diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-03-05 16:08:41 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-03-05 16:08:41 +0800 |
| commit | 890fc913737c62c5d7e51636e0535b7b318a0d89 (patch) | |
| tree | 8ca71fc3a2599ad1cbebcd3234dcb06292448037 /spec | |
| parent | 3b94999e55df35d19616e87d7f3b6fddf5b8a30b (diff) | |
| download | yuescript-890fc913737c62c5d7e51636e0535b7b318a0d89.tar.gz yuescript-890fc913737c62c5d7e51636e0535b7b318a0d89.tar.bz2 yuescript-890fc913737c62c5d7e51636e0535b7b318a0d89.zip | |
move functions of old export statement to global statement, make export statement work with Lua module system.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/inputs/class.moon | 2 | ||||
| -rw-r--r-- | spec/inputs/export.moon | 98 | ||||
| -rw-r--r-- | spec/inputs/export_default.moon | 15 | ||||
| -rw-r--r-- | spec/inputs/global.moon | 77 | ||||
| -rw-r--r-- | spec/inputs/import.moon | 2 |
5 files changed, 127 insertions, 67 deletions
diff --git a/spec/inputs/class.moon b/spec/inputs/class.moon index 3288dc6..533694e 100644 --- a/spec/inputs/class.moon +++ b/spec/inputs/class.moon | |||
| @@ -158,7 +158,7 @@ print (class WhatsUp).__name | |||
| 158 | 158 | ||
| 159 | -- | 159 | -- |
| 160 | 160 | ||
| 161 | export ^ | 161 | global ^ |
| 162 | class Something | 162 | class Something |
| 163 | _ = nil | 163 | _ = nil |
| 164 | 164 | ||
diff --git a/spec/inputs/export.moon b/spec/inputs/export.moon index a8c782c..9c906d5 100644 --- a/spec/inputs/export.moon +++ b/spec/inputs/export.moon | |||
| @@ -1,77 +1,45 @@ | |||
| 1 | 1 | ||
| 2 | do | 2 | export a,b,c = 223, 343, 123 |
| 3 | export a,b,c = 223, 343 | 3 | export cool = "dad" |
| 4 | export cool = "dad" | ||
| 5 | 4 | ||
| 6 | do | 5 | d,e,f = 3, 2, 1 |
| 7 | export class Something | 6 | export d, e, f |
| 8 | umm: "cool" | ||
| 9 | 7 | ||
| 10 | do | 8 | export class Something |
| 11 | export a,b,c | 9 | umm: "cool" |
| 12 | a,b,c,d = "hello" | ||
| 13 | 10 | ||
| 11 | export if this | ||
| 12 | 232 | ||
| 13 | else | ||
| 14 | 4343 | ||
| 14 | 15 | ||
| 15 | do | 16 | export What = if this |
| 16 | What = if this | 17 | 232 |
| 17 | 232 | 18 | else |
| 18 | else | 19 | 4343 |
| 19 | 4343 | ||
| 20 | 20 | ||
| 21 | export ^ | 21 | export y = -> |
| 22 | hallo = 3434 | ||
| 22 | 23 | ||
| 23 | another = 3434 | 24 | export with tmp |
| 24 | Another = 7890 | 25 | j = 2000 |
| 25 | 26 | ||
| 26 | if inner then Yeah = "10000" | 27 | export cbVal = do |
| 27 | 28 | h = 100 | |
| 28 | What = if this | 29 | (x)<- f |
| 29 | 232 | 30 | return x h |
| 30 | else | ||
| 31 | 4343 | ||
| 32 | |||
| 33 | |||
| 34 | do | ||
| 35 | export * | ||
| 36 | |||
| 37 | What = if this | ||
| 38 | 232 | ||
| 39 | else | ||
| 40 | 4343 | ||
| 41 | |||
| 42 | x,y,z = 1,2,3 | ||
| 43 | |||
| 44 | y = -> | ||
| 45 | hallo = 3434 | ||
| 46 | |||
| 47 | with tmp | ||
| 48 | j = 2000 | ||
| 49 | |||
| 50 | |||
| 51 | do | ||
| 52 | export * | ||
| 53 | x = 3434 | ||
| 54 | if y then | ||
| 55 | x = 10 | ||
| 56 | |||
| 57 | do | ||
| 58 | export * | ||
| 59 | if y then | ||
| 60 | x = 10 | ||
| 61 | x = 3434 | ||
| 62 | |||
| 63 | do | ||
| 64 | do | ||
| 65 | export * | ||
| 66 | |||
| 67 | k = 1212 | ||
| 68 | 31 | ||
| 69 | do | 32 | export y = -> |
| 70 | h = 100 | 33 | h = 100 |
| 34 | k = 100 | ||
| 71 | 35 | ||
| 72 | y = -> | 36 | export switch h |
| 73 | h = 100 | 37 | when 100, 150 then 200 |
| 74 | k = 100 | 38 | when 200 then 300 |
| 39 | else 0 | ||
| 75 | 40 | ||
| 76 | h = 100 | 41 | export Constant = switch value |
| 42 | when "good" then 1 | ||
| 43 | when "better" then 2 | ||
| 44 | when "best" then 3 | ||
| 77 | 45 | ||
diff --git a/spec/inputs/export_default.moon b/spec/inputs/export_default.moon new file mode 100644 index 0000000..73f43ac --- /dev/null +++ b/spec/inputs/export_default.moon | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | |||
| 2 | print "OK" | ||
| 3 | |||
| 4 | export default -> | ||
| 5 | print "hello" | ||
| 6 | 123 | ||
| 7 | |||
| 8 | (x, fy)<- f 123, "abc" unless isOff | ||
| 9 | print x | ||
| 10 | (y, res)<- fy | ||
| 11 | return if res | ||
| 12 | abc + y | ||
| 13 | else | ||
| 14 | abc | ||
| 15 | |||
diff --git a/spec/inputs/global.moon b/spec/inputs/global.moon new file mode 100644 index 0000000..7d6cfde --- /dev/null +++ b/spec/inputs/global.moon | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | |||
| 2 | do | ||
| 3 | global a,b,c = 223, 343 | ||
| 4 | global cool = "dad" | ||
| 5 | |||
| 6 | do | ||
| 7 | global class Something | ||
| 8 | umm: "cool" | ||
| 9 | |||
| 10 | do | ||
| 11 | global a,b,c | ||
| 12 | a,b,c,d = "hello" | ||
| 13 | |||
| 14 | |||
| 15 | do | ||
| 16 | What = if this | ||
| 17 | 232 | ||
| 18 | else | ||
| 19 | 4343 | ||
| 20 | |||
| 21 | global ^ | ||
| 22 | |||
| 23 | another = 3434 | ||
| 24 | Another = 7890 | ||
| 25 | |||
| 26 | if inner then Yeah = "10000" | ||
| 27 | |||
| 28 | What = if this | ||
| 29 | 232 | ||
| 30 | else | ||
| 31 | 4343 | ||
| 32 | |||
| 33 | |||
| 34 | do | ||
| 35 | global * | ||
| 36 | |||
| 37 | What = if this | ||
| 38 | 232 | ||
| 39 | else | ||
| 40 | 4343 | ||
| 41 | |||
| 42 | x,y,z = 1,2,3 | ||
| 43 | |||
| 44 | y = -> | ||
| 45 | hallo = 3434 | ||
| 46 | |||
| 47 | with tmp | ||
| 48 | j = 2000 | ||
| 49 | |||
| 50 | |||
| 51 | do | ||
| 52 | global * | ||
| 53 | x = 3434 | ||
| 54 | if y then | ||
| 55 | x = 10 | ||
| 56 | |||
| 57 | do | ||
| 58 | global * | ||
| 59 | if y then | ||
| 60 | x = 10 | ||
| 61 | x = 3434 | ||
| 62 | |||
| 63 | do | ||
| 64 | do | ||
| 65 | global * | ||
| 66 | |||
| 67 | k = 1212 | ||
| 68 | |||
| 69 | do | ||
| 70 | h = 100 | ||
| 71 | |||
| 72 | y = -> | ||
| 73 | h = 100 | ||
| 74 | k = 100 | ||
| 75 | |||
| 76 | h = 100 | ||
| 77 | |||
diff --git a/spec/inputs/import.moon b/spec/inputs/import.moon index ded1ffd..99981f8 100644 --- a/spec/inputs/import.moon +++ b/spec/inputs/import.moon | |||
| @@ -58,7 +58,7 @@ do | |||
| 58 | import "lpeg" as {:C, :Ct, :Cmt} | 58 | import "lpeg" as {:C, :Ct, :Cmt} |
| 59 | 59 | ||
| 60 | do | 60 | do |
| 61 | export * | 61 | global * |
| 62 | import 'module' | 62 | import 'module' |
| 63 | import 'module_x' | 63 | import 'module_x' |
| 64 | import "org.package.module-y" | 64 | import "org.package.module-y" |
