diff options
Diffstat (limited to 'spec/outputs/import_global.lua')
| -rw-r--r-- | spec/outputs/import_global.lua | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/spec/outputs/import_global.lua b/spec/outputs/import_global.lua new file mode 100644 index 0000000..895daf9 --- /dev/null +++ b/spec/outputs/import_global.lua | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | do | ||
| 2 | local print <const> = print | ||
| 3 | local math <const> = math | ||
| 4 | print("hello") | ||
| 5 | math.random(10) | ||
| 6 | end | ||
| 7 | do | ||
| 8 | local print <const> = print | ||
| 9 | local value = 1 | ||
| 10 | value = value + 2 | ||
| 11 | print(value) | ||
| 12 | end | ||
| 13 | do | ||
| 14 | local print | ||
| 15 | print = function(msg) | ||
| 16 | return msg | ||
| 17 | end | ||
| 18 | do | ||
| 19 | local math <const> = math | ||
| 20 | print("local") | ||
| 21 | math.random(1) | ||
| 22 | end | ||
| 23 | end | ||
| 24 | do | ||
| 25 | local print <const> = print | ||
| 26 | local tostring | ||
| 27 | tostring = function(v) | ||
| 28 | return "local" | ||
| 29 | end | ||
| 30 | tostring("value") | ||
| 31 | print(tostring(123)) | ||
| 32 | end | ||
| 33 | do | ||
| 34 | local func | ||
| 35 | func = function(x, y) | ||
| 36 | local type <const> = type | ||
| 37 | local tostring <const> = tostring | ||
| 38 | local print <const> = print | ||
| 39 | return type(x, tostring(y, print)) | ||
| 40 | end | ||
| 41 | func(1, 2) | ||
| 42 | end | ||
| 43 | do | ||
| 44 | local xpcall <const> = xpcall | ||
| 45 | local func <const> = func | ||
| 46 | local world <const> = world | ||
| 47 | local tostring <const> = tostring | ||
| 48 | local print <const> = print | ||
| 49 | xpcall(function() | ||
| 50 | return func("hello " .. tostring(world)) | ||
| 51 | end, function(err) | ||
| 52 | return print(err) | ||
| 53 | end) | ||
| 54 | end | ||
| 55 | do | ||
| 56 | local print <const> = print | ||
| 57 | print(FLAG) | ||
| 58 | FLAG = 123 | ||
| 59 | end | ||
| 60 | do | ||
| 61 | local print <const> = print | ||
| 62 | Foo = 10 | ||
| 63 | print(Foo) | ||
| 64 | Foo = Foo + 2 | ||
| 65 | end | ||
| 66 | do | ||
| 67 | local print <const> = print | ||
| 68 | Bar = 1 | ||
| 69 | Baz = 2 | ||
| 70 | print(Bar, Baz) | ||
| 71 | end | ||
| 72 | do | ||
| 73 | local y <const> = y | ||
| 74 | x = 3434 | ||
| 75 | if y then | ||
| 76 | x = 10 | ||
| 77 | end | ||
| 78 | end | ||
| 79 | do | ||
| 80 | local lowercase <const> = lowercase | ||
| 81 | local tostring <const> = tostring | ||
| 82 | local Uppercase <const> = Uppercase | ||
| 83 | local foobar = "all " .. tostring(lowercase) | ||
| 84 | FooBar = "pascal case" | ||
| 85 | FOOBAR = "all " .. tostring(Uppercase) | ||
| 86 | end | ||
| 87 | do | ||
| 88 | local setmetatable <const> = setmetatable | ||
| 89 | local print <const> = print | ||
| 90 | do | ||
| 91 | local _class_0 | ||
| 92 | local _base_0 = { } | ||
| 93 | if _base_0.__index == nil then | ||
| 94 | _base_0.__index = _base_0 | ||
| 95 | end | ||
| 96 | _class_0 = setmetatable({ | ||
| 97 | __init = function() end, | ||
| 98 | __base = _base_0, | ||
| 99 | __name = "A" | ||
| 100 | }, { | ||
| 101 | __index = _base_0, | ||
| 102 | __call = function(cls, ...) | ||
| 103 | local _self_0 = setmetatable({ }, _base_0) | ||
| 104 | cls.__init(_self_0, ...) | ||
| 105 | return _self_0 | ||
| 106 | end | ||
| 107 | }) | ||
| 108 | _base_0.__class = _class_0 | ||
| 109 | A = _class_0 | ||
| 110 | end | ||
| 111 | Flag = 1 | ||
| 112 | const, x, y = "const", 1, 2 | ||
| 113 | print(math, table) | ||
| 114 | end | ||
| 115 | do | ||
| 116 | local X <const> = X | ||
| 117 | X:func(1, 2, 3) | ||
| 118 | X.tag = "abc" | ||
| 119 | end | ||
| 120 | local _anon_func_0 = function(func) | ||
| 121 | return func | ||
| 122 | end | ||
| 123 | do | ||
| 124 | local func <const> = func | ||
| 125 | local pcall <const> = pcall | ||
| 126 | local f | ||
| 127 | f = function() | ||
| 128 | func() | ||
| 129 | return pcall(_anon_func_0, func) | ||
| 130 | end | ||
| 131 | end | ||
