summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-10-30 15:32:56 +0100
committerPaweł Dybiec <pdybiec@stud.cs.uni.wroc.pl>2018-10-30 15:32:56 +0100
commitb798ac29c37299b2f761243ae92ab8f7c4c4d7f1 (patch)
treeeb9b9cc9be294fe5bd3acf9a342098ffc0ea06e5 /tests
Initial commit
Diffstat (limited to 'tests')
-rw-r--r--tests/pracownia1/parse_error.xi75
-rw-r--r--tests/pracownia1/parse_ok.xi163
-rw-r--r--tests/pracownia1/parse_operators.xi14
3 files changed, 252 insertions, 0 deletions
diff --git a/tests/pracownia1/parse_error.xi b/tests/pracownia1/parse_error.xi
new file mode 100644
index 0000000..7bc8eee
--- /dev/null
+++ b/tests/pracownia1/parse_error.xi
@@ -0,0 +1,75 @@
+x:int
+
+main(x:int y:int)
+{
+}
+
+main() int int {
+
+}
+
+main()
+{
+    (x:int, y:int) = pair()
+}
+
+pair(): int, int
+{
+    return (0,0)
+}
+
+f()
+{
+    return 1;
+    x = 1
+}
+
+f()
+{
+    x = ''
+}
+
+f()
+{
+    x = 'ab'
+}
+
+f()
+{
+    x = '
+'
+}
+
+f()
+{
+    x = '\a'
+}
+
+f()
+{
+    x = "a
+b"
+}
+
+f()
+{
+    x = "a\tb"
+}
+
+f()
+{
+    while cond return 1
+}
+
+f()
+{
+    if cond return 1
+}
+
+f()
+{
+    if cond return 1 else z = 1
+}
+
+//@PRACOWNIA
+//@should_not_parse
diff --git a/tests/pracownia1/parse_ok.xi b/tests/pracownia1/parse_ok.xi
new file mode 100644
index 0000000..e4d0761
--- /dev/null
+++ b/tests/pracownia1/parse_ok.xi
@@ -0,0 +1,163 @@
+
+f()
+
+f(x:int)
+
+f():int
+{
+    return 0
+}
+
+f(x:int, y:int)
+
+f(): bool
+
+f(): int, int
+
+f()
+{
+    x:int
+}
+
+f() { x:int y:int }
+
+f() {
+    x:int = 1
+}
+
+f()
+{
+    return "Wroclaw"
+}
+
+f()
+{
+    return 5, 10, 15, "zaraz sie zacznie"
+}
+
+f()
+{
+    x:int x = 10 y = 17
+}
+
+f()
+{
+    x = 1 + 2 + 3
+    x = 1 - 2 - 3
+    x = 1 * 2 * 3
+    x = 1 / 2 / 3
+    x = 1 % 2 % 3
+    x = 1 & 2 & 3
+    x = 1 | 2 | 3
+}
+
+
+f()
+{
+    if (x > 10) y = 1
+    if x > 10 y = 1
+    if x > 10 {
+        return "42"
+    }
+    if pred() y = 1
+    if pred() & y | z x = 1
+}
+
+f()
+{
+    if (x > 10) y = 1 else z = 1
+    if x > 10 y = 1 else z = 1
+    if x > 10 { 
+        return "42"
+    } else z = 1
+
+    if pred() y = 1 else {
+        z = 1
+    }
+    if pred() & y | z x = 1 else {
+        z = 3
+    }
+}
+
+f()
+{
+    if x if y z = 1 else z = 2
+}
+
+f()
+{
+    while (x > 10) y = 1
+    while x > 10 y = 1
+    while x y = 1
+    while pred() y = 1
+    while pred() {
+        zmienna = wartosc
+        return
+    }
+}
+
+f()
+{
+    g()
+    g(1, 2)
+    g(1, 2, 3)
+}
+
+f()
+{
+    x:int, y:int = f()
+    x:int, y:int = f(1, 2)
+    _, y:int = f(1, 2)
+    _, _ = f(1, 2)
+    x:int, _ = f(1, 2)
+}
+
+f()
+{
+    z = length("x")
+    z = length(x + y)
+    z = length(x - y)
+    z = length(x & y)
+    z = length(x / y)
+    z = length({1,2,3} + 1)
+}
+
+g()
+{
+    z = 'a'
+    z = 'b'
+    z = '\n'
+    z = '\\'
+    z = '\''
+}
+
+g()
+{
+    z = "a"
+    z = "abece de"
+    z = "abece\nde"
+    z = "abece\\de"
+    z = "abece\"de"
+}
+
+g(x:int[][]):bool[][]
+
+g(x:int[1][]):bool[][x]
+
+g()
+{
+    x:int[][][]
+    x:int[][][1]
+    x:int[2][][1]
+    x:int[][n][]
+}
+
+g()
+{
+    x[0] = 1
+    x[0][1] = 2
+    x[a][b] = c[d]
+}
+
+//@PRACOWNIA
+//@stop_after parser
diff --git a/tests/pracownia1/parse_operators.xi b/tests/pracownia1/parse_operators.xi
new file mode 100644
index 0000000..59bbe0c
--- /dev/null
+++ b/tests/pracownia1/parse_operators.xi
@@ -0,0 +1,14 @@
+test()
+{
+    x = a | b & c;
+    x = a & b | c & d;
+    x = a | b | c;
+    x = a < b < c;
+    x = a < b == c < d;
+    x = a < b * c == c + d < e * f
+    x = a * b / d % e
+
+}
+
+//@PRACOWNIA
+//@stop_after parser