From 20e6f342084b9702e6ad7f48aed3452526ed8e27 Mon Sep 17 00:00:00 2001 From: Ashleyhx Date: Fri, 15 Dec 2023 20:01:42 -0500 Subject: [PATCH] openCypher expression regression test --- .../expressions/aggregation/Aggregation1.test | 32 ++ .../expressions/aggregation/Aggregation2.test | 155 ++++++ .../expressions/aggregation/Aggregation3.test | 32 ++ .../expressions/aggregation/Aggregation5.test | 36 ++ .../expressions/aggregation/Aggregation6.test | 23 + .../expressions/aggregation/Aggregation8.test | 53 ++ .../tck/expressions/boolean/Boolean1.test | 260 +++++++++ .../tck/expressions/boolean/Boolean2.test | 258 +++++++++ .../tck/expressions/boolean/Boolean3.test | 257 +++++++++ .../tck/expressions/boolean/Boolean4.test | 66 +++ .../tck/expressions/boolean/Boolean5.test | 204 ++++++++ .../expressions/comparison/Comparison1.test | 351 +++++++++++++ .../expressions/comparison/Comparison2.test | 183 +++++++ .../expressions/comparison/Comparison3.test | 146 ++++++ .../expressions/comparison/Comparison4.test | 30 ++ .../expressions/conditional/Conditional2.test | 161 ++++++ .../tck/expressions/list/List1.test | 135 +++++ .../tck/expressions/list/List11.test | 493 ++++++++++++++++++ .../tck/expressions/list/List2.test | 191 +++++++ .../tck/expressions/list/List3.test | 86 +++ .../tck/expressions/list/List4.test | 28 + .../tck/expressions/list/List5.test | 126 +++++ .../tck/expressions/list/List6.test | 55 ++ test/test_files/tck/expressions/map/Map1.test | 150 ++++++ test/test_files/tck/expressions/map/Map2.test | 165 ++++++ test/test_files/tck/expressions/map/Map3.test | 100 ++++ .../mathematical/Mathematical11.test | 15 + .../mathematical/Mathematical13.test | 16 + .../mathematical/Mathematical2.test | 19 + .../mathematical/Mathematical3.test | 14 + .../mathematical/Mathematical8.test | 27 + .../expressions/precedence/Precedence1.test | 273 ++++++++++ .../expressions/precedence/Precedence2.test | 171 ++++++ .../expressions/precedence/Precedence3.test | 70 +++ .../expressions/precedence/Precedence4.test | 123 +++++ .../tck/expressions/string/String1.test | 16 + .../tck/expressions/string/String3.test | 16 + .../tck/expressions/string/String4.test | 17 + .../typeConversion/TypeConversion1.test | 70 +++ .../typeConversion/TypeConversion2.test | 111 ++++ 40 files changed, 4734 insertions(+) create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation1.test create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation2.test create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation3.test create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation5.test create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation6.test create mode 100644 test/test_files/tck/expressions/aggregation/Aggregation8.test create mode 100644 test/test_files/tck/expressions/boolean/Boolean1.test create mode 100644 test/test_files/tck/expressions/boolean/Boolean2.test create mode 100644 test/test_files/tck/expressions/boolean/Boolean3.test create mode 100644 test/test_files/tck/expressions/boolean/Boolean4.test create mode 100644 test/test_files/tck/expressions/boolean/Boolean5.test create mode 100644 test/test_files/tck/expressions/comparison/Comparison1.test create mode 100644 test/test_files/tck/expressions/comparison/Comparison2.test create mode 100644 test/test_files/tck/expressions/comparison/Comparison3.test create mode 100644 test/test_files/tck/expressions/comparison/Comparison4.test create mode 100644 test/test_files/tck/expressions/conditional/Conditional2.test create mode 100644 test/test_files/tck/expressions/list/List1.test create mode 100644 test/test_files/tck/expressions/list/List11.test create mode 100644 test/test_files/tck/expressions/list/List2.test create mode 100644 test/test_files/tck/expressions/list/List3.test create mode 100644 test/test_files/tck/expressions/list/List4.test create mode 100644 test/test_files/tck/expressions/list/List5.test create mode 100644 test/test_files/tck/expressions/list/List6.test create mode 100644 test/test_files/tck/expressions/map/Map1.test create mode 100644 test/test_files/tck/expressions/map/Map2.test create mode 100644 test/test_files/tck/expressions/map/Map3.test create mode 100644 test/test_files/tck/expressions/mathematical/Mathematical11.test create mode 100644 test/test_files/tck/expressions/mathematical/Mathematical13.test create mode 100644 test/test_files/tck/expressions/mathematical/Mathematical2.test create mode 100644 test/test_files/tck/expressions/mathematical/Mathematical3.test create mode 100644 test/test_files/tck/expressions/mathematical/Mathematical8.test create mode 100644 test/test_files/tck/expressions/precedence/Precedence1.test create mode 100644 test/test_files/tck/expressions/precedence/Precedence2.test create mode 100644 test/test_files/tck/expressions/precedence/Precedence3.test create mode 100644 test/test_files/tck/expressions/precedence/Precedence4.test create mode 100644 test/test_files/tck/expressions/string/String1.test create mode 100644 test/test_files/tck/expressions/string/String3.test create mode 100644 test/test_files/tck/expressions/string/String4.test create mode 100644 test/test_files/tck/expressions/typeConversion/TypeConversion1.test create mode 100644 test/test_files/tck/expressions/typeConversion/TypeConversion2.test diff --git a/test/test_files/tck/expressions/aggregation/Aggregation1.test b/test/test_files/tck/expressions/aggregation/Aggregation1.test new file mode 100644 index 0000000000..5539454177 --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation1.test @@ -0,0 +1,32 @@ +-GROUP TCKAggregation1 +-DATASET CSV tck + +-- + +# Count only non-null values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:A {name: 'a', num: 33}), (:A {name: 'b', num: 42}), ({name: 'a'}); +---- ok +-STATEMENT MATCH (n) RETURN n.name, count(n.num); +## Outcome: the result should be, in any order: +---- 2 +a|1 +b|1 + +# Counting loop relationships +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE REL TABLE R(FROM A TO A); +---- ok +-STATEMENT CREATE (a:A), (a:A)-[:R]->(a:A); +---- ok +-STATEMENT MATCH ()-[r]->() + RETURN count(r); +## Outcome: the result should be, in any order: +---- 1 +1 diff --git a/test/test_files/tck/expressions/aggregation/Aggregation2.test b/test/test_files/tck/expressions/aggregation/Aggregation2.test new file mode 100644 index 0000000000..3cdde827fd --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation2.test @@ -0,0 +1,155 @@ +-GROUP TCKAggregation2 +-DATASET CSV tck + +-- + + +# `max()` over integers +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,2,0,null,-1] AS x + RETURN max(x); +## Outcome: the result should be, in any order: +---- 1 +2 + +# `min()` over integers +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,2,0,null,-1] AS x + RETURN min(x); +## Outcome: the result should be, in any order: +---- 1 +-1 + +# `max()` over floats +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1.0,2.0,0.5,null] AS x + RETURN max(x); +## Outcome: the result should be, in any order: +---- 1 +2.000000 + +# `min()` over floats +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1.0,2.0,0.5,null] AS x + RETURN min(x); +## Outcome: the result should be, in any order: +---- 1 +0.500000 + +# `max()` over mixed numeric values +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,2.0,5,null,3.2,0.1] AS x + RETURN max(x); +## Outcome: the result should be, in any order: +---- 1 +5 + +# `min()` over mixed numeric values +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,2.0,5,null,3.2,0.1] AS x + RETURN min(x); +## Outcome: the result should be, in any order: +---- 1 +0.1 + +# `max()` over strings +-CASE Scenario7 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND ['a','b','B',null,'abc','abc1'] AS i + RETURN max(i); +## Outcome: the result should be, in any order: +---- 1 +b + +# `min()` over strings +-CASE Scenario8 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND ['a','b','B',null,'abc','abc1'] AS i + RETURN min(i); +## Outcome: the result should be, in any order: +---- 1 +B + +# `max()` over list values +-CASE Scenario9 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [[1],[2],[2, 1]] AS x + RETURN max(x); +## Outcome: the result should be, in any order: +---- 1 +[2,1] + +# `min()` over list values +-CASE Scenario10 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [[1],[2],[2, 1]] AS x + RETURN min(x); +## Outcome: the result should be, in any order: +---- 1 +[1] + +# `max()` over mixed values +-CASE Scenario11 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,'a',null,[1, 2],0.2,'b'] AS x + RETURN max(x); +## Outcome: the result should be, in any order: +---- 1 +1 + +# `min()` over mixed values +-CASE Scenario12 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [1,'a',null,[1, 2],0.2,'b'] AS x + RETURN min(x); +## Outcome: the result should be, in any order: +---- 1 +[1,2] diff --git a/test/test_files/tck/expressions/aggregation/Aggregation3.test b/test/test_files/tck/expressions/aggregation/Aggregation3.test new file mode 100644 index 0000000000..e99a4ede3b --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation3.test @@ -0,0 +1,32 @@ +-GROUP TCKAggregation3 +-DATASET CSV tck + +-- + + +# Sum only non-null values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:A {name: 'a', num: 33}), (:A {name: 'a'}), (:A {name: 'a', num: 42}); +---- ok +-STATEMENT MATCH (n) + RETURN n.name, sum(n.num); +## Outcome: the result should be, in any order: +---- 1 +a|75 + +# No overflow during summation +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND range(1000000, 2000000) AS i + WITH i + LIMIT 3000 + RETURN sum(i); +## Outcome: the result should be, in any order: +---- 1 +3004498500 \ No newline at end of file diff --git a/test/test_files/tck/expressions/aggregation/Aggregation5.test b/test/test_files/tck/expressions/aggregation/Aggregation5.test new file mode 100644 index 0000000000..3135493ff0 --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation5.test @@ -0,0 +1,36 @@ +-GROUP TCKAggregation5 +-DATASET CSV tck + +-- + + +# `collect()` filtering nulls +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok + +-STATEMENT CREATE (); +---- ok +-STATEMENT MATCH (n) + OPTIONAL MATCH (n)-[:NOT_EXIST]->(x) + RETURN n, collect(x); +## Outcome: the result should be, in any order: +---- 1 +|[] + +# OPTIONAL MATCH and `collect()` on node property +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE DoesExist(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:DoesExist {num: 42}), (:DoesExist {num: 43}), (:DoesExist {num: 44}); +---- ok +-STATEMENT OPTIONAL MATCH (f:DoesExist) + OPTIONAL MATCH (n:DoesNotExist) + RETURN collect(DISTINCT n.num) AS a, collect(DISTINCT f.num) AS b; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[]|[42,43,44] \ No newline at end of file diff --git a/test/test_files/tck/expressions/aggregation/Aggregation6.test b/test/test_files/tck/expressions/aggregation/Aggregation6.test new file mode 100644 index 0000000000..6e27ea2671 --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation6.test @@ -0,0 +1,23 @@ +-GROUP TCKAggregation6 +-DATASET CSV tck + +-- + + +# `percentileDisc()` +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ({price: 10.0}), + ({price: 20.0}), + ({price: 30.0}); +## Context: parameters are: +#parameters are: +#percentile | 0.0 +-STATEMENT MATCH (n) + RETURN percentileDisc(n.price, $percentile) AS p; +## Outcome: the result should be, in any order: +---- 1 +10.0 \ No newline at end of file diff --git a/test/test_files/tck/expressions/aggregation/Aggregation8.test b/test/test_files/tck/expressions/aggregation/Aggregation8.test new file mode 100644 index 0000000000..00dd910546 --- /dev/null +++ b/test/test_files/tck/expressions/aggregation/Aggregation8.test @@ -0,0 +1,53 @@ +-GROUP TCKAggregation8 +-DATASET CSV tck + +-- + + +# Distinct on unbound node +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT OPTIONAL MATCH (a) + RETURN count(DISTINCT a); +## Outcome: the result should be, in any order: +---- 1 +0 + +# Distinct on null +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (); +-STATEMENT MATCH (a) + RETURN count(DISTINCT a.name); +## Outcome: the result should be, in any order: +---- 1 +0 + +# Collect distinct nulls +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [null, null] AS x + RETURN collect(DISTINCT x) AS c; +## Outcome: the result should be, in any order: +---- 1 + + +# Collect distinct values mixed with nulls +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [null, 1, null] AS x + RETURN collect(DISTINCT x) AS c; +## Outcome: the result should be, in any order: +---- 1 +[1] \ No newline at end of file diff --git a/test/test_files/tck/expressions/boolean/Boolean1.test b/test/test_files/tck/expressions/boolean/Boolean1.test new file mode 100644 index 0000000000..5f3ba759d0 --- /dev/null +++ b/test/test_files/tck/expressions/boolean/Boolean1.test @@ -0,0 +1,260 @@ +-GROUP TCKBoolean1 +-DATASET CSV tck + +-- + + + +# [1] Conjunction of two truth values +-CASE Scenario1 + + +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN true AND true AS tt, + true AND false AS tf, + true AND null AS tn, + false AND true AS ft, + false AND false AS ff, + false AND null AS fn, + null AND true AS nt, + null AND false AS nf, + null AND null AS nn; +---- 1 +True|False||False|False|False||False| + + +# [2] Conjunction of three truth values +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true AND true AND true AS ttt, + true AND true AND false AS ttf, + true AND true AND null AS ttn, + true AND false AND true AS tft, + true AND false AND false AS tff, + true AND false AND null AS tfn, + true AND null AND true AS tnt, + true AND null AND false AS tnf, + true AND null AND null AS tnn, + false AND true AND true AS ftt, + false AND true AND false AS ftf, + false AND true AND null AS ftn, + false AND false AND true AS fft, + false AND false AND false AS fff, + false AND false AND null AS ffn, + false AND null AND true AS fnt, + false AND null AND false AS fnf, + false AND null AND null AS fnn, + null AND true AND true AS ntt, + null AND true AND false AS ntf, + null AND true AND null AS ntn, + null AND false AND true AS nft, + null AND false AND false AS nff, + null AND false AND null AS nfn, + null AND null AND true AS nnt, + null AND null AND false AS nnf, + null AND null AND null AS nnn; +## Outcome: the result should be, in any order: +---- 1 +True|False||False|False|False||False||False|False|False|False|False|False|False|False|False||False||False|False|False||False| + + +# [3] Conjunction of many truth values +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true AND true AND true AND true AND true AND true AND true AND true AND true AND true AND true AS t, + true AND true AND true AND false AND true AND true AND true AND true AND true AND true AND true AS tsf, + true AND true AND true AND null AND true AND true AND true AND true AND true AND true AND true AS tsn, + false AND false AND false AND false AND false AND false AND false AND false AND false AND false AND false AS f, + false AND false AND false AND false AND true AND false AND false AND false AND false AND false AND false AS fst, + false AND false AND false AND false AND false AND false AND null AND false AND false AND false AND false AS fsn, + null AND null AND null AND null AND null AND null AND null AND null AND null AND null AND null AS n, + null AND null AND null AND null AND true AND null AND null AND null AND null AND null AND null AS nst, + null AND null AND null AND null AND false AND null AND null AND null AND null AND null AND null AS nsf, + true AND false AND false AND false AND true AND false AND false AND true AND true AND true AND false AS m1, + true AND true AND false AND false AND true AND false AND false AND true AND true AND true AND false AS m2, + true AND true AND false AND false AND true AND null AND false AND true AND true AND null AND false AS m3; +## Outcome: the result should be, in any order: +---- 1 +True|False||False|False|False|||False|False|False|False + +# [4] Conjunction is commutative on non-null +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + RETURN a, b, (a AND b) = (b AND a) AS result; +## Outcome: the result should be, in any order: +---- 4 +False|False|True +False|True|True +True|False|True +True|True|True + +# [5] Conjunction is commutative on null +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + WITH a, b WHERE a IS NULL OR b IS NULL + RETURN a, b, (a AND b) IS NULL = (b AND a) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 5 +true | null | true +false | null | true +null | true | true +null | false | true +null | null | true + + +# Conjunction is associative on non-null +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a AND (b AND c)) = ((a AND b) AND c) AS result; +## Outcome: the result should be, in any order: +---- 8 +False|False|False|True +False|False|True|True +False|True|False|True +False|True|True|True +True|False|False|True +True|False|True|True +True|True|False|True +True|True|True|True + +# Conjunction is associative on null +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a AND (b AND c)) IS NULL = ((a AND b) AND c) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +true | true | null | true +true | false | null | true +true | null | true | true +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | true +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# Fail on conjunction of at least one non-booleans +-CASE Scenario8 +-STATEMENT RETURN 123 AND true; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 AND true; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 AND null; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' AND true; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [] AND false; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] AND false; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [null] AND null; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} AND true; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false AND 123; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true AND 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false AND 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null AND 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true AND []; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true AND [false]; +---- error +Binder exception: Expression LIST_CREATION(False) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null AND [null]; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false AND {x: []}; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123 AND 'foo'; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123.4 AND 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' AND {x: []}; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] AND [true]; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} AND [123]; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. diff --git a/test/test_files/tck/expressions/boolean/Boolean2.test b/test/test_files/tck/expressions/boolean/Boolean2.test new file mode 100644 index 0000000000..dc7249d071 --- /dev/null +++ b/test/test_files/tck/expressions/boolean/Boolean2.test @@ -0,0 +1,258 @@ +-GROUP TCKBoolean2 +-DATASET CSV tck + +-- + + +# Disjunction of two truth values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true OR true AS tt, + true OR false AS tf, + true OR null AS tn, + false OR true AS ft, + false OR false AS ff, + false OR null AS fn, + null OR true AS nt, + null OR false AS nf, + null OR null AS nn; +## Outcome: the result should be, in any order: +---- 1 +True|True|True|True|False||True|| + +# Disjunction of three truth values +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true OR true OR true AS ttt, + true OR true OR false AS ttf, + true OR true OR null AS ttn, + true OR false OR true AS tft, + true OR false OR false AS tff, + true OR false OR null AS tfn, + true OR null OR true AS tnt, + true OR null OR false AS tnf, + true OR null OR null AS tnn, + false OR true OR true AS ftt, + false OR true OR false AS ftf, + false OR true OR null AS ftn, + false OR false OR true AS fft, + false OR false OR false AS fff, + false OR false OR null AS ffn, + false OR null OR true AS fnt, + false OR null OR false AS fnf, + false OR null OR null AS fnn, + null OR true OR true AS ntt, + null OR true OR false AS ntf, + null OR true OR null AS ntn, + null OR false OR true AS nft, + null OR false OR false AS nff, + null OR false OR null AS nfn, + null OR null OR true AS nnt, + null OR null OR false AS nnf, + null OR null OR null AS nnn; +## Outcome: the result should be, in any order: +---- 1 +True|True|True|True|True|True|True|True|True|True|True|True|True|False||True|||True|True|True|True|||True|| + +# Disjunction of many truth values +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true OR true OR true OR true OR true OR true OR true OR true OR true OR true OR true AS t, + true OR true OR true OR false OR true OR true OR true OR true OR true OR true OR true AS tsf, + true OR true OR true OR null OR true OR true OR true OR true OR true OR true OR true AS tsn, + false OR false OR false OR false OR false OR false OR false OR false OR false OR false OR false AS f, + false OR false OR false OR false OR true OR false OR false OR false OR false OR false OR false AS fst, + false OR false OR false OR false OR false OR false OR null OR false OR false OR false OR false AS fsn, + null OR null OR null OR null OR null OR null OR null OR null OR null OR null OR null AS n, + null OR null OR null OR null OR true OR null OR null OR null OR null OR null OR null AS nst, + null OR null OR null OR null OR false OR null OR null OR null OR null OR null OR null AS nsf, + true OR false OR false OR false OR true OR false OR false OR true OR true OR true OR false AS m1, + true OR true OR false OR false OR true OR false OR false OR true OR true OR true OR false AS m2, + true OR true OR false OR false OR true OR null OR false OR true OR true OR null OR false AS m3; +## Outcome: the result should be, in any order: +---- 1 +True|True|True|False|True|||True||True|True|True + +# Disjunction is commutative on non-null +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + RETURN a, b, (a OR b) = (b OR a) AS result; +## Outcome: the result should be, in any order: +---- 4 +False|False|True +False|True|True +True|False|True +True|True|True + + +# Disjunction is commutative on null +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + WITH a, b WHERE a IS NULL OR b IS NULL + RETURN a, b, (a OR b) IS NULL = (b OR a) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 5 +true | null | true +false | null | true +null | true | true +null | false | true +null | null | true + +# Disjunction is associative on non-null +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a OR (b OR c)) = ((a OR b) OR c) AS result; +## Outcome: the result should be, in any order: +---- 8 +False|False|False|True +False|False|True|True +False|True|False|True +False|True|True|True +True|False|False|True +True|False|True|True +True|True|False|True +True|True|True|True + +# Disjunction is associative on null +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a OR (b OR c)) IS NULL = ((a OR b) OR c) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +true | true | null | true +true | false | null | true +true | null | true | true +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | true +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# Fail on disjunction of at least one non-booleans +-CASE Scenario8 +-STATEMENT RETURN 123 OR true; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 OR true; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 OR null; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' OR true; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [] OR false; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] OR false; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [null] OR null; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} OR true; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false OR 123; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true OR 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false OR 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null OR 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true OR []; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true OR [false]; +---- error +Binder exception: Expression LIST_CREATION(False) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null OR [null]; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false OR {x: []}; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123 OR 'foo'; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123.4 OR 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' OR {x: []}; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] OR [true]; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} OR [123]; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. diff --git a/test/test_files/tck/expressions/boolean/Boolean3.test b/test/test_files/tck/expressions/boolean/Boolean3.test new file mode 100644 index 0000000000..7acbcc4835 --- /dev/null +++ b/test/test_files/tck/expressions/boolean/Boolean3.test @@ -0,0 +1,257 @@ +-GROUP TCKBoolean3 +-DATASET CSV tck + +-- + + +# Exclusive disjunction of two truth values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true XOR true AS tt, + true XOR false AS tf, + true XOR null AS tn, + false XOR true AS ft, + false XOR false AS ff, + false XOR null AS fn, + null XOR true AS nt, + null XOR false AS nf, + null XOR null AS nn; +## Outcome: the result should be, in any order: +---- 1 +False|True||True|False|||| + +# Exclusive disjunction of three truth values +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true XOR true XOR true AS ttt, + true XOR true XOR false AS ttf, + true XOR true XOR null AS ttn, + true XOR false XOR true AS tft, + true XOR false XOR false AS tff, + true XOR false XOR null AS tfn, + true XOR null XOR true AS tnt, + true XOR null XOR false AS tnf, + true XOR null XOR null AS tnn, + false XOR true XOR true AS ftt, + false XOR true XOR false AS ftf, + false XOR true XOR null AS ftn, + false XOR false XOR true AS fft, + false XOR false XOR false AS fff, + false XOR false XOR null AS ffn, + false XOR null XOR true AS fnt, + false XOR null XOR false AS fnf, + false XOR null XOR null AS fnn, + null XOR true XOR true AS ntt, + null XOR true XOR false AS ntf, + null XOR true XOR null AS ntn, + null XOR false XOR true AS nft, + null XOR false XOR false AS nff, + null XOR false XOR null AS nfn, + null XOR null XOR true AS nnt, + null XOR null XOR false AS nnf, + null XOR null XOR null AS nnn; +## Outcome: the result should be, in any order: +---- 1 +True|False||False|True|||||False|True||True|False||||||||||||| + +# Exclusive disjunction of many truth values +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN true XOR true XOR true XOR true XOR true XOR true XOR true XOR true XOR true XOR true XOR true AS t, + true XOR true XOR true XOR false XOR true XOR true XOR true XOR true XOR true XOR true XOR true AS tsf, + true XOR true XOR true XOR null XOR true XOR true XOR true XOR true XOR true XOR true XOR true AS tsn, + false XOR false XOR false XOR false XOR false XOR false XOR false XOR false XOR false XOR false XOR false AS f, + false XOR false XOR false XOR false XOR true XOR false XOR false XOR false XOR false XOR false XOR false AS fst, + false XOR false XOR false XOR false XOR false XOR false XOR null XOR false XOR false XOR false XOR false AS fsn, + null XOR null XOR null XOR null XOR null XOR null XOR null XOR null XOR null XOR null XOR null AS n, + null XOR null XOR null XOR null XOR true XOR null XOR null XOR null XOR null XOR null XOR null AS nst, + null XOR null XOR null XOR null XOR false XOR null XOR null XOR null XOR null XOR null XOR null AS nsf, + true XOR false XOR false XOR false XOR true XOR false XOR false XOR true XOR true XOR true XOR false AS m1, + true XOR true XOR false XOR false XOR true XOR false XOR false XOR true XOR true XOR true XOR false AS m2, + true XOR true XOR false XOR false XOR true XOR null XOR false XOR true XOR true XOR null XOR false AS m3; +## Outcome: the result should be, in any order: +---- 1 +True|False||False|True|||||True|False| + +# Exclusive disjunction is commutative on non-null +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + RETURN a, b, (a XOR b) = (b XOR a) AS result; +## Outcome: the result should be, in any order: +---- 4 +True|True|True +True|False|True +False|True|True +False|False|True + +# Exclusive disjunction is commutative on null +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + WITH a, b WHERE a IS NULL OR b IS NULL + RETURN a, b, (a XOR b) IS NULL = (b XOR a) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 5 +true | null | true +false | null | true +null | true | true +null | false | true +null | null | true + +# Exclusive disjunction is associative on non-null +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a XOR (b XOR c)) = ((a XOR b) XOR c) AS result; +## Outcome: the result should be, in any order: +---- 8 +True|True|True|True +True|True|False|True +True|False|True|True +True|False|False|True +False|True|True|True +False|True|False|True +False|False|True|True +False|False|False|True + +# Exclusive disjunction is associative on null +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a XOR (b XOR c)) IS NULL = ((a XOR b) XOR c) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +true | true | null | true +true | false | null | true +true | null | true | true +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | true +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# Fail on exclusive disjunction of at least one non-booleans +-CASE Scenario8 +-STATEMENT RETURN 123 XOR true; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 XOR true; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN 123.4 XOR null; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' XOR true; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [] XOR false; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] XOR false; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [null] XOR null; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} XOR true; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false XOR 123; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true XOR 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false XOR 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null XOR 'foo'; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true XOR []; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN true XOR [false]; +---- error +Binder exception: Expression LIST_CREATION(False) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN null XOR [null]; +---- error +Binder exception: Expression LIST_CREATION() has data type STRING[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN false XOR {x: []}; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123 XOR 'foo'; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 123.4 XOR 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN 'foo' XOR {x: []}; +---- error +Binder exception: Expression foo has data type STRING but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN [true] XOR [true]; +---- error +Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN {x: []} XOR [123]; +---- error +Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported. diff --git a/test/test_files/tck/expressions/boolean/Boolean4.test b/test/test_files/tck/expressions/boolean/Boolean4.test new file mode 100644 index 0000000000..4b2005ac8e --- /dev/null +++ b/test/test_files/tck/expressions/boolean/Boolean4.test @@ -0,0 +1,66 @@ +-GROUP TCKBoolean4 +-DATASET CSV tck + +-- + + +# Logical negation of truth values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN NOT true AS nt, NOT false AS nf, NOT null AS nn; +## Outcome: the result should be, in any order: +---- 1 +False|True| + +# Double logical negation of truth values +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN NOT NOT true AS nnt, NOT NOT false AS nnf, NOT NOT null AS nnn; +## Outcome: the result should be, in any order: +---- 1 +true | false | null + +# NOT and false +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (A:{name: 'a'}); +-STATEMENT MATCH (n) + WHERE NOT(n.name = 'apa' AND false) + RETURN n; +## Outcome: the result should be, in any order: +---- 1 +{name: 'a'} + +# Fail when using NOT on a non-boolean literal +-CASE Scenario4 +-STATEMENT RETURN NOT 0; +---- error +Binder exception: Expression 0 has data type INT64 but expected BOOL. Implicit cast is not supported. +-STATEMENT RETURN NOT 1; +---- error +Binder exception: Expression 1 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN NOT 123; +---- error +Binder exception: Expression 123 has data type INT64 but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN NOT 123.4; +---- error +Binder exception: Expression 123.400000 has data type DOUBLE but expected BOOL. Implicit cast is not supported. + +-STATEMENT RETURN NOT ''; +## Outcome: a SyntaxError should be raised at compile time: InvalidArgumentType +---- error +Binder exception: Expression has data type STRING but expected BOOL. Implicit cast is not supported. + + diff --git a/test/test_files/tck/expressions/boolean/Boolean5.test b/test/test_files/tck/expressions/boolean/Boolean5.test new file mode 100644 index 0000000000..d61b568f68 --- /dev/null +++ b/test/test_files/tck/expressions/boolean/Boolean5.test @@ -0,0 +1,204 @@ +-GROUP TCKBoolean5 +-DATASET CSV tck + +-- + + +# Disjunction is distributive over conjunction on non-null +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a OR (b AND c)) = ((a OR b) AND (a OR c)) AS result; +## Outcome: the result should be, in any order: +---- 8 +False|False|False|True +False|False|True|True +False|True|False|True +False|True|True|True +True|False|False|True +True|False|True|True +True|True|False|True +True|True|True|True + +# Disjunction is distributive over conjunction on null +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a OR (b AND c)) IS NULL = ((a OR b) AND (a OR c)) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +true | true | null | true +true | false | null | true +true | null | true | true +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | true +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# Conjunction is distributive over disjunction on non-null +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a AND (b OR c)) = ((a AND b) OR (a AND c)) AS result; +## Outcome: the result should be, in any order: +---- 8 +False|False|False|True +False|False|True|True +False|True|False|True +False|True|True|True +True|False|False|True +True|False|True|True +True|True|False|True +True|True|True|True + +# Conjunction is distributive over disjunction on null +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a AND (b OR c)) IS NULL = ((a AND b) OR (a AND c)) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +true | true | null | true +true | false | null | true +true | null | true | true +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | true +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# Conjunction is distributive over exclusive disjunction on non-null +-CASE Scenario5 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + UNWIND [true, false] AS c + RETURN a, b, c, (a AND (b XOR c)) = ((a AND b) XOR (a AND c)) AS result; +## Outcome: the result should be, in any order: +---- 8 +True|True|True|True +True|True|False|True +True|False|True|True +True|False|False|True +False|True|True|True +False|True|False|True +False|False|True|True +False|False|False|True + +# Conjunction is not distributive over exclusive disjunction on null +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false, null] AS a + UNWIND [true, false, null] AS b + UNWIND [true, false, null] AS c + WITH a, b, c WHERE a IS NULL OR b IS NULL OR c IS NULL + RETURN a, b, c, (a AND (b XOR c)) IS NULL = ((a AND b) XOR (a AND c)) IS NULL AS result; +## Outcome: the result should be, in any order: +---- 19 +True|True||True +True|False||True +True||True|True +true | null | false | true +true | null | null | true +false | true | null | true +false | false | null | true +false | null | true | true +false | null | false | true +false | null | null | true +null | true | true | false +null | true | false | true +null | true | null | true +null | false | true | true +null | false | false | true +null | false | null | true +null | null | true | true +null | null | false | true +null | null | null | true + +# De Morgan's law on non-null: the negation of a disjunction is the conjunction of the negations +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + RETURN a, b, NOT (a OR b) = (NOT (a) AND NOT (b)) AS result; +## Outcome: the result should be, in any order: +---- 4 +False|False|False +False|True|True +True|False|True +True|True|True + +# De Morgan's law on non-null: the negation of a conjunction is the disjunction of the negations +-CASE Scenario8 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS a + UNWIND [true, false] AS b + RETURN a, b, NOT (a AND b) = (NOT (a) OR NOT (b)) AS result; +## Outcome: the result should be, in any order: +---- 4 +True|True|True +True|False|True +False|True|True +False|False|True diff --git a/test/test_files/tck/expressions/comparison/Comparison1.test b/test/test_files/tck/expressions/comparison/Comparison1.test new file mode 100644 index 0000000000..f9bcd385bc --- /dev/null +++ b/test/test_files/tck/expressions/comparison/Comparison1.test @@ -0,0 +1,351 @@ +-GROUP TCKComparison1 +-DATASET CSV tck + +-- + + +# Number-typed integer comparison +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ({id: 0}); +-STATEMENT WITH collect([0, 0.0]) AS numbers + UNWIND numbers AS arr + WITH arr[0] AS expected + MATCH (n) WHERE toInteger(n.id) = expected + RETURN n; +## Outcome: the result should be, in any order: +---- 1 +{id: 0} + +# Number-typed float comparison +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ({id: 0}); +-STATEMENT WITH collect([0.5, 0]) AS numbers + UNWIND numbers AS arr + WITH arr[0] AS expected + MATCH (n) WHERE toInteger(n.id) = expected + RETURN n; +## Outcome: the result should be, in any order: +---- 0 + +# Any-typed string comparison +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ({id: 0}); +-STATEMENT WITH collect(['0', 0]) AS things + UNWIND things AS arr + WITH arr[0] AS expected + MATCH (n) WHERE toInteger(n.id) = expected + RETURN n; +## Outcome: the result should be, in any order: +---- 0 + +# Comparing nodes to nodes +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (); +-STATEMENT MATCH (a) + WITH a + MATCH (b) + WHERE a = b + RETURN count(b); +## Outcome: the result should be, in any order: +---- 1 +1 + +# Comparing relationships to relationships +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH ()-[a]->() + WITH a + MATCH ()-[b]->() + WHERE a = b + RETURN count(b); +## Outcome: the result should be, in any order: +---- 1 +1 + + +# Comparing lists to lists +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [1, 2] = [1] AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN [null] = [1] AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN ['a'] = [1] AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +# Comparing maps to maps +-CASE Scenario7 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok + +-STATEMENT RETURN {k: True} = {k: True} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 1} = {k: 1} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 1.0} = {k: 1.0} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 'abc'} = {k: 'abc'} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 'a', l: 2} = {k: 'a', l: 2} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 1} = {k: 1, l: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: null, l: 1} = {l: 1} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: null} = {k: null, l: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: null} = {k: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN {k: 1} = {k: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: 1, l: null} = {k: null, l: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: 1, l: null} = {k: null, l: 1} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: 1, l: null} = {k: 1, l: 1} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +#invalids in case7 +-CASE Scenario7_error +-SKIP +-STATEMENT RETURN {} = {} AS result; +## Outcome: the result should be, in any order: +---- 1 +True + + +-STATEMENT RETURN {} = {k: null} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN {k: null} = {} AS result; +## Outcome: the result should be, in any order: +---- 1 +False + + +# Equality and inequality of NaN +-CASE Scenario8 +## Context: any graph +-STATEMENT RETURN 0.0 / 0.0 = 1 AS isEqual, 0.0 / 0.0 <> 1 AS isNotEqual; +## Outcome: the result should be, in any order: +---- 1 +False|True + +-STATEMENT RETURN 0.0 / 0.0 = 1.0 AS isEqual, 0.0 / 0.0 <> 1.0 AS isNotEqual; +## Outcome: the result should be, in any order: +---- 1 +False|True + +-STATEMENT RETURN 0.0 / 0.0 = 0.0 / 0.0 AS isEqual, 0.0 / 0.0 <> 0.0 / 0.0 AS isNotEqual; +## Outcome: the result should be, in any order: +---- 1 +False|True + +-CASE Scenario8_error +-SKIP +-STATEMENT RETURN 0.0 / 0.0 = 'a' AS isEqual, 0.0 / 0.0 <> 'a' AS isNotEqual; +## Outcome: the result should be, in any order: +---- 1 +False|True + + +# Equality between strings and numbers +-CASE Scenario9 +## Context: any graph +-STATEMENT RETURN 1.0 = 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN 1 = 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +#cannot compare string and number +-CASE Scenario9_error +-SKIP +-STATEMENT RETURN '1.0' = 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN '1' = 1 AS result; +## Outcome: the result should be, in any order: +---- 1 +False + + +# Handling inlined equality of large integer +-CASE Scenario10 +## VERIFY +-STATEMENT CREATE NODE TABLE TheLabel(ID SERIAL, name INT128, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:TheLabel {name: 4611686018427387905}); +---- ok +-STATEMENT MATCH (p:TheLabel {name: 4611686018427387905}) + RETURN p.name; +## Outcome: the result should be, in any order: +---- 1 +4611686018427387905 + +# Handling explicit equality of large integer +-CASE Scenario11 +## VERIFY +-STATEMENT CREATE NODE TABLE TheLabel(ID SERIAL, name INT128, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:TheLabel {name: 4611686018427387905}); +---- ok +-STATEMENT MATCH (p:TheLabel) + WHERE p.name = 4611686018427387905 + RETURN p.name; +## Outcome: the result should be, in any order: +---- 1 +4611686018427387905 + +# Handling inlined equality of large integer, non-equal values +-CASE Scenario12 +## VERIFY +-STATEMENT CREATE NODE TABLE TheLabel(ID SERIAL, name INT128, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:TheLabel {name: 4611686018427387905}); +-STATEMENT MATCH (p:TheLabel {name : 4611686018427387900}) + RETURN p.name; +## Outcome: the result should be, in any order: +---- 0 + +# Handling explicit equality of large integer, non-equal values +-CASE Scenario13 +## VERIFY +-STATEMENT CREATE NODE TABLE TheLabel(ID SERIAL, name INT128, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:TheLabel {name: 4611686018427387905}); +-STATEMENT MATCH (p:TheLabel) + WHERE p.name = 4611686018427387900 + RETURN p.name; +## Outcome: the result should be, in any order: +---- 0 + +# Direction of traversed relationship is not significant for path equality, simple +-CASE Scenario14 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE REL TABLE R(FROM A TO A); +---- ok +-STATEMENT CREATE (n:A)-[:R]->(n); + +-STATEMENT MATCH p1 = (:A)-->() + MATCH p2 = (:A)<--() + RETURN p1 = p2; +## Outcome: the result should be, in any order: +---- 1 +True + +# It is unknown - i.e. null - if a null is equal to a null +-CASE Scenario15 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN null = null AS value; +## Outcome: the result should be, in any order: +---- 1 + + +# It is unknown - i.e. null - if a null is not equal to a null +-CASE Scenario16 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN null <> null AS value; +## Outcome: the result should be, in any order: +---- 1 + + +# Failing when comparing to an undefined variable +-CASE Scenario17 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT MATCH (s) + WHERE s.name = undefinedVariable + AND s.age = 10 + RETURN s; +## Outcome: a SyntaxError should be raised at compile time: UndefinedVariable +---- error +Binder exception: Variable undefinedVariable is not in scope. diff --git a/test/test_files/tck/expressions/comparison/Comparison2.test b/test/test_files/tck/expressions/comparison/Comparison2.test new file mode 100644 index 0000000000..21d0009dba --- /dev/null +++ b/test/test_files/tck/expressions/comparison/Comparison2.test @@ -0,0 +1,183 @@ +-GROUP TCKComparison2 +-DATASET CSV tck + +-- + + +# Comparing strings and integers using > in an AND'd predicate +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE Root(ID SERIAL, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE NODE TABLE Child(ID SERIAL, var STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE REL TABLE T(FROM Root TO Child); +---- ok +-STATEMENT CREATE (root:Root)-[:T]->(:Child {var: '0'}), + (root)-[:T]->(:Child {var: 'xx'}), + (root)-[:T]->(:Child); +---- ok +-STATEMENT MATCH (:Root)-->(i:Child) + WHERE i.var IS NOT NULL AND i.var > 'x' + RETURN i.var; +## Outcome: the result should be, in any order: +---- 1 +xx + +# Comparing strings and integers using > in a OR'd predicate +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE Root(ID SERIAL, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE NODE TABLE Child(ID SERIAL, var STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE REL TABLE T(FROM Root TO Child); +---- ok +-STATEMENT CREATE (root:Root)-[:T]->(:Child {var: '0'}), + (root)-[:T]->(:Child {var: 'xx'}), + (root)-[:T]->(:Child); +-STATEMENT MATCH (:Root)-->(i:Child) + WHERE i.var IS NULL OR i.var > 'x' + RETURN i.var; +## Outcome: the result should be, in any order: +---- 2 +xx + + +# Comparing across types yields null, except numbers +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r]->() + WITH [n, r, p, '', 1, 3.14, True, null, [], {}] AS types + UNWIND range(0, size(types) - 1) AS i + UNWIND range(0, size(types) - 1) AS j + WITH types[i] AS lhs, types[j] AS rhs + WHERE i <> j + WITH lhs, rhs, lhs < rhs AS result + WHERE result + RETURN lhs, rhs; +## Outcome: the result should be, in any order: +---- 1 +1|3.14 + +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r]->() + WITH [n, r, p, '', 1, 3.14, True, null, [], {}] AS types + UNWIND range(0, size(types) - 1) AS i + UNWIND range(0, size(types) - 1) AS j + WITH types[i] AS lhs, types[j] AS rhs + WHERE i <> j + WITH lhs, rhs, lhs <= rhs AS result + WHERE result + RETURN lhs, rhs; +## Outcome: the result should be, in any order: +---- 1 +1|3.14 + +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r]->() + WITH [n, r, p, '', 1, 3.14, True, null, [], {}] AS types + UNWIND range(0, size(types) - 1) AS i + UNWIND range(0, size(types) - 1) AS j + WITH types[i] AS lhs, types[j] AS rhs + WHERE i <> j + WITH lhs, rhs, lhs >= rhs AS result + WHERE result + RETURN lhs, rhs; +## Outcome: the result should be, in any order: +---- 1 +3.14|1 + +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r]->() + WITH [n, r, p, '', 1, 3.14, True, null, [], {}] AS types + UNWIND range(0, size(types) - 1) AS i + UNWIND range(0, size(types) - 1) AS j + WITH types[i] AS lhs, types[j] AS rhs + WHERE i <> j + WITH lhs, rhs, lhs > rhs AS result + WHERE result + RETURN lhs, rhs; +## Outcome: the result should be, in any order: +---- 1 +3.14|1 + + +# Comparing lists +-CASE Scenario7 +-STATEMENT RETURN [1, 0] >= [1] AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN [1, null] >= [1] AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +-STATEMENT RETURN [1, 2] >= [1, null] AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN [1, 2] >= [3, null] AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-CASE Scenario7_error +-SKIP +-STATEMENT RETURN [1, 'a'] >= [1, null] AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +# Comparing NaN +-CASE Scenario8 +-STATEMENT RETURN 0.0 / 0.0 > 1 AS gt, 0.0 / 0.0 >= 1 AS gtE, 0.0 / 0.0 < 1 AS lt, 0.0 / 0.0 <= 1 AS ltE; +## Outcome: the result should be, in any order: +---- 1 +False|False|True|True + +-STATEMENT RETURN 0.0 / 0.0 > 1.0 AS gt, 0.0 / 0.0 >= 1.0 AS gtE, 0.0 / 0.0 < 1.0 AS lt, 0.0 / 0.0 <= 1.0 AS ltE; +## Outcome: the result should be, in any order: +---- 1 +False|False|True|True + +-STATEMENT RETURN 0.0 / 0.0 > 0.0 / 0.0 AS gt, 0.0 / 0.0 >= 0.0 / 0.0 AS gtE, 0.0 / 0.0 < 0.0 / 0.0 AS lt, 0.0 / 0.0 <= 0.0 / 0.0 AS ltE; +## Outcome: the result should be, in any order: +---- 1 +False|False|True|True + + +# Comparability between numbers and strings +-CASE Scenario9 +## Context: any graph +-STATEMENT RETURN 1.0 < 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-STATEMENT RETURN 1 < 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +False + +-CASE Scenario9_error +-SKIP +-STATEMENT RETURN '1.0' < 1.0 AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +-STATEMENT RETURN '1' < 1 AS result; +## Outcome: the result should be, in any order: +---- 1 +null + + diff --git a/test/test_files/tck/expressions/comparison/Comparison3.test b/test/test_files/tck/expressions/comparison/Comparison3.test new file mode 100644 index 0000000000..8e130540e6 --- /dev/null +++ b/test/test_files/tck/expressions/comparison/Comparison3.test @@ -0,0 +1,146 @@ +-GROUP TCKComparison3 +-DATASET CSV tck + +-- + + +# Handling numerical ranges 1 +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [1, 2, 3] AS i + CREATE (:A {num: i}); +---- ok +-STATEMENT MATCH (n) + WHERE 1 < n.num AND n.num < 3 + RETURN n.num; +## Outcome: the result should be, in any order: +---- 1 +2 + +# Handling numerical ranges 2 +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [1, 2, 3] AS i + CREATE (:A {num: i}); +---- ok +-STATEMENT MATCH (n) + WHERE 1 < n.num AND n.num <= 3 + RETURN n.num; +## Outcome: the result should be, in any order: +---- 2 +2 +3 + +# Handling numerical ranges 3 +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [1, 2, 3] AS i + CREATE (:A {num: i}); +---- ok +-STATEMENT MATCH (n) + WHERE 1 <= n.num AND n.num < 3 + RETURN n.num; +## Outcome: the result should be, in any order: +---- 2 +1 +2 + +# Handling numerical ranges 4 +-CASE Scenario4 +-STATEMENT CREATE NODE TABLE A(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [1, 2, 3] AS i + CREATE (:A {num: i}); +---- ok +-STATEMENT MATCH (n) + WHERE 1 <= n.num AND n.num <= 3 + RETURN n.num; +## Outcome: the result should be, in any order: +---- 3 +1 +2 +3 + +# Handling string ranges 1 +-CASE Scenario5 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND ['a', 'b', 'c'] AS c + CREATE (:A {name: c}); +---- ok +-STATEMENT MATCH (n) + WHERE 'a' < n.name AND n.name < 'c' + RETURN n.name; +## Outcome: the result should be, in any order: +---- 1 +b + +# Handling string ranges 2 +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND ['a', 'b', 'c'] AS c + CREATE (:A {name: c}); +---- ok +-STATEMENT MATCH (n) + WHERE 'a' < n.name AND n.name <= 'c' + RETURN n.name; +## Outcome: the result should be, in any order: +---- 2 +b +c + +# Handling string ranges 3 +-CASE Scenario7 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND ['a', 'b', 'c'] AS c + CREATE (:A {name: c}); +---- ok +-STATEMENT MATCH (n) + WHERE 'a' <= n.name AND n.name < 'c' + RETURN n.name; +## Outcome: the result should be, in any order: +---- 2 +a +b + +# Handling string ranges 4 +-CASE Scenario8 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND ['a', 'b', 'c'] AS c + CREATE (:A {name: c}); +---- ok +-STATEMENT MATCH (n) + WHERE 'a' <= n.name AND n.name <= 'c' + RETURN n.name; +## Outcome: the result should be, in any order: +---- 3 +a +b +c + +# Handling empty range +-CASE Scenario9 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, num INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:A {num: 3}); +---- ok +-STATEMENT MATCH (n) + WHERE 10 < n.num AND n.num < 10 + RETURN n.num; +## Outcome: the result should be, in any order: +---- 0 + diff --git a/test/test_files/tck/expressions/comparison/Comparison4.test b/test/test_files/tck/expressions/comparison/Comparison4.test new file mode 100644 index 0000000000..456775c664 --- /dev/null +++ b/test/test_files/tck/expressions/comparison/Comparison4.test @@ -0,0 +1,30 @@ +-GROUP TCKComparison4 +-DATASET CSV tck + +-- + + +# Handling long chains of operators +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, prop1 INT64, prop2 INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE NODE TABLE B(ID SERIAL, prop1 INT64, prop2 INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE NODE TABLE C(ID SERIAL, prop1 INT64, prop2 INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE REL TABLE R(FROM A TO B); +---- ok +-STATEMENT CREATE REL TABLE S(FROM B TO C); +---- ok +-STATEMENT CREATE REL TABLE T(FROM C TO A); +---- ok +-STATEMENT CREATE (a:A {prop1: 3, prop2: 4}), (b:B {prop1: 4, prop2: 5}), (c:C {prop1: 4, prop2: 4}), (a)-[:R]->(b), + (b)-[:S]->(c), (c)-[:T]->(a); +---- ok +-STATEMENT MATCH (n)-[]->(m) + WHERE n.prop1 < m.prop1 AND n.prop2 = m.prop1 AND n.prop2 <> m.prop2 + RETURN LABEL(m); +## Outcome: the result should be, in any order: +---- 1 +B \ No newline at end of file diff --git a/test/test_files/tck/expressions/conditional/Conditional2.test b/test/test_files/tck/expressions/conditional/Conditional2.test new file mode 100644 index 0000000000..a0db57e1b4 --- /dev/null +++ b/test/test_files/tck/expressions/conditional/Conditional2.test @@ -0,0 +1,161 @@ +-GROUP TCKConditional2 +-DATASET CSV tck + +-- + + +# Simple cases over integers +-CASE Scenario1 +-STATEMENT RETURN CASE -10 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +## Outcome: the result should be, in any order: +---- 1 +minus ten +-STATEMENT RETURN CASE 0 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +## Outcome: the result should be, in any order: +---- 1 +zero +-STATEMENT RETURN CASE 1 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +## Outcome: the result should be, in any order: +---- 1 +one + +-STATEMENT RETURN CASE 5 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; + +## Outcome: the result should be, in any order: +---- 1 +five + +-STATEMENT RETURN CASE 10 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; + +## Outcome: the result should be, in any order: +---- 1 +ten + +-STATEMENT RETURN CASE 3000 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; + +---- 1 +three thousand + +-STATEMENT RETURN CASE 3001 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + +-STATEMENT RETURN CASE -30 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + +-STATEMENT RETURN CASE 3 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + +-STATEMENT RETURN CASE 10.1 + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + +# Other types +-CASE Scenario1b +-SKIP +-STATEMENT RETURN CASE '0' + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + +-STATEMENT RETURN CASE true + WHEN -10 THEN 'minus ten' + WHEN 0 THEN 'zero' + WHEN 1 THEN 'one' + WHEN 5 THEN 'five' + WHEN 10 THEN 'ten' + WHEN 3000 THEN 'three thousand' + ELSE 'something else' + END AS result; +---- 1 +something else + diff --git a/test/test_files/tck/expressions/list/List1.test b/test/test_files/tck/expressions/list/List1.test new file mode 100644 index 0000000000..433bae3041 --- /dev/null +++ b/test/test_files/tck/expressions/list/List1.test @@ -0,0 +1,135 @@ +-GROUP TCKList1 +-DATASET CSV tck + +-- + + +# Indexing into literal list +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1, 2, 3][1] AS value; +## Outcome: the result should be, in any order: +---- 1 +1 + +# Indexing into nested literal lists +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [[1]][1][1]; +## Outcome: the result should be, in any order: +---- 1 +1 + + +# Use list lookup based on parameters when there is no type information +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +#parameters are: +#expr | ['Apa'] +#idx | 0 +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[idx] AS value; +## Outcome: the result should be, in any order: +---- 1 +'Apa' + +# Use list lookup based on parameters when there is lhs type information +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +#parameters are: +#idx | 0 +-STATEMENT WITH ['Apa'] AS expr + RETURN expr[$idx] AS value; +## Outcome: the result should be, in any order: +---- 1 +'Apa' + +# Use list lookup based on parameters when there is rhs type information +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +#parameters are: +#expr | ['Apa'] +#idx | 0 +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[toInteger(idx)] AS value; +## Outcome: the result should be, in any order: +---- 1 +'Apa' + +#Fail when indexing a non-list #Example: boolean +-CASE Scenario6 +-STATEMENT WITH true AS list, 1 AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(BOOL,INT64). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH 123 AS list, 0 AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(INT64,INT64). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH 4.7 AS list, 0 AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(DOUBLE,INT64). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +# Fail when indexing with a non-integer #Example: boolean +-CASE Scenario8 +## Context: any graph +-STATEMENT WITH [1, 2, 3, 4, 5] AS list, true AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(VAR_LIST,BOOL). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH [1, 2, 3, 4, 5] AS list, 4.7 AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(VAR_LIST,DOUBLE). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH [1, 2, 3, 4, 5] AS list, '1' AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(VAR_LIST,STRING). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH [1, 2, 3, 4, 5] AS list, [1] AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(VAR_LIST,VAR_LIST). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING + +-STATEMENT WITH [1, 2, 3, 4, 5] AS list, {x: 3} AS idx + RETURN list[idx]; +---- error +Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(VAR_LIST,STRUCT). Supported inputs are +(VAR_LIST,INT64) -> ANY +(STRING,INT64) -> STRING diff --git a/test/test_files/tck/expressions/list/List11.test b/test/test_files/tck/expressions/list/List11.test new file mode 100644 index 0000000000..1e8e2cbb04 --- /dev/null +++ b/test/test_files/tck/expressions/list/List11.test @@ -0,0 +1,493 @@ +-GROUP TCKList11 +-DATASET CSV tck + +-- + + +# Create list from `range()` with default step +-CASE Scenario1 +-STATEMENT RETURN range(-1236, -1234) AS list; +---- 1 +[-1236,-1235,-1234] + +-STATEMENT RETURN range(-1234, -1234) AS list; +---- 1 +[-1234] + +-STATEMENT RETURN range(-10, -3) AS list; +---- 1 +[-10,-9,-8,-7,-6,-5,-4,-3] + +-STATEMENT RETURN range(-10, 0) AS list; +## Outcome: the result should be, in any order: +---- 1 +[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0] + +-STATEMENT RETURN range(-1, 0) AS list; +## Outcome: the result should be, in any order: +---- 1 +[-1,0] + +-STATEMENT RETURN range(0, -123) AS list; +## Outcome: the result should be, in any order: +---- 1 +[] + +-STATEMENT RETURN range(0, -1) AS list; +## Outcome: the result should be, in any order: +---- 1 +[] + +-STATEMENT RETURN range(-1, 1) AS list; +## Outcome: the result should be, in any order: +---- 1 +[-1,0,1] + +-STATEMENT RETURN range(0, 0) AS list; +## Outcome: the result should be, in any order: +---- 1 +[0] + +-STATEMENT RETURN range(0, 1) AS list; +## Outcome: the result should be, in any order: +---- 1 +[0,1] + +-STATEMENT RETURN range(0, 10) AS list; +## Outcome: the result should be, in any order: +---- 1 +[0,1,2,3,4,5,6,7,8,9,10] + +-STATEMENT RETURN range(6, 10) AS list; +## Outcome: the result should be, in any order: +---- 1 +[6,7,8,9,10] + +-STATEMENT RETURN range(1234, 1234) AS list; +## Outcome: the result should be, in any order: +---- 1 +[1234] + +-STATEMENT RETURN range(1234, 1236) AS list; +## Outcome: the result should be, in any order: +---- 1 +[1234,1235,1236] + +-CASE Scenario2 +-STATEMENT RETURN range(1381, -3412, -1298) AS list; +## Outcome: the result should be, in any order: +---- 1 +[1381,83,-1215,-2513] + +-STATEMENT RETURN range(0, -2000, -1298) AS list; +---- 1 +[0,-1298] +-STATEMENT RETURN range(10, -10, -3) AS list; +---- 1 +[10,7,4,1,-2,-5,-8] +-STATEMENT RETURN range(0, -10, -3) AS list; +---- 1 +[0,-3,-6,-9] +-STATEMENT RETURN range(0, -20, -2) AS list; +---- 1 +[0,-2,-4,-6,-8,-10,-12,-14,-16,-18,-20] +-STATEMENT RETURN range(0, -10, -1) AS list; +---- 1 +[0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-10] +-STATEMENT RETURN range(0, -1, -1) AS list; +---- 1 +[0,-1] +-STATEMENT RETURN range(-1236, -1234, 1) AS list; +---- 1 +[-1236,-1235,-1234] +-STATEMENT RETURN range(-10, 0, 1) AS list; +---- 1 +[-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0] +-STATEMENT RETURN range(-1, 0, 1) AS list; +---- 1 +[-1,0] +-STATEMENT RETURN range(0, 1, -123) AS list; +---- 1 +[] +-STATEMENT RETURN range(0, 1, -1) AS list; +---- 1 +[] +-STATEMENT RETURN range(0, -123, 1) AS list; +---- 1 +[] +-STATEMENT RETURN range(0, -1, 1) AS list; +---- 1 +[] +-STATEMENT RETURN range(0, 0, -1) AS list; +---- 1 +[0] +-STATEMENT RETURN range(0, 0, 1) AS list; +---- 1 +[0] +-STATEMENT RETURN range(0, 1, 2) AS list; +---- 1 +[0] +-STATEMENT RETURN range(0, 1, 1) AS list; +---- 1 +[0,1] +-STATEMENT RETURN range(0, 10, 1) AS list; +---- 1 +[0,1,2,3,4,5,6,7,8,9,10] +-STATEMENT RETURN range(6, 10, 1) AS list; +---- 1 +[6,7,8,9,10] +-STATEMENT RETURN range(1234, 1234, 1) AS list; +---- 1 +[1234] +-STATEMENT RETURN range(1234, 1236, 1) AS list; +---- 1 +[1234,1235,1236] +-STATEMENT RETURN range(-10, 0, 3) AS list; +---- 1 +[-10,-7,-4,-1] +-STATEMENT RETURN range(-10, 10, 3) AS list; +---- 1 +[-10,-7,-4,-1,2,5,8] +-STATEMENT RETURN range(-2000, 0, 1298) AS list; +---- 1 +[-2000,-702] +-STATEMENT RETURN range(-3412, 1381, 1298) AS list; +---- 1 +[-3412,-2114,-816,482] + +# Create an empty list if range direction and step direction are inconsistent +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH 0 AS start, [1, 2, 500, 1000, 1500] AS stopList, [-1000, -3, -2, -1, 1, 2, 3, 1000] AS stepList + UNWIND stopList AS stop + UNWIND stepList AS step + WITH start, stop, step, range(start, stop, step) AS list + WITH start, stop, step, list, sign(stop-start) <> sign(step) AS empty + #RETURN ALL(ok IN collect((size(list) = 0) = empty) WHERE ok) AS okay; +## Outcome: the result should be, in any order: +---- 1 +TRUE + +# Fail on invalid arguments for `range()` +-CASE Scenario4 +-STATEMENT RETURN range(0, 0, 0); +## Outcome: an ArgumentError should be raised at runtime: NumberOutOfRange +---- error +Runtime exception: Step of range cannot be 0. + +-STATEMENT RETURN range(2, 8, 0); +## Outcome: an ArgumentError should be raised at runtime: NumberOutOfRange +---- error +Runtime exception: Step of range cannot be 0. + +-STATEMENT RETURN range(-2, 8, 0); +## Outcome: an ArgumentError should be raised at runtime: NumberOutOfRange +---- error +Runtime exception: Step of range cannot be 0. + +-STATEMENT RETURN range(2, -8, 0); +## Outcome: an ArgumentError should be raised at runtime: NumberOutOfRange +---- error +Runtime exception: Step of range cannot be 0. + +# Fail on invalid argument types for `range()` +-CASE Scenario5 +-STATEMENT RETURN range(true, 1, 1); +## Outcome: an Error should be raised at runtime: InvalidArgumentType +---- error +Binder exception: Cannot match a built-in function for given function RANGE(BOOL,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, true, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,BOOL,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1, true); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,BOOL). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(-1.1, 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(DOUBLE,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(-0.0, 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(DOUBLE,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0.0, 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(DOUBLE,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(1.1, 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(DOUBLE,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, -1.1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,DOUBLE,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, -0.0, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,DOUBLE,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 0.0, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,DOUBLE,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1.1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,DOUBLE,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1, -1.1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,DOUBLE). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1, 1.1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,DOUBLE). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range('xyz', 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(STRING,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 'xyz', 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,STRING,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1, 'xyz'); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,STRING). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range([0], 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(VAR_LIST,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, [1], 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,VAR_LIST,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range(0, 1, [1]); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,VAR_LIST). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + +-STATEMENT RETURN range({start: 0}, 1, 1); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(STRUCT,INT64,INT64). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST + + +-STATEMENT RETURN range(0, 1, {step: 1}); +---- error +Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,STRUCT). Supported inputs are +(INT64,INT64) -> VAR_LIST +(INT64,INT64,INT64) -> VAR_LIST +(INT32,INT32) -> VAR_LIST +(INT32,INT32,INT32) -> VAR_LIST +(INT16,INT16) -> VAR_LIST +(INT16,INT16,INT16) -> VAR_LIST +(INT8,INT8) -> VAR_LIST +(INT8,INT8,INT8) -> VAR_LIST +(SERIAL,SERIAL) -> VAR_LIST +(SERIAL,SERIAL,SERIAL) -> VAR_LIST diff --git a/test/test_files/tck/expressions/list/List2.test b/test/test_files/tck/expressions/list/List2.test new file mode 100644 index 0000000000..2e06484f37 --- /dev/null +++ b/test/test_files/tck/expressions/list/List2.test @@ -0,0 +1,191 @@ +-GROUP TCKList2 +-DATASET CSV tck + +-- + +# List slice +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3, 4, 5] AS list + RETURN list[2:4]; +## Outcome: the result should be, in any order: +---- 1 +[2,3] + +# List slice with implicit end +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[2:] AS r; +## Outcome: the result should be, in any order: +---- 1 +[2] + +# List slice with implicit start +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[:3] AS r; +## Outcome: the result should be, in any order: +---- 1 +[1,2] + +# List slice with singleton range +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[1:2] AS r; +## Outcome: the result should be, in any order: +---- 1 +[1] + +# List slice with empty range +-CASE Scenario5 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[1:1] AS r; +## Outcome: the result should be, in any order: +---- 1 +[] + +# List slice with negative range +-CASE Scenario6 +-SKIP +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[-3:-1] AS r; +## Outcome: the result should be, in any order: +---- 1 +[1,2] + +# List slice with invalid range +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[3:1] AS r; +## Outcome: the result should be, in any order: +---- 1 +[] + +# List slice with exceeding range +-CASE Scenario8 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[-5:5] AS r; +## Outcome: the result should be, in any order: +---- 1 +[1,2,3] + +# List slice with null range +-CASE Scenario9 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[null:null] AS r; +## Outcome: the result should be, in any order: +---- 1 + + +# List slice with null range +-CASE Scenario10 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[1:null] AS r; +## Outcome: the result should be, in any order: +---- 1 + + +# List slice with null range +-CASE Scenario11 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[null:3] AS r; +## Outcome: the result should be, in any order: +---- 1 + + +# List slice with null range +-CASE Scenario12 +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[:null] AS r; +## Outcome: the result should be, in any order: +---- 1 + + +# List slice with null range +-CASE Scenario13 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[null:] AS r; +## Outcome: the result should be, in any order: +---- 1 + + +# List slice with parameterised range +-CASE Scenario14 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#from | 1 +#to | 3 +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[$from..$to] AS r; +## Outcome: the result should be, in any order: +---- 1 +[2, 3] + +# List slice with parameterised invalid range +-CASE Scenario15 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#from | 3 +#to | 1 +-STATEMENT WITH [1, 2, 3] AS list + RETURN list[$from..$to] AS r; +## Outcome: the result should be, in any order: +---- 1 +[] \ No newline at end of file diff --git a/test/test_files/tck/expressions/list/List3.test b/test/test_files/tck/expressions/list/List3.test new file mode 100644 index 0000000000..b3d74042f6 --- /dev/null +++ b/test/test_files/tck/expressions/list/List3.test @@ -0,0 +1,86 @@ +-GROUP TCKList3 +-DATASET CSV tck + +-- + + +# Equality between list and literal should return false +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1, 2] = 'foo' AS res; +## Outcome: the result should be, in any order: +---- 1 +false + +# Equality of lists of different length should return false despite nulls +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1] = [1, null] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# Equality between different lists with null should return false +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1, 2] = [null, 'foo'] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# Equality between almost equal lists with null should return null +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1, 2] = [null, 2] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# Equality of nested lists of different length should return false despite nulls +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [[1]] = [[1], [null]] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# Equality between different nested lists with null should return false +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [[1, 2], [1, 3]] = [[1, 2], [null, 'foo']] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# Equality between almost equal nested lists with null should return null +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [[1, 2], ['foo', 'bar']] = [[1, 2], [null, 'bar']] AS res; +## Outcome: the result should be, in any order: +---- 1 +Null diff --git a/test/test_files/tck/expressions/list/List4.test b/test/test_files/tck/expressions/list/List4.test new file mode 100644 index 0000000000..67716e82a0 --- /dev/null +++ b/test/test_files/tck/expressions/list/List4.test @@ -0,0 +1,28 @@ +-GROUP TCKList4 +-DATASET CSV tck + +-- + + +# Concatenating lists of same type +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1, 10, 100] + [4, 5] AS foo; +## Outcome: the result should be, in any order: +---- 1 +[1,10,100,4,5] + +# Concatenating a list with a scalar of same type +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [False,True] + False AS foo; +## Outcome: the result should be, in any order: +---- 1 +[False,True,False] diff --git a/test/test_files/tck/expressions/list/List5.test b/test/test_files/tck/expressions/list/List5.test new file mode 100644 index 0000000000..a01a195766 --- /dev/null +++ b/test/test_files/tck/expressions/list/List5.test @@ -0,0 +1,126 @@ +-GROUP TCKList5 +-DATASET CSV tck + +-- + +# IN should work with nested list subscripting +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [[1,2,3]] AS list + RETURN 3 IN list[0] AS r; +## Outcome: the result should be, in any order: +---- 1 +True + +# IN should work with nested literal list subscripting +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN 3 IN [[1,2,3]][0] AS r; +## Outcome: the result should be, in any order: +---- 1 +True + +# IN should work with list slices +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [1,2,3] AS list + RETURN 3 IN list[1:2] AS r; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should work with literal list slices +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN 3 IN [1,2,3][1:2] AS r; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should return false when matching a number with a string +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN 1 IN ['1',2] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should return false when matching a number with a string - list version +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1,2] IN [1,[1,'2']] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should return false when types of LHS and RHS don't match - singleton list +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1] IN [1,2] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should return false when types of LHS and RHS don't match - list +-CASE Scenario8 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1,2] IN [1,2] AS res; +## Outcome: the result should be, in any order: +---- 1 +False + +# IN should return true when types of LHS and RHS match - singleton list +-CASE Scenario9 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1] IN [1,2,[1]] AS res; +## Outcome: the result should be, in any order: +---- 1 +True + +# IN should return true when types of LHS and RHS match - list +-CASE Scenario10 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN [1,2] IN [1,[1,2]] AS res; +## Outcome: the result should be, in any order: +---- 1 +True \ No newline at end of file diff --git a/test/test_files/tck/expressions/list/List6.test b/test/test_files/tck/expressions/list/List6.test new file mode 100644 index 0000000000..0abf3ff7e7 --- /dev/null +++ b/test/test_files/tck/expressions/list/List6.test @@ -0,0 +1,55 @@ +-GROUP TCKList6 +-DATASET CSV tck + +-- + + +# Return list size +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN size([1, 2, 3]) AS n; +## Outcome: the result should be, in any order: +---- 1 +3 + +# Setting and returning the size of a list property +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE TheLabel(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:TheLabel); +-STATEMENT MATCH (n:TheLabel) + SET n.numbers = [1, 2, 3] + RETURN size(n.numbers); +## Outcome: the result should be, in any order: +---- 1 +3 +## Outcome: the side effects should be: +---- 0 + +# Concatenating and returning the size of literal lists +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN size([[], []] + [[]]) AS l; +## Outcome: the result should be, in any order: +---- 1 +3 + +# `size()` on null list +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH null AS l + RETURN size(l), size(null); +## Outcome: the result should be, in any order: +---- 1 +| diff --git a/test/test_files/tck/expressions/map/Map1.test b/test/test_files/tck/expressions/map/Map1.test new file mode 100644 index 0000000000..989484b295 --- /dev/null +++ b/test/test_files/tck/expressions/map/Map1.test @@ -0,0 +1,150 @@ +-GROUP TCKMap1 +-DATASET CSV tck + +-- + + +# Statically access a field of a non-null map +-CASE Scenario1 +-STATEMENT WITH {existing: 42, notMissing: null} AS m + RETURN m.notMissing, m.existing; +## Outcome: the result should be, in any order: +---- 1 +|42 + +# Statically access a field of a null map +-CASE Scenario2 +-SKIP +-STATEMENT WITH null AS m + RETURN m.missing; +## Outcome: the result should be, in any order: +---- 1 +null + +# Statically access a field of a map resulting from an expression +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [{existing: 42, notMissing: null}, {existing: 42, notMissing: null}] AS list + RETURN (list[1]).notMissing, (list[1]).existing; +## Outcome: the result should be, in any order: +---- 1 +|42 + +# Statically access a field is case-sensitive +-CASE Scenario4 +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map.name AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map.name AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + + +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map.nAMe AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-CASE Scenario4_error +-SKIP +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map.Name AS result; +## Outcome: the result should be, in any order: +---- 1 +Pontus + +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map.nAMe AS result; +## Outcome: the result should be, in any order: +---- 1 + + +# Statically access a field with a delimited identifier +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map.`name` AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map.`nome` AS result; +## Outcome: the result should be, in any order: +---- 1 +Pontus + +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map.`Mats` AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map.`null` AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +-STATEMENT WITH {null: 'Mats', NULL: 'Pontus'} AS map + RETURN map.`null` AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH {null: 'Mats', NULL: 'Pontus'} AS map + RETURN map.NULL` AS result; +## Outcome: the result should be, in any order: +---- 1 +Pontus + +# Fail when performing property access on a non-map +-CASE Scenario6 +-STATEMENT WITH 123 AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: nonMap has data type INT64 but (NODE,REL,STRUCT) was expected. + +-STATEMENT WITH 42.45 AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: nonMap has data type DOUBLE but (NODE,REL,STRUCT) was expected. + +-STATEMENT WITH True AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: nonMap has data type BOOL but (NODE,REL,STRUCT) was expected. + +-STATEMENT WITH False AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: nonMap has data type BOOL but (NODE,REL,STRUCT) was expected. + +-STATEMENT WITH 'string' AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: nonMap has data type STRING but (NODE,REL,STRUCT) was expected. + +-STATEMENT WITH [123, True] AS nonMap + RETURN nonMap.num; +## Outcome: an Error should be raised at compile time: InvalidArgumentType +---- error +Binder exception: Cannot bind LIST_CREATION with parameter type INT64 and BOOL. diff --git a/test/test_files/tck/expressions/map/Map2.test b/test/test_files/tck/expressions/map/Map2.test new file mode 100644 index 0000000000..eea4e3df28 --- /dev/null +++ b/test/test_files/tck/expressions/map/Map2.test @@ -0,0 +1,165 @@ +-GROUP TCKMap2 +-DATASET CSV tck + +-- + + +# Dynamically access a field based on parameters when there is no type information +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#expr|{name: 'Apa'} +#idx|'name' +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[idx] AS value; +## Outcome: the result should be, in any order: +---- 1 +Apa + +# Dynamically access a field based on parameters when there is rhs type information +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#expr|{name: 'Apa'} +#idx|'name' +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[toString(idx)] AS value; +## Outcome: the result should be, in any order: +---- 1 +Apa + +# Dynamically access a field on null results in null +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH null AS expr, 'x' AS idx + RETURN expr[idx] AS value; +## Outcome: the result should be, in any order: +---- 1 +null + +# Dynamically access a field with null results in null +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH map(['name'], ['Mats']) AS expr, null AS idx + RETURN expr[idx] AS value; +## Outcome: the result should be, in any order: +---- 1 +null + +# Dynamically access a field is case-sensitive +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH map(['name', 'nome'], ['Mats', 'Pontus']) AS map + RETURN map['name'] AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH map(['name', 'Name'], ['Mats', 'Pontus']) AS map + RETURN map['name'] AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map['Name'] AS result; +## Outcome: the result should be, in any order: +---- 1 +Pontus + +-STATEMENT WITH {name: 'Mats', Name: 'Pontus'} AS map + RETURN map['nAMe'] AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +-STATEMENT WITH {name: 'Mats', nome: 'Pontus'} AS map + RETURN map['null'] AS result; +## Outcome: the result should be, in any order: +---- 1 +null + +-STATEMENT WITH {null: 'Mats', NULL: 'Pontus'} AS map + RETURN map['null'] AS result; +## Outcome: the result should be, in any order: +---- 1 +Mats + +-STATEMENT WITH {null: 'Mats', NULL: 'Pontus'} AS map + RETURN map['NULL'] AS result; +## Outcome: the result should be, in any order: +---- 1 +Pontus + +# Fail at runtime when attempting to index with an Int into a Map +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#expr|{name: 'Apa'} +#idx|0 +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[idx]; +## Outcome: an Error should be raised at runtime: MapElementAccessByNonString +---- error +1 + +# Fail at runtime when trying to index into a map with a non-string +-CASE Scenario13 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#expr|{name: 'Apa'} +#idx|12.3 +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[idx]; +## Outcome: a TypeError should be raised at runtime: MapElementAccessByNonString +---- error +TypeError: Map element access by non-string + +# Fail at runtime when trying to index something which is not a map +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#expr|100 +#idx|0 +-STATEMENT WITH $expr AS expr, $idx AS idx + RETURN expr[idx]; +## Outcome: an Error should be raised at any time: InvalidArgumentType +---- error +Invalid argument type diff --git a/test/test_files/tck/expressions/map/Map3.test b/test/test_files/tck/expressions/map/Map3.test new file mode 100644 index 0000000000..fb6cb2ca65 --- /dev/null +++ b/test/test_files/tck/expressions/map/Map3.test @@ -0,0 +1,100 @@ +-GROUP TCKMap3 +-DATASET CSV tck + +-- + + +# Using `keys()` on a literal map +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN map_keys( +map(['Alice','age', 'address'], + ['Alice', 38, map(['city', 'residential'], ['London', True])])) AS k; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +['name', 'age', 'address'] + +# Using `keys()` on a parameter map +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#param|{name: 'Alice', age: 38, address: {city: 'London', residential: true}} +-STATEMENT RETURN ($param) AS k; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +['address', 'name', 'age'] + +# Using `keys()` on null map +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH map([],[]) AS m + RETURN map_keys(m), map_keys(map([],[])); +## Outcome: the result should be, in any order: +---- 1 +[]|[] + +# Using `keys()` on map with null values +-CASE Scenario4 +## VERIFY + +-STATEMENT RETURN map_keys(map([], [])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[] + +-STATEMENT RETURN map_keys(map(['k'], [1])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k] + +-STATEMENT RETURN map_keys(map(['k'], [null])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k] + +-STATEMENT RETURN map_keys(map(['k', 'l'], [null, 1])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k,l] + +-STATEMENT RETURN map_keys(map(['k', 'l'], [1, null])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k,l] + +-STATEMENT RETURN map_keys(map(['k', 'l'], [null, null])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k,l] + +-STATEMENT RETURN map_keys(map(['k', 'l', 'm'], [1, null, 1])) AS keys; +## Outcome: the result should be (ignoring element order for lists): +---- 1 +[k,l,m] + +# Using `keys()` and `IN` to check field existence +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH {exists: 42, notMissing: null} AS map + RETURN 'exists' IN keys(map) AS a, + 'notMissing' IN keys(map) AS b, + 'missing' IN keys(map) AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False diff --git a/test/test_files/tck/expressions/mathematical/Mathematical11.test b/test/test_files/tck/expressions/mathematical/Mathematical11.test new file mode 100644 index 0000000000..5d6f19899c --- /dev/null +++ b/test/test_files/tck/expressions/mathematical/Mathematical11.test @@ -0,0 +1,15 @@ +-GROUP TCKMathematical11 +-DATASET CSV tck + +-- + +# Absolute function +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN abs(-1); +## Outcome: the result should be, in any order: +---- 1 +1 diff --git a/test/test_files/tck/expressions/mathematical/Mathematical13.test b/test/test_files/tck/expressions/mathematical/Mathematical13.test new file mode 100644 index 0000000000..fafff26f09 --- /dev/null +++ b/test/test_files/tck/expressions/mathematical/Mathematical13.test @@ -0,0 +1,16 @@ +-GROUP TCKMathematical13 +-DATASET CSV tck + +-- + + +# `sqrt()` returning float values +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN sqrt(12.96); +## Outcome: the result should be, in any order: +---- 1 +3.600000 diff --git a/test/test_files/tck/expressions/mathematical/Mathematical2.test b/test/test_files/tck/expressions/mathematical/Mathematical2.test new file mode 100644 index 0000000000..f15fbb6a1d --- /dev/null +++ b/test/test_files/tck/expressions/mathematical/Mathematical2.test @@ -0,0 +1,19 @@ +-GROUP TCKMathematical2 +-DATASET CSV tck + +-- + + +# Allow addition +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name INT64, version INT64, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:A {name: 1337, version: 99}); +---- ok +-STATEMENT MATCH (a) + WHERE a.name = 1337 + RETURN a.version + 5; +## Outcome: the result should be, in any order: +---- 1 +104 diff --git a/test/test_files/tck/expressions/mathematical/Mathematical3.test b/test/test_files/tck/expressions/mathematical/Mathematical3.test new file mode 100644 index 0000000000..268ed32554 --- /dev/null +++ b/test/test_files/tck/expressions/mathematical/Mathematical3.test @@ -0,0 +1,14 @@ +-GROUP TCKMathematical3 +-DATASET CSV tck + +-- + + +# Fail for invalid Unicode hyphen in subtraction +-CASE Scenario1 +-STATEMENT RETURN 42 — 41; +---- error +Parser exception: Invalid input < —>: expected rule oC_Cypher (line: 1, offset: 10) +"RETURN 42 — 41;" + ^ + diff --git a/test/test_files/tck/expressions/mathematical/Mathematical8.test b/test/test_files/tck/expressions/mathematical/Mathematical8.test new file mode 100644 index 0000000000..99ce4c9b30 --- /dev/null +++ b/test/test_files/tck/expressions/mathematical/Mathematical8.test @@ -0,0 +1,27 @@ +-GROUP TCKMathematical8 +-DATASET CSV tck + +-- + + +# Arithmetic precedence test +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN 12 / 4 * 3 - 2 * 4; +## Outcome: the result should be, in any order: +---- 1 +1 + +# Arithmetic precedence with parenthesis test +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN 12 / 4 * (3 - 2 * 4); +## Outcome: the result should be, in any order: +---- 1 +-15 diff --git a/test/test_files/tck/expressions/precedence/Precedence1.test b/test/test_files/tck/expressions/precedence/Precedence1.test new file mode 100644 index 0000000000..11f03403f6 --- /dev/null +++ b/test/test_files/tck/expressions/precedence/Precedence1.test @@ -0,0 +1,273 @@ +-GROUP TCKPrecedence1 +-DATASET CSV tck + +-- + + +# Exclusive disjunction takes precedence over inclusive disjunction +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN True OR True XOR True AS a, + True OR (True XOR True) AS b, + (True OR True) XOR True AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Conjunction disjunction takes precedence over exclusive disjunction +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN True XOR False AND False AS a, + True XOR (False AND False) AS b, + (True XOR False) AND False AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Conjunction disjunction takes precedence over inclusive disjunction +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN True OR False AND False AS a, + True OR (False AND False) AS b, + (True OR False) AND False AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Negation takes precedence over conjunction +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT True AND False AS a, + (NOT True) AND False AS b, + NOT (True AND False) AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# Negation takes precedence over inclusive disjunction +-CASE Scenario5 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT False OR True AS a, + (NOT False) OR True AS b, + NOT (False OR True) AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Comparison operator takes precedence over boolean negation +-CASE Scenario6 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT False >= False AS a, + NOT (False >= False) AS b, + (NOT False) >= False AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# Comparison operator takes precedence over binary boolean operator +-CASE Scenario7 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN True OR False = False AS a, + True OR (False = False) AS b, + (True OR False) = False AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Null predicate takes precedence over comparison operator +-CASE Scenario8 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN False = True IS NULL AS a, + False = (True IS NULL) AS b, + (False = True) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Null predicate takes precedence over negation +-CASE Scenario9 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT False IS NULL AS a, + NOT (False IS NULL) AS b, + (NOT False) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Null predicate takes precedence over boolean operator +-CASE Scenario10 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN True OR False IS NULL AS a, + True OR (False IS NULL) AS b, + (True OR False) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# List predicate takes precedence over comparison operator +-CASE Scenario11 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN False = True IN [True, False] AS a, + False = (True IN [True, False]) AS b, + (False = True) IN [True, False] AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# List predicate takes precedence over negation +-CASE Scenario12 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT True IN [True, False] AS a, + NOT (True IN [True, False]) AS b, + (NOT True) IN [True, False] AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# List predicate takes precedence over boolean operator +-CASE Scenario13 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN False AND True IN [True, False] AS a, + False AND (True IN [True, False]) AS b, + (False AND True) IN [True, False] AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# Exclusive disjunction takes precedence over inclusive disjunction in every combination of truth values +-CASE Scenario14 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + UNWIND [True, False, null] AS c + WITH collect((a OR b XOR c) = (a OR (b XOR c))) AS eq, + collect((a OR b XOR c) <> ((a OR b) XOR c)) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Conjunction takes precedence over exclusive disjunction in every combination of truth values +-CASE Scenario15 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + UNWIND [True, False, null] AS c + WITH collect((a XOR b AND c) = (a XOR (b AND c))) AS eq, + collect((a XOR b AND c) <> ((a XOR b) AND c)) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Conjunction takes precedence over inclusive disjunction in every combination of truth values +-CASE Scenario16 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + UNWIND [True, False, null] AS c + WITH collect((a OR b AND c) = (a OR (b AND c))) AS eq, + collect((a OR b AND c) <> ((a OR b) AND c)) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Negation takes precedence over conjunction in every combination of truth values +-CASE Scenario17 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + WITH collect((NOT a AND b) = ((NOT a) AND b)) AS eq, + collect((NOT a AND b) <> (NOT (a AND b))) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Negation takes precedence over inclusive disjunction in every combination of truth values +-CASE Scenario18 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + WITH collect((NOT a OR b) = ((NOT a) OR b)) AS eq, + collect((NOT a OR b) <> (NOT (a OR b))) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Comparison operators takes precedence over boolean negation in every combination of truth values +-CASE Scenario19 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + WITH collect((NOT a <= b) = (NOT (a <= b))) AS eq, + collect((NOT a <= b) <> ((NOT a) <= b)) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True + +# Comparison operators takes precedence over boolean negation in every combination of truth values +-CASE Scenario20 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT UNWIND [True, False, null] AS a + UNWIND [True, False, null] AS b + WITH collect((NOT a >= b) = (NOT (a >= b))) AS eq, + collect((NOT a >= b) <> ((NOT a) >= b)) AS neq + RETURN all(x IN eq WHERE x) AND any(x IN neq WHERE x) AS result; +## Outcome: the result should be, in any order: +---- 1 +True \ No newline at end of file diff --git a/test/test_files/tck/expressions/precedence/Precedence2.test b/test/test_files/tck/expressions/precedence/Precedence2.test new file mode 100644 index 0000000000..dbd96652c4 --- /dev/null +++ b/test/test_files/tck/expressions/precedence/Precedence2.test @@ -0,0 +1,171 @@ +-GROUP TCKPrecedence2 +-DATASET CSV tck + +-- + + +# Numeric multiplicative operations takes precedence over numeric additive operations +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN 4 * 2 + 3 * 2 AS a, + 4 * 2 + (3 * 2) AS b, + 4 * (2 + 3) * 2 AS c; +## Outcome: the result should be, in any order: +---- 1 +14|14|40 +-STATEMENT RETURN 4 * 2 + 3 / 2 AS a, + 4 * 2 + (3 / 2) AS b, + 4 * (2 + 3) / 2 AS c +---- 1 +9|9|10 +-STATEMENT RETURN 4 * 2 + 3 % 2 AS a, + 4 * 2 + (3 % 2) AS b, + 4 * (2 + 3) % 2 AS c +---- 1 +9|9|0 +-STATEMENT RETURN 4 * 2 - 3 * 2 AS a, + 4 * 2 - (3 * 2) AS b, + 4 * (2 - 3) * 2 AS c +---- 1 +2|2|-8 +-STATEMENT RETURN 4 * 2 - 3 / 2 AS a, + 4 * 2 - (3 / 2) AS b, + 4 * (2 - 3) / 2 AS c +---- 1 +7|7|-2 +-STATEMENT RETURN 4 * 2 - 3 % 2 AS a, + 4 * 2 - (3 % 2) AS b, + 4 * (2 - 3) % 2 AS c +---- 1 +7|7|0 +-STATEMENT RETURN 4 / 2 + 3 * 2 AS a, + 4 / 2 + (3 * 2) AS b, + 4 / (2 + 3) * 2 AS c +---- 1 +8|8|0 +-STATEMENT RETURN 4 / 2 + 3 / 2 AS a, + 4 / 2 + (3 / 2) AS b, + 4 / (2 + 3) / 2 AS c +---- 1 +3|3|0 +-STATEMENT RETURN 4 / 2 + 3 % 2 AS a, + 4 / 2 + (3 % 2) AS b, + 4 / (2 + 3) % 2 AS c +---- 1 +3|3|0 +-STATEMENT RETURN 4 / 2 - 3 * 2 AS a, + 4 / 2 - (3 * 2) AS b, + 4 / (2 - 3) * 2 AS c +---- 1 +-4|-4|-8 +-STATEMENT RETURN 4 / 2 - 3 / 2 AS a, + 4 / 2 - (3 / 2) AS b, + 4 / (2 - 3) / 2 AS c +---- 1 +1|1|-2 +-STATEMENT RETURN 4 / 2 - 3 % 2 AS a, + 4 / 2 - (3 % 2) AS b, + 4 / (2 - 3) % 2 AS c +---- 1 +1|1|0 +-STATEMENT RETURN 4 % 2 + 3 * 2 AS a, + 4 % 2 + (3 * 2) AS b, + 4 % (2 + 3) * 2 AS c +---- 1 +6|6|8 +-STATEMENT RETURN 4 % 2 + 3 / 2 AS a, + 4 % 2 + (3 / 2) AS b, + 4 % (2 + 3) / 2 AS c +---- 1 +1|1|2 +-STATEMENT RETURN 4 % 2 + 3 % 2 AS a, + 4 % 2 + (3 % 2) AS b, + 4 % (2 + 3) % 2 AS c +---- 1 +1|1|0 +-STATEMENT RETURN 4 % 2 - 3 * 2 AS a, + 4 % 2 - (3 * 2) AS b, + 4 % (2 - 3) * 2 AS c +---- 1 +-6|-6|0 +-STATEMENT RETURN 4 % 2 - 3 / 2 AS a, + 4 % 2 - (3 / 2) AS b, + 4 % (2 - 3) / 2 AS c +---- 1 +-1|-1|0 +-STATEMENT RETURN 4 % 2 - 3 % 2 AS a, + 4 % 2 - (3 % 2) AS b, + 4 % (2 - 3) % 2 AS c +---- 1 +-1|-1|0 + + +# Exponentiation takes precedence over numeric multiplicative operations +-CASE Scenario2 +-STATEMENT RETURN 4 ^ 3 * 2 ^ 3 AS a, + (4 ^ 3) * (2 ^ 3) AS b, + 4 ^ (3 * 2) ^ 3 AS c; +## Outcome: the result should be, in any order: +---- 1 +512.000000|512.000000|68719476736.000000 + +-STATEMENT RETURN 4 ^ 3 / 2 ^ 3 AS a, + (4 ^ 3) / (2 ^ 3) AS b, + 4 ^ (3 / 2) ^ 3 AS c; +---- 1 +8.000000|8.000000|64.000000 + +-STATEMENT RETURN 4 ^ 3 % 2 ^ 3 AS a, + (4 ^ 3) % (2 ^ 3) AS b, + 4 ^ (3 % 2) ^ 3 AS c; +---- 1 +0.000000|0.000000|64.000000 + + +# Exponentiation takes precedence over numeric additive operations +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN 4 ^ 3 + 2 ^ 3 AS a, + (4 ^ 3) + (2 ^ 3) AS b, + 4 ^ (3 + 2) ^ 3 AS c; +## Outcome: the result should be, in any order: +---- 1 +72.000000|72.000000|1073741824.000000 + +-STATEMENT RETURN 4 ^ 3 - 2 ^ 3 AS a, + (4 ^ 3) - (2 ^ 3) AS b, + 4 ^ (3 - 2) ^ 3 AS c; +---- 1 +56.000000|56.000000|64.000000 + + +# Numeric unary negative takes precedence over exponentiation +-CASE Scenario4 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN -3 ^ 2 AS a, + (-3) ^ 2 AS b, + -(3 ^ 2) AS c; +## Outcome: the result should be, in any order: +---- 1 +9.000000|9.000000|-9.000000 + +# Numeric unary negative takes precedence over numeric additive operations +-CASE Scenario5 +## VERIFY +-STATEMENT RETURN -3 + 2 AS a, + (-3) + 2 AS b, + -(3 + 2) AS c; +---- 1 +-1|-1|-5 + +-STATEMENT RETURN -3 - 2 AS a, + (-3) - 2 AS b, + -(3 - 2) AS c; +---- 1 +-5|-5|-1 diff --git a/test/test_files/tck/expressions/precedence/Precedence3.test b/test/test_files/tck/expressions/precedence/Precedence3.test new file mode 100644 index 0000000000..e48845e176 --- /dev/null +++ b/test/test_files/tck/expressions/precedence/Precedence3.test @@ -0,0 +1,70 @@ +-GROUP TCKPrecedence3 +-DATASET CSV tck + +-- + +# List element access takes precedence over list appending +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10][3] AS a, + [[1], [2, 3], [4, 5]] + ([5, [6, 7], [8, 9], 10][3]) AS b, + ([[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10])[3] AS c; +## Outcome: the result should be, in any order: +---- 1 +[[1], [2, 3], [4, 5], 10]|[[1], [2, 3], [4, 5], 10]|5 + +# List element access takes precedence over list concatenation +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10][2] AS a, + [[1], [2, 3], [4, 5]] + ([5, [6, 7], [8, 9], 10][2]) AS b, + ([[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10])[2] AS c; +## Outcome: the result should be, in any order: +---- 1 +[[1], [2, 3], [4, 5], 8, 9]|[[1], [2, 3], [4, 5], 8, 9]|[4, 5] + +# List slicing takes precedence over list concatenation +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10][1..3] AS a, + [[1], [2, 3], [4, 5]] + ([5, [6, 7], [8, 9], 10][1..3]) AS b, + ([[1], [2, 3], [4, 5]] + [5, [6, 7], [8, 9], 10])[1..3] AS c; +## Outcome: the result should be, in any order: +---- 1 +[[1], [2, 3], [4, 5], [6, 7], [8, 9]]|[[1], [2, 3], [4, 5], [6, 7], [8, 9]]|[[2, 3], [4, 5]] + +# List appending takes precedence over list element containment +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [1]+2 IN [3]+4 AS a, + ([1]+2) IN ([3]+4) AS b, + [1]+(2 IN [3])+4 AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|[1, False, 4] + +# List concatenation takes precedence over list element containment +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN [1]+[2] IN [3]+[4] AS a, + ([1]+[2]) IN ([3]+[4]) AS b, + (([1]+[2]) IN [3])+[4] AS c, + [1]+([2] IN [3])+[4] AS d; +## Outcome: the result should be, in any order: +---- 1 +False|False|[False, 4]|[1, False, 4] diff --git a/test/test_files/tck/expressions/precedence/Precedence4.test b/test/test_files/tck/expressions/precedence/Precedence4.test new file mode 100644 index 0000000000..43844e8dd6 --- /dev/null +++ b/test/test_files/tck/expressions/precedence/Precedence4.test @@ -0,0 +1,123 @@ +-GROUP TCKPrecedence4 +-DATASET CSV tck + +-- + + +# Null predicate takes precedence over comparison operator +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN (null is NOT NULL) = (null is NULL); + +## Outcome: the result should be, in any order: +---- 1 +False + +# Null predicate takes precedence over comparison operator +-CASE Scenario2 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN null IS NULL <> null IS NULL AS a, + (null IS NULL) <> (null IS NULL) AS b, + (null IS NULL <> null) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# Null predicate takes precedence over comparison operator +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN null IS NULL <> null IS NOT NULL AS a, + (null IS NULL) <> (null IS NOT NULL) AS b, + (null IS NULL <> null) IS NOT NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +# Null predicate takes precedence over boolean negation +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN NOT null IS NULL AS a, + NOT (null IS NULL) AS b, + (NOT null) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +# Null predicate takes precedence over binary boolean operator +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN null AND null IS NULL AS a, + null AND (null IS NULL) AS b, + (null AND null) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +null|null|True + +# Null predicate takes precedence over binary boolean operator +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT RETURN null AND True IS NULL AS a, + null AND (True IS NULL) AS b, + (null AND True) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +False|False|True + +-STATEMENT RETURN False AND False IS NOT NULL AS a, + False AND (False IS NOT NULL) AS b, + (False AND False) IS NOT NULL AS c; +---- 1 +False|False|True + +-STATEMENT RETURN null OR False IS NULL AS a, + null OR (False IS NULL) AS b, + (null OR False) IS NULL AS c; +---- 1 +null|null|True + +-STATEMENT RETURN True OR null IS NULL AS a, + True OR (null IS NULL) AS b, + (True OR null) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +-STATEMENT RETURN True XOR null IS NOT NULL AS a, + True XOR (null IS NOT NULL) AS b, + (True XOR null) IS NOT NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +-STATEMENT RETURN True XOR False IS NULL AS a, + True XOR (False IS NULL) AS b, + (True XOR False) IS NULL AS c; +## Outcome: the result should be, in any order: +---- 1 +True|True|False + +-STATEMENT RETURN ('abc' STARTS WITH null OR True) = (('abc' STARTS WITH null) OR True) AS a, + ('abc' STARTS WITH null OR True) <> ('abc' STARTS WITH (null OR True)) AS b, + (True OR null STARTS WITH 'abc') = (True OR (null STARTS WITH 'abc')) AS c, + (True OR null STARTS WITH 'abc') <> ((True OR null) STARTS WITH 'abc') AS d; +## Outcome: the result should be, in any order: +---- 1 +True|null|True|null \ No newline at end of file diff --git a/test/test_files/tck/expressions/string/String1.test b/test/test_files/tck/expressions/string/String1.test new file mode 100644 index 0000000000..cb743af1e3 --- /dev/null +++ b/test/test_files/tck/expressions/string/String1.test @@ -0,0 +1,16 @@ +-GROUP TCKString1 +-DATASET CSV tck + +-- + + +# `substring()` with default second argument +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN substring('0123456789', 2, 10) AS s; +## Outcome: the result should be, in any order: +---- 1 +123456789 \ No newline at end of file diff --git a/test/test_files/tck/expressions/string/String3.test b/test/test_files/tck/expressions/string/String3.test new file mode 100644 index 0000000000..3b20b5d447 --- /dev/null +++ b/test/test_files/tck/expressions/string/String3.test @@ -0,0 +1,16 @@ +-GROUP TCKString3 +-DATASET CSV tck + +-- + + +# `reverse()` +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN reverse('raksO'); +## Outcome: the result should be, in any order: +---- 1 +Oskar \ No newline at end of file diff --git a/test/test_files/tck/expressions/string/String4.test b/test/test_files/tck/expressions/string/String4.test new file mode 100644 index 0000000000..c209fe7134 --- /dev/null +++ b/test/test_files/tck/expressions/string/String4.test @@ -0,0 +1,17 @@ +-GROUP TCKString4 +-DATASET CSV tck + +-- + + +# `split()` +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND split('one1two', '1') AS item + RETURN count(item) AS item; +---- 1 +2 \ No newline at end of file diff --git a/test/test_files/tck/expressions/typeConversion/TypeConversion1.test b/test/test_files/tck/expressions/typeConversion/TypeConversion1.test new file mode 100644 index 0000000000..4e0928d75e --- /dev/null +++ b/test/test_files/tck/expressions/typeConversion/TypeConversion1.test @@ -0,0 +1,70 @@ +-GROUP TCKTypeConversion1 +-DATASET CSV tck + +-- + + +# `toBoolean()` on booleans +-CASE Scenario1 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [true, false] AS b + RETURN to_bool(b) AS b; +## Outcome: the result should be, in any order: +---- 2 +True +False + +# `toBoolean()` on valid literal string +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT RETURN to_bool('true') AS b; +## Outcome: the result should be, in any order: +---- 1 +True + + +# `toBoolean()` on variables with valid string values +-CASE Scenario3 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND ['true', 'false'] AS s + RETURN to_Bool(s) AS b; +## Outcome: the result should be, in any order: +---- 2 +True +False + +# `toBoolean()` on invalid strings +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT UNWIND [null, '', ' tru ', 'f alse'] AS things + RETURN to_Bool(things) AS b; +## Outcome: the result should be, in any order: +---- 4 + + + +# Fail `toBoolean()` on invalid types #Example: list +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r:T]->() + RETURN [x IN [true, []] | toBoolean(x) ] AS list; +---- error +123 diff --git a/test/test_files/tck/expressions/typeConversion/TypeConversion2.test b/test/test_files/tck/expressions/typeConversion/TypeConversion2.test new file mode 100644 index 0000000000..ce3bde5093 --- /dev/null +++ b/test/test_files/tck/expressions/typeConversion/TypeConversion2.test @@ -0,0 +1,111 @@ +-GROUP TCKTypeConversion2 +-DATASET CSV tck + +-- + + +# `toInteger()` on float +-CASE Scenario1 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH 82.9 AS weight + RETURN to_int64(weight); +## Outcome: the result should be, in any order: +---- 1 +83 + +# `toInteger()` returning error on non-numerical string +-CASE Scenario2 +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH 'foo' AS foo_string, '' AS empty_string + RETURN to_int64(foo_string) AS foo, to_int64(empty_string) AS empty; +## Outcome: the result should be, in any order: +---- error +Conversion exception: Cast failed. foo is not in INT64 range. + +# `toInteger()` handling mixed number types +-CASE Scenario3 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [2, 2.9] AS numbers + RETURN [n IN numbers | toInteger(n)] AS int_numbers; +## Outcome: the result should be, in any order: +---- 1 +[2, 2] + +# `toInteger()` handling Any type +-CASE Scenario4 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH [2, 2.9, '1.7'] AS things + RETURN [n IN things | toInteger(n)] AS int_numbers; +## Outcome: the result should be, in any order: +---- 1 +[2, 2, 1] + +# `toInteger()` on a list of strings +-CASE Scenario5 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +-STATEMENT WITH ['2', '2.9', 'foo'] AS numbers + RETURN [n IN numbers | toInteger(n)] AS int_numbers; +## Outcome: the result should be, in any order: +---- 1 +[2, 2, null] + +# `toInteger()` on a complex-typed expression +-CASE Scenario6 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +## Context: any graph +## Context: parameters are: +#parameters are: +#param | 1 +-STATEMENT RETURN to_Int64(1 - $param) AS result; +## Outcome: the result should be, in any order: +---- 1 +0 + +# `toInteger()` on node property +-CASE Scenario7 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE Person(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE (:Person {name: '42'}); +-STATEMENT MATCH (p:Person { name: '42' }) + WITH * + MATCH (n) + RETURN to_int64(n.name) AS name; +## Outcome: the result should be, in any order: +---- 1 +42 + +# Fail `toInteger()` on invalid types #Example: list +-CASE Scenario8 +-SKIP +## VERIFY +-STATEMENT CREATE NODE TABLE A(ID SERIAL, name STRING, PRIMARY KEY(ID)); +---- ok +-STATEMENT CREATE ()-[:T]->(); +-STATEMENT MATCH p = (n)-[r:T]->() + RETURN [x IN [1, []] | toInteger(x) ] AS list; +## Outcome: a TypeError should be raised at runtime: InvalidArgumentValue +---- error +123