diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/const-array-complex.mnml | 2 | ||||
-rw-r--r-- | test/const-array.mnml | 8 | ||||
-rw-r--r-- | test/const-function-if.mnml | 5 | ||||
-rw-r--r-- | test/const-function.mnml | 2 | ||||
-rw-r--r-- | test/const-map.mnml | 7 | ||||
-rw-r--r-- | test/const-simple.mnml | 2 | ||||
-rw-r--r-- | test/if.mnml | 2 | ||||
-rw-r--r-- | test/parentheses.mnml | 7 | ||||
-rw-r--r-- | test/self/lexer.mnml | 22 | ||||
-rw-r--r-- | test/test.mnml | 4 |
10 files changed, 51 insertions, 10 deletions
diff --git a/test/const-array-complex.mnml b/test/const-array-complex.mnml index 07e2286..00edaac 100644 --- a/test/const-array-complex.mnml +++ b/test/const-array-complex.mnml @@ -1 +1 @@ -const array: [[integer]] = [[1, 2], [3, 4], [5, 6, 7]] +const array: [[integer]] = [[1, 2], [3, 4], [5, 6, 7_000_000]] diff --git a/test/const-array.mnml b/test/const-array.mnml index 03c7163..f79adbf 100644 --- a/test/const-array.mnml +++ b/test/const-array.mnml @@ -1,2 +1,8 @@ const array: [integer] = [1, 2, 3] -const array2: [integer] = [3, 4, 5] +const array2: [integer] = [3, [4, 8], 5] + +const main: function = (array3: [integer], array4: [integer]): integer { + return array4[1][1] +} + +main(array3 = array, array4 = array2) diff --git a/test/const-function-if.mnml b/test/const-function-if.mnml index 11883cd..7b71b8c 100644 --- a/test/const-function-if.mnml +++ b/test/const-function-if.mnml @@ -1,6 +1,7 @@ const main: function = (input: string): string { if (input == "hello") { const bye: string = "bye" + return input + " " + bye } return input @@ -9,5 +10,7 @@ const main: function = (input: string): string { const main2: function = (input: string): string { const bye: string = main(input = "bye") - return main(input = "hello") + return input + main(input = "hello") } + +main(input = "hello") => main2(input = $ + " ") diff --git a/test/const-function.mnml b/test/const-function.mnml index 9630dd8..5a82b68 100644 --- a/test/const-function.mnml +++ b/test/const-function.mnml @@ -5,4 +5,4 @@ const main: function = (input: string or integer, default: integer = 1): void { return hello + " " + bye } -main(input = "hey", 2) +main(input = "hey", default = 2) diff --git a/test/const-map.mnml b/test/const-map.mnml index b63b68b..6942bba 100644 --- a/test/const-map.mnml +++ b/test/const-map.mnml @@ -8,4 +8,11 @@ const map: [string][string or integer or bool] = [ },*/ "sixth" = 20_000, "seventh" = 20.02, + "eight" = [8, 9, 0], ] + +const main: function = (input: [string][string or integer or bool]): string { + return input["eight"][2] +} + +main(input = map) diff --git a/test/const-simple.mnml b/test/const-simple.mnml index 5da0a0f..f7f597d 100644 --- a/test/const-simple.mnml +++ b/test/const-simple.mnml @@ -1,2 +1,2 @@ const henshin: integer = 2 -const new: integer = henshin + 5 * 10 +const new: integer = (henshin * 5) + 10 diff --git a/test/if.mnml b/test/if.mnml index 1d273b3..8227ad5 100644 --- a/test/if.mnml +++ b/test/if.mnml @@ -1,4 +1,4 @@ -if (1 == 2) { +if ((1 == 2) or (2 == 3)) { main1() } diff --git a/test/parentheses.mnml b/test/parentheses.mnml index d18aee2..f321700 100644 --- a/test/parentheses.mnml +++ b/test/parentheses.mnml @@ -1,6 +1,7 @@ const main: function = (input: string): string { if ((input == "hello") or input == "bye") { - const bye: string = "bye" + const bye: string = "bye" + return bye } return input @@ -13,5 +14,7 @@ const main2: function = (input: string): string { const test2: string = ((main(input = "test") => main(input = $)) + "test2") - return main(input = "hello") + bye + return input + main(input = "hello") + bye + " " + test2 } + +main(input = "test") => main2(input = $) diff --git a/test/self/lexer.mnml b/test/self/lexer.mnml new file mode 100644 index 0000000..8468f66 --- /dev/null +++ b/test/self/lexer.mnml @@ -0,0 +1,22 @@ +const main: function = (input: string): array { + return lex(input = input, position = 0, output = []) +} + +const lex: function = (input: string, position: integer, output: array): array { + if (position == (strlen(input))) { + return output + } + + const current_char: string = get_char(input, position) + + const appended_output: array + if (current_char != " ") { + appended_output = array_append(output, current_char) + } else { + appended_output = output + } + + return lex(input = input, position = (position + 1), output = appended_output) +} + +main(input = "a b c d e f g") => dump($) diff --git a/test/test.mnml b/test/test.mnml index a14bdec..6ecb7d9 100644 --- a/test/test.mnml +++ b/test/test.mnml @@ -12,11 +12,11 @@ const main: function = (input: string or integer): void { return hello + " " + bye } -main()/* +main(input = "mlc")/* * mlc */ -main("pipe1!") => print($) +main(input = "pipe1!") => print($) /*var mls: string = "alphabet ende |