diff options
Diffstat (limited to 'tests/pracownia3')
48 files changed, 560 insertions, 0 deletions
diff --git a/tests/pracownia3/000_manyargs_3.xi b/tests/pracownia3/000_manyargs_3.xi new file mode 100644 index 0000000..3e73ca9 --- /dev/null +++ b/tests/pracownia3/000_manyargs_3.xi @@ -0,0 +1,11 @@ +f(r0:int, r1:int, r2:int, r3:int, r4:int, r5:int, r6:int):int +{ + return r0 + r1 + r2 + r3 + r4 + r5 + r6 +} + +main():int { + return f(1, 2, 3, 4, 5, 6, 7) +} + +//@PRACOWNIA +//@out Exit code: 28 diff --git a/tests/pracownia3/001_or_01.xi b/tests/pracownia3/001_or_01.xi new file mode 100644 index 0000000..42e3715 --- /dev/null +++ b/tests/pracownia3/001_or_01.xi @@ -0,0 +1,30 @@ +printString(str:int[]) + +pred_lhs():bool +{ + printString("pred_lhs") + return false +} + +pred_rhs():bool +{ + printString("pred_rhs") + return true +} + +main():int +{ + result:int = 3 + if pred_lhs() | pred_rhs() { + result = 1 + } else { + result = 0 + } + + return result +} + +//@PRACOWNIA +//@out pred_lhs +//@out pred_rhs +//@out Exit code: 1 diff --git a/tests/pracownia3/002_list_empty.xi b/tests/pracownia3/002_list_empty.xi new file mode 100644 index 0000000..a7a2c9d --- /dev/null +++ b/tests/pracownia3/002_list_empty.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = {1,2,3} + return 0 +} + +//@PRACOWNIA +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/003_concat_rhs_len.xi b/tests/pracownia3/003_concat_rhs_len.xi new file mode 100644 index 0000000..5ab6e64 --- /dev/null +++ b/tests/pracownia3/003_concat_rhs_len.xi @@ -0,0 +1,8 @@ +main():int +{ + z:int[] = {} + {100, 200} + return length(z) +} + +//@PRACOWNIA +//@out Exit code: 2
\ No newline at end of file diff --git a/tests/pracownia3/004_return.xi b/tests/pracownia3/004_return.xi new file mode 100644 index 0000000..a24d01a --- /dev/null +++ b/tests/pracownia3/004_return.xi @@ -0,0 +1,12 @@ +return_4():int +{ + return 4 +} + +main():int +{ + return return_4() +} + +//@PRACOWNIA +//@out Exit code: 4
\ No newline at end of file diff --git a/tests/pracownia3/005_multireturn_multiargs.xi b/tests/pracownia3/005_multireturn_multiargs.xi new file mode 100644 index 0000000..96fbb57 --- /dev/null +++ b/tests/pracownia3/005_multireturn_multiargs.xi @@ -0,0 +1,12 @@ +f(a0:int, a1:int, a2:int, a3:int, a4:int, a5:int, a6:int): int, int, int, int, int, int, int +{ + return a0, a1, a2, a3, a4, a5, a6 +} + +main():int { + a0:int, a1:int, a2:int, a3:int, a4:int, a5:int, a6:int = f(10,20,30,40,50,60,70) + return a0+a1+a2+a3+a4+a5+a6 +} + +//@PRACOWNIA +//@out Exit code: 280 diff --git a/tests/pracownia3/006_init_variable.xi b/tests/pracownia3/006_init_variable.xi new file mode 100644 index 0000000..27940b7 --- /dev/null +++ b/tests/pracownia3/006_init_variable.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int = 42; + return 13 +} + +//@PRACOWNIA +//@out Exit code: 13
\ No newline at end of file diff --git a/tests/pracownia3/007_mul_literals.xi b/tests/pracownia3/007_mul_literals.xi new file mode 100644 index 0000000..4302efe --- /dev/null +++ b/tests/pracownia3/007_mul_literals.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 4 * 3 +} + +//@PRACOWNIA +//@out Exit code: 12
\ No newline at end of file diff --git a/tests/pracownia3/008_fac_rec_0.xi b/tests/pracownia3/008_fac_rec_0.xi new file mode 100644 index 0000000..45d5265 --- /dev/null +++ b/tests/pracownia3/008_fac_rec_0.xi @@ -0,0 +1,15 @@ +fac(x:int):int +{ + if (x == 0) { + return 1 + } + return fac(x-1)*x +} + +main():int +{ + return fac(0) +} + +//@PRACOWNIA +//@out Exit code: 1
\ No newline at end of file diff --git a/tests/pracownia3/009_while_while_sum.xi b/tests/pracownia3/009_while_while_sum.xi new file mode 100644 index 0000000..abb029c --- /dev/null +++ b/tests/pracownia3/009_while_while_sum.xi @@ -0,0 +1,18 @@ +main():int +{ + i:int = 0; + n:int = 10; + sum:int = 0; + while (i < n) { + j:int = 0 + while (j < n) { + sum = sum + j + j = j + 1 + } + i = i + 1 + } + return sum +} + +//@PRACOWNIA +//@out Exit code: 450
\ No newline at end of file diff --git a/tests/pracownia3/010_length_empty.xi b/tests/pracownia3/010_length_empty.xi new file mode 100644 index 0000000..46b3025 --- /dev/null +++ b/tests/pracownia3/010_length_empty.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = {} + return length(x) +} + +//@PRACOWNIA +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/011_concat_string.xi b/tests/pracownia3/011_concat_string.xi new file mode 100644 index 0000000..c245c05 --- /dev/null +++ b/tests/pracownia3/011_concat_string.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = "Wro" + "claw" + return length(x) +} + +//@PRACOWNIA +//@out Exit code: 7
\ No newline at end of file diff --git a/tests/pracownia3/012_multireturn_4.xi b/tests/pracownia3/012_multireturn_4.xi new file mode 100644 index 0000000..7b1c7b7 --- /dev/null +++ b/tests/pracownia3/012_multireturn_4.xi @@ -0,0 +1,12 @@ +f(): int, int, int, int +{ + return 10, 15, 20, 25 +} + +main():int { + x:int, y:int, z:int, v:int = f() + return x + y + z + v; +} + +//@PRACOWNIA +//@out Exit code: 70 diff --git a/tests/pracownia3/013_add_literals.xi b/tests/pracownia3/013_add_literals.xi new file mode 100644 index 0000000..9ced5c6 --- /dev/null +++ b/tests/pracownia3/013_add_literals.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 4 + 3 +} + +//@PRACOWNIA +//@out Exit code: 7
\ No newline at end of file diff --git a/tests/pracownia3/014_assign.xi b/tests/pracownia3/014_assign.xi new file mode 100644 index 0000000..bb62c67 --- /dev/null +++ b/tests/pracownia3/014_assign.xi @@ -0,0 +1,9 @@ +main():int +{ + x:int = 42 + x = 10 + return x +} + +//@PRACOWNIA +//@out Exit code: 10
\ No newline at end of file diff --git a/tests/pracownia3/015_sub_literals.xi b/tests/pracownia3/015_sub_literals.xi new file mode 100644 index 0000000..2a8ce93 --- /dev/null +++ b/tests/pracownia3/015_sub_literals.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 4 - 3 +} + +//@PRACOWNIA +//@out Exit code: 1
\ No newline at end of file diff --git a/tests/pracownia3/016_fib_rec_3.xi b/tests/pracownia3/016_fib_rec_3.xi new file mode 100644 index 0000000..49a5d5b --- /dev/null +++ b/tests/pracownia3/016_fib_rec_3.xi @@ -0,0 +1,18 @@ +fib(x:int):int +{ + if (x == 0) { + return 0 + } + if (x == 1) { + return 1 + } + return fib(x-1) + fib(x-2) +} + +main():int +{ + return fib(5) +} + +//@PRACOWNIA +//@out Exit code: 5
\ No newline at end of file diff --git a/tests/pracownia3/017_return_42.xi b/tests/pracownia3/017_return_42.xi new file mode 100644 index 0000000..6d53081 --- /dev/null +++ b/tests/pracownia3/017_return_42.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 42 +} + +//@PRACOWNIA +//@out Exit code: 42
\ No newline at end of file diff --git a/tests/pracownia3/018_empty_main.xi b/tests/pracownia3/018_empty_main.xi new file mode 100644 index 0000000..336daf1 --- /dev/null +++ b/tests/pracownia3/018_empty_main.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 0 +} + +//@PRACOWNIA +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/019_while_sum.xi b/tests/pracownia3/019_while_sum.xi new file mode 100644 index 0000000..8821a07 --- /dev/null +++ b/tests/pracownia3/019_while_sum.xi @@ -0,0 +1,14 @@ +main():int +{ + i:int = 0; + n:int = 10; + sum:int = 0; + while (i < n) { + sum = sum + i + i = i + 1 + } + return sum +} + +//@PRACOWNIA +//@out Exit code: 45
\ No newline at end of file diff --git a/tests/pracownia3/020_return_variable.xi b/tests/pracownia3/020_return_variable.xi new file mode 100644 index 0000000..288a5eb --- /dev/null +++ b/tests/pracownia3/020_return_variable.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int = 42 + return x +} + +//@PRACOWNIA +//@out Exit code: 42
\ No newline at end of file diff --git a/tests/pracownia3/021_printInt.xi b/tests/pracownia3/021_printInt.xi new file mode 100644 index 0000000..5f75922 --- /dev/null +++ b/tests/pracownia3/021_printInt.xi @@ -0,0 +1,16 @@ + +printInt(x:int) + +main():int +{ + printInt(5) + printInt(10) + printInt(15) + return 0 +} + +//@PRACOWNIA +//@out 5 +//@out 10 +//@out 15 +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/022_if_eq_true.xi b/tests/pracownia3/022_if_eq_true.xi new file mode 100644 index 0000000..4571f1b --- /dev/null +++ b/tests/pracownia3/022_if_eq_true.xi @@ -0,0 +1,13 @@ +main():int +{ + x:int = 33; + result:int = 99 + if (x == 33) { + result = 100 + } + + return result +} + +//@PRACOWNIA +//@out Exit code: 100
\ No newline at end of file diff --git a/tests/pracownia3/023_ifelse_pred.xi b/tests/pracownia3/023_ifelse_pred.xi new file mode 100644 index 0000000..10010d6 --- /dev/null +++ b/tests/pracownia3/023_ifelse_pred.xi @@ -0,0 +1,18 @@ +pred():bool +{ + return true +} + +main():int +{ + result:int = 13 + if pred() { + result = 100 + } else { + result = 1 + } + return result +} + +//@PRACOWNIA +//@out Exit code: 100 diff --git a/tests/pracownia3/024_fac.xi b/tests/pracownia3/024_fac.xi new file mode 100644 index 0000000..381de7c --- /dev/null +++ b/tests/pracownia3/024_fac.xi @@ -0,0 +1,17 @@ +fac(x:int):int +{ + res:int = 1 + while (x > 0) { + res = x*res + x = x - 1 + } + return res +} + +main():int +{ + return fac(5) +} + +//@PRACOWNIA +//@out Exit code: 120
\ No newline at end of file diff --git a/tests/pracownia3/025_and_literals.xi b/tests/pracownia3/025_and_literals.xi new file mode 100644 index 0000000..fc87e96 --- /dev/null +++ b/tests/pracownia3/025_and_literals.xi @@ -0,0 +1,16 @@ +convert(b:bool):int +{ + if b { + return 1 + } else { + return 0 + } +} + +main():int +{ + return convert(true & false) +} + +//@PRACOWNIA +//@out Exit code: 0 diff --git a/tests/pracownia3/026_printString.xi b/tests/pracownia3/026_printString.xi new file mode 100644 index 0000000..29dc5aa --- /dev/null +++ b/tests/pracownia3/026_printString.xi @@ -0,0 +1,11 @@ +printString(x:int[]) + +main():int +{ + printString("Wroclaw") + return 0 +} + +//@PRACOWNIA +//@out Wroclaw +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/027_init_2_variables.xi b/tests/pracownia3/027_init_2_variables.xi new file mode 100644 index 0000000..b417ab1 --- /dev/null +++ b/tests/pracownia3/027_init_2_variables.xi @@ -0,0 +1,9 @@ +main():int +{ + x:int = 42; + y:int = 43; + return 14 +} + +//@PRACOWNIA +//@out Exit code: 14
\ No newline at end of file diff --git a/tests/pracownia3/028_return_second_variable.xi b/tests/pracownia3/028_return_second_variable.xi new file mode 100644 index 0000000..257fce9 --- /dev/null +++ b/tests/pracownia3/028_return_second_variable.xi @@ -0,0 +1,9 @@ +main():int +{ + x:int = 42 + y:int = 43 + return y +} + +//@PRACOWNIA +//@out Exit code: 43
\ No newline at end of file diff --git a/tests/pracownia3/029_return_first_variable.xi b/tests/pracownia3/029_return_first_variable.xi new file mode 100644 index 0000000..138a3a2 --- /dev/null +++ b/tests/pracownia3/029_return_first_variable.xi @@ -0,0 +1,9 @@ +main():int +{ + x:int = 42 + y:int = 43 + return x +} + +//@PRACOWNIA +//@out Exit code: 42
\ No newline at end of file diff --git a/tests/pracownia3/030_length_string.xi b/tests/pracownia3/030_length_string.xi new file mode 100644 index 0000000..bc6011a --- /dev/null +++ b/tests/pracownia3/030_length_string.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = "Wroclaw" + return length(x) +} + +//@PRACOWNIA +//@out Exit code: 7
\ No newline at end of file diff --git a/tests/pracownia3/031_div_literals.xi b/tests/pracownia3/031_div_literals.xi new file mode 100644 index 0000000..16a75f8 --- /dev/null +++ b/tests/pracownia3/031_div_literals.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 8 / 2 +} + +//@PRACOWNIA +//@out Exit code: 4
\ No newline at end of file diff --git a/tests/pracownia3/032_return_index0.xi b/tests/pracownia3/032_return_index0.xi new file mode 100644 index 0000000..09ddee4 --- /dev/null +++ b/tests/pracownia3/032_return_index0.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = {5, 10, 15} + return x[0] +} + +//@PRACOWNIA +//@out Exit code: 5
\ No newline at end of file diff --git a/tests/pracownia3/033_multiarray.xi b/tests/pracownia3/033_multiarray.xi new file mode 100644 index 0000000..f6fb7b5 --- /dev/null +++ b/tests/pracownia3/033_multiarray.xi @@ -0,0 +1,13 @@ +main():int { + xs:int[2][3]; + xs[0][0] = 1; + xs[0][1] = 2; + xs[0][2] = 3; + xs[1][0] = 10; + xs[1][1] = 20; + xs[1][2] = 30; + return xs[0][0] + xs[0][1] + xs[0][2] + xs[1][0] + xs[1][1] + xs[1][2]; +} + +//@PRACOWNIA +//@out Exit code: 66 diff --git a/tests/pracownia3/034_or_literals.xi b/tests/pracownia3/034_or_literals.xi new file mode 100644 index 0000000..ca1c9da --- /dev/null +++ b/tests/pracownia3/034_or_literals.xi @@ -0,0 +1,15 @@ +convert(b:bool):int +{ + if b { + return 1 + } else { + return 0 + } +} +main():int +{ + return convert(false | true) +} + +//@PRACOWNIA +//@out Exit code: 1 diff --git a/tests/pracownia3/035_return_char.xi b/tests/pracownia3/035_return_char.xi new file mode 100644 index 0000000..689567a --- /dev/null +++ b/tests/pracownia3/035_return_char.xi @@ -0,0 +1,7 @@ +main():int +{ + return 'a' +} + +//@PRACOWNIA +//@out Exit code: 97 diff --git a/tests/pracownia3/036_multireturn_3.xi b/tests/pracownia3/036_multireturn_3.xi new file mode 100644 index 0000000..f8190a8 --- /dev/null +++ b/tests/pracownia3/036_multireturn_3.xi @@ -0,0 +1,12 @@ +f(): int, int, int +{ + return 10, 15, 20 +} + +main():int { + x:int, y:int, z:int = f() + return x + y + z; +} + +//@PRACOWNIA +//@out Exit code: 45 diff --git a/tests/pracownia3/037_concat_lhs_len.xi b/tests/pracownia3/037_concat_lhs_len.xi new file mode 100644 index 0000000..f51c1e0 --- /dev/null +++ b/tests/pracownia3/037_concat_lhs_len.xi @@ -0,0 +1,8 @@ +main():int +{ + z:int[] = {100, 200} + {} + return length(z) +} + +//@PRACOWNIA +//@out Exit code: 2
\ No newline at end of file diff --git a/tests/pracownia3/038_fac_rec_5.xi b/tests/pracownia3/038_fac_rec_5.xi new file mode 100644 index 0000000..1258e53 --- /dev/null +++ b/tests/pracownia3/038_fac_rec_5.xi @@ -0,0 +1,15 @@ +fac(x:int):int +{ + if (x == 0) { + return 1 + } + return fac(x-1)*x +} + +main():int +{ + return fac(5) +} + +//@PRACOWNIA +//@out Exit code: 120
\ No newline at end of file diff --git a/tests/pracownia3/039_ifelse_eq_true_ret.xi b/tests/pracownia3/039_ifelse_eq_true_ret.xi new file mode 100644 index 0000000..70a6491 --- /dev/null +++ b/tests/pracownia3/039_ifelse_eq_true_ret.xi @@ -0,0 +1,13 @@ +main():int +{ + x:int = 33; + if (x == 33) { + return 100 + } else { + return 10 + } + return 0 +} + +//@PRACOWNIA +//@out Exit code: 100
\ No newline at end of file diff --git a/tests/pracownia3/040_string.xi b/tests/pracownia3/040_string.xi new file mode 100644 index 0000000..f046b6b --- /dev/null +++ b/tests/pracownia3/040_string.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = "Wroclaw" + return 13 +} + +//@PRACOWNIA +//@out Exit code: 13
\ No newline at end of file diff --git a/tests/pracownia3/041_assign_index0.xi b/tests/pracownia3/041_assign_index0.xi new file mode 100644 index 0000000..f1c39b6 --- /dev/null +++ b/tests/pracownia3/041_assign_index0.xi @@ -0,0 +1,9 @@ +main():int +{ + x:int[] = {5, 10, 15} + x[0] = 20 + return x[0] +} + +//@PRACOWNIA +//@out Exit code: 20
\ No newline at end of file diff --git a/tests/pracownia3/042_return_nl.xi b/tests/pracownia3/042_return_nl.xi new file mode 100644 index 0000000..b529e15 --- /dev/null +++ b/tests/pracownia3/042_return_nl.xi @@ -0,0 +1,7 @@ +main():int +{ + return '\n' +} + +//@PRACOWNIA +//@out Exit code: 10 diff --git a/tests/pracownia3/043_while_or.xi b/tests/pracownia3/043_while_or.xi new file mode 100644 index 0000000..5d9525e --- /dev/null +++ b/tests/pracownia3/043_while_or.xi @@ -0,0 +1,18 @@ +pred():bool +{ + return false +} + +main():int +{ + x:bool = true + result:int = 13 + while x | pred() { + result = 100 + x = false + } + return result +} + +//@PRACOWNIA +//@out Exit code: 100 diff --git a/tests/pracownia3/044_list_init.xi b/tests/pracownia3/044_list_init.xi new file mode 100644 index 0000000..a7a2c9d --- /dev/null +++ b/tests/pracownia3/044_list_init.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = {1,2,3} + return 0 +} + +//@PRACOWNIA +//@out Exit code: 0
\ No newline at end of file diff --git a/tests/pracownia3/045_mod_literals.xi b/tests/pracownia3/045_mod_literals.xi new file mode 100644 index 0000000..e904355 --- /dev/null +++ b/tests/pracownia3/045_mod_literals.xi @@ -0,0 +1,8 @@ + +main():int +{ + return 3 % 2 +} + +//@PRACOWNIA +//@out Exit code: 1 diff --git a/tests/pracownia3/046_return_index1.xi b/tests/pracownia3/046_return_index1.xi new file mode 100644 index 0000000..b2af5d1 --- /dev/null +++ b/tests/pracownia3/046_return_index1.xi @@ -0,0 +1,8 @@ +main():int +{ + x:int[] = {5, 10, 15} + return x[1] +} + +//@PRACOWNIA +//@out Exit code: 10
\ No newline at end of file diff --git a/tests/pracownia3/047_and_10_.xi b/tests/pracownia3/047_and_10_.xi new file mode 100644 index 0000000..d9469ae --- /dev/null +++ b/tests/pracownia3/047_and_10_.xi @@ -0,0 +1,30 @@ +printString(str:int[]) + +pred_lhs():bool +{ + printString("pred_lhs") + return true +} + +pred_rhs():bool +{ + printString("pred_rhs") + return false +} + +main():int +{ + result:int = 3 + if pred_lhs() & pred_rhs() { + result = 1 + } else { + result = 0 + } + + return result +} + +//@PRACOWNIA +//@out pred_lhs +//@out pred_rhs +//@out Exit code: 0 |