?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.   ; missing arguments errors (stops scripts)
  2.   LUA
  3.     sj.get_label()
  4.   ENDLUA
  5.   LUA
  6.      -- sj.insert_label() -- disabled, the error message is platform+compiler dependent, linux reports #2 arg, macos+bsd #1 arg
  7.   ENDLUA
  8.   LUA
  9.     sj.insert_label("no_address")
  10.   ENDLUA
  11.  
  12. foo   EQU   0x1234
  13. bay   EQU   bar + 0x1111
  14.  
  15.   LUA PASS1
  16.     -- regular get_label
  17.     assert(0x1234 == sj.get_label("foo"))
  18.  
  19.     -- regular insert_label
  20.     assert(0 == sj.get_label("bar"))
  21.     assert(true == sj.insert_label("bar",0x2345))
  22.     assert(0x2345 == sj.get_label("bar"))
  23.     assert(false == sj.insert_label("bar",0x3456))  -- can't modify regular label
  24.    assert(0x2345 == sj.get_label("bar"))
  25.  
  26.    assert(0x1111 == sj.get_label("bay"))   -- not modified by inserting "bar" yet
  27.    assert(0 == sj.get_label("baz"))        -- not defined yet (not modified by inserting "bar")
  28.  
  29.    -- invalid args (avoid hard crash)
  30.    assert(-1 == sj.get_label("1_invalid_name"))
  31.    assert(-1 == sj.get_label(nil))
  32.    assert(-1 == sj.get_label(""))
  33.    assert(-1 == sj.get_label(" "))
  34.    assert(-1 == sj.get_label("@"))
  35.  
  36.    assert(false == sj.insert_label(nil, 0x2345))
  37.    assert(false == sj.insert_label("", 0x2345))
  38.    assert(false == sj.insert_label(" ", 0x2345))
  39.    assert(false == sj.insert_label("@", 0x2345))
  40.    assert(false == sj.insert_label(".", 0x2345))
  41.    assert(false == sj.insert_label("1_invalid_name", 0x2345))
  42.  ENDLUA
  43.  
  44.  LUA PASS3
  45.    -- regular get_label
  46.    assert(0x1234 == sj.get_label("foo"))
  47.  
  48.    -- regular insert_label
  49.    assert(0x2345 == sj.get_label("bar"))
  50.    assert(true == sj.insert_label("bar",0x2346)) -- can modify if defining it first time this pass, but will emit warning
  51.    assert(0x2346 == sj.get_label("bar"))
  52.    assert(false == sj.insert_label("bar",0x3456)) -- can't modify regular label
  53.     assert(0x2346 == sj.get_label("bar"))
  54.  
  55.     assert(0x2345+0x1111 == sj.get_label("bay")) -- defined with older value 0x2345
  56.     assert(0x2345+0x1111 == sj.get_label("baz")) -- defined with older value 0x2345
  57.  
  58.     -- invalid args (avoid hard crash) - also produce regular errors in PASS3
  59.     assert(-1 == sj.get_label("1_invalid_name"))
  60.     assert(-1 == sj.get_label(nil))
  61.     assert(-1 == sj.get_label(""))
  62.     assert(-1 == sj.get_label(" "))
  63.     assert(-1 == sj.get_label("@"))
  64.  
  65.     assert(false == sj.insert_label(nil, 0x2345))
  66.     assert(false == sj.insert_label("", 0x2345))
  67.     assert(false == sj.insert_label(" ", 0x2345))
  68.     assert(false == sj.insert_label("@", 0x2345))
  69.     assert(false == sj.insert_label(".", 0x2345))
  70.     assert(false == sj.insert_label("1_invalid_name", 0x2345))
  71.   ENDLUA
  72.  
  73. baz   EQU   bar + 0x1111
  74.