?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ;
  2. ; check if standard Lua libraries are loaded
  3. ; see Lua 5.4 manual for full details: https://www.lua.org/manual/5.4/manual.html#6
  4. ;
  5.     LUA
  6.         -- base lib
  7.         assert(true)
  8.         assert(2 == tonumber("10", 2))
  9.         assert(43794 == tonumber("ab12", 16))
  10.         assert("1234" == tostring(1234))
  11.         assert("Lua 5.4" == _VERSION)
  12.         assert("nil" == type(nil))
  13.         -- string manipulation
  14.         assert(0x42 == string.byte("ABC", 2))
  15.         assert("ABC" == string.char(0x41, 0x42, 0x43))
  16.         assert("ab12" == string.format('%x', 43794))
  17.         -- math
  18.         assert(math.abs(300 * 0.07 - 21.0) ~= 0)        -- trollface
  19.         assert(math.abs(300 * 0.07 - 21.0) < 1e-14)     -- lua doesn't have epsilon-equal out of box :/
  20.        assert(128 == 2^7)  -- math.pow is replaced by "^" operator in recent Lua versions
  21.        assert("integer" == math.type(1234))
  22.        assert("float" == math.type(1234.0))
  23.        -- and others... see the documentation
  24.    ENDLUA
  25.  
  26. ;
  27. ; Third-party embedded library(ies) from old sjasmplus versions (if they ever did work?)
  28. ;
  29.  
  30. ; hex: hex.to_hex(i), hex.to_dec(h)
  31. ; - removed, this should be easy to replace with standard lib, write your own wrappers if needed
  32.    LUA
  33.        assert(43794 == tonumber("ab12", 16))
  34.        assert(43794 == tonumber("0xab12"))
  35.        assert("ab12" == string.format('%x', 43794))
  36.        assert("0xab12" == string.format('0x%x', 43794))
  37.    ENDLUA
  38.  
  39. ; bitwise operators: bit.bxor(a, b) (bnot,band,bor,bxor,brshift,blshift,bxor2,blogic_rshift,tobits,tonumb)
  40. ; - removed, these are part of Lua now (since Lua 5.3)
  41.    LUA
  42.        assert(-1 == ~0)
  43.        assert(0xA0C0 == 0xABCD & 0xF0F0)
  44.        assert(0xABCD == 0xA0C1 | 0xAB0C)
  45.        assert(0xA0CC == 0xABCD ~ 0x0B01)
  46.        assert(0xAB00 == 0xAB << 8)
  47.        assert(0xAB == 0xAB00 >> 8)
  48.    ENDLUA
  49.  
  50. ; lpack.c: string.pack, string.unpack
  51. ; - removed, part of standard Lua string lib
  52.    LUA
  53.        assert("ABCD" == string.pack("bbbb", 0x41, 0x42, 0x43, 0x44))
  54.        assert(0x4241, 0x4142, 5 == string.unpack("<H>H", "ABAB"))
  55.    ENDLUA
  56.