Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
internal/core/eval: use cue's import support in tests
Browse files Browse the repository at this point in the history
Change-Id: I52e179479f99402bc0ec28c09614a3c80de79b17
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6520
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Jul 22, 2020
1 parent 7d54042 commit 7903529
Show file tree
Hide file tree
Showing 58 changed files with 450 additions and 232 deletions.
16 changes: 8 additions & 8 deletions cue/testdata/basicrewrite/001_regexp.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ e3: _|_ // conflicting values !="a" and <5 (mismatched types string and number)
}
-- out/eval --
Errors:
invalid value *adt.BoundValue (mismatched types number and string)
invalid value *adt.Vertex (out of bound *adt.BoundValue)
cannot use *adt.Num (type int) as type (string|bytes):
invalid value "foo" (out of bound =~"[a-z]{4}")
invalid value <5 (mismatched types number and string)
cannot use 1 (type int) as type (string|bytes):
./in.cue:18:5
cannot use *adt.Bool (type bool) as type (string|bytes):
cannot use true (type bool) as type (string|bytes):
./in.cue:19:5

Result:
Expand All @@ -79,20 +79,20 @@ Result:
b1: (string){ "a" }
b2: (string){ "foo" }
b3: (_|_){
// [eval] invalid value *adt.Vertex (out of bound *adt.BoundValue)
// [eval] invalid value "foo" (out of bound =~"[a-z]{4}")
}
b4: (string){ "foo" }
s1: (string){ &(!="b", =~"c") }
s2: (string){ &(!="b", =~"[a-z]") }
e1: (_|_){
// [eval] cannot use *adt.Num (type int) as type (string|bytes):
// [eval] cannot use 1 (type int) as type (string|bytes):
// ./in.cue:18:5
}
e2: (_|_){
// [eval] cannot use *adt.Bool (type bool) as type (string|bytes):
// [eval] cannot use true (type bool) as type (string|bytes):
// ./in.cue:19:5
}
e3: (_|_){
// [eval] invalid value *adt.BoundValue (mismatched types number and string)
// [eval] invalid value <5 (mismatched types number and string)
}
}
20 changes: 10 additions & 10 deletions cue/testdata/basicrewrite/002_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ division by zero:
./in.cue:15:9
division by zero:
./in.cue:16:9
invalid operands *adt.Num and *adt.String to '+' (type int and string):
invalid operands 2 and "a" to '+' (type int and string):
./in.cue:23:5
invalid operands *adt.Num and *adt.Num to 'div' (type float and int):
invalid operands 1.0 and 2 to 'div' (type float and int):
./in.cue:29:5
invalid operands *adt.Num and *adt.Num to 'rem' (type int and float):
invalid operands 2 and 2.0 to 'rem' (type int and float):
./in.cue:30:5
invalid operands *adt.Num and *adt.Num to 'quo' (type int and float):
invalid operands 2 and 2.0 to 'quo' (type int and float):
./in.cue:31:5
invalid operands *adt.Num and *adt.Num to 'mod' (type float and int):
invalid operands 1.0 and 1 to 'mod' (type float and int):
./in.cue:32:5

Result:
Expand Down Expand Up @@ -158,23 +158,23 @@ Result:
v3: (float){ 0.666666666666666666666667 }
v5: (int){ 0 }
e0: (_|_){
// [eval] invalid operands *adt.Num and *adt.String to '+' (type int and string):
// [eval] invalid operands 2 and "a" to '+' (type int and string):
// ./in.cue:23:5
}
e5: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'div' (type float and int):
// [eval] invalid operands 1.0 and 2 to 'div' (type float and int):
// ./in.cue:29:5
}
e6: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'rem' (type int and float):
// [eval] invalid operands 2 and 2.0 to 'rem' (type int and float):
// ./in.cue:30:5
}
e7: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'quo' (type int and float):
// [eval] invalid operands 2 and 2.0 to 'quo' (type int and float):
// ./in.cue:31:5
}
e8: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'mod' (type float and int):
// [eval] invalid operands 1.0 and 1 to 'mod' (type float and int):
// ./in.cue:32:5
}
}
32 changes: 16 additions & 16 deletions cue/testdata/basicrewrite/003_integer-specific_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,21 @@ me2: _|_ // invalid operation 2 mod 1.0 (mismatched types int and float)
}
-- out/eval --
Errors:
invalid operands *adt.Num and *adt.Num to 'quo' (type float and int):
invalid operands 2.0 and 1 to 'quo' (type float and int):
./in.cue:5:6
invalid operands *adt.Num and *adt.Num to 'quo' (type int and float):
invalid operands 2 and 1.0 to 'quo' (type int and float):
./in.cue:6:6
invalid operands *adt.Num and *adt.Num to 'rem' (type float and int):
invalid operands 2.0 and 1 to 'rem' (type float and int):
./in.cue:12:6
invalid operands *adt.Num and *adt.Num to 'rem' (type int and float):
invalid operands 2 and 1.0 to 'rem' (type int and float):
./in.cue:13:6
invalid operands *adt.Num and *adt.Num to 'div' (type float and int):
invalid operands 2.0 and 1 to 'div' (type float and int):
./in.cue:19:6
invalid operands *adt.Num and *adt.Num to 'div' (type int and float):
invalid operands 2 and 1.0 to 'div' (type int and float):
./in.cue:20:6
invalid operands *adt.Num and *adt.Num to 'mod' (type float and int):
invalid operands 2.0 and 1 to 'mod' (type float and int):
./in.cue:26:6
invalid operands *adt.Num and *adt.Num to 'mod' (type int and float):
invalid operands 2 and 1.0 to 'mod' (type int and float):
./in.cue:27:6

Result:
Expand All @@ -112,47 +112,47 @@ Result:
q3: (int){ -2 }
q4: (int){ 2 }
qe1: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'quo' (type float and int):
// [eval] invalid operands 2.0 and 1 to 'quo' (type float and int):
// ./in.cue:5:6
}
qe2: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'quo' (type int and float):
// [eval] invalid operands 2 and 1.0 to 'quo' (type int and float):
// ./in.cue:6:6
}
r1: (int){ 1 }
r2: (int){ 1 }
r3: (int){ -1 }
r4: (int){ -1 }
re1: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'rem' (type float and int):
// [eval] invalid operands 2.0 and 1 to 'rem' (type float and int):
// ./in.cue:12:6
}
re2: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'rem' (type int and float):
// [eval] invalid operands 2 and 1.0 to 'rem' (type int and float):
// ./in.cue:13:6
}
d1: (int){ 2 }
d2: (int){ -2 }
d3: (int){ -3 }
d4: (int){ 3 }
de1: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'div' (type float and int):
// [eval] invalid operands 2.0 and 1 to 'div' (type float and int):
// ./in.cue:19:6
}
de2: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'div' (type int and float):
// [eval] invalid operands 2 and 1.0 to 'div' (type int and float):
// ./in.cue:20:6
}
m1: (int){ 1 }
m2: (int){ 1 }
m3: (int){ 1 }
m4: (int){ 1 }
me1: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'mod' (type float and int):
// [eval] invalid operands 2.0 and 1 to 'mod' (type float and int):
// ./in.cue:26:6
}
me2: (_|_){
// [eval] invalid operands *adt.Num and *adt.Num to 'mod' (type int and float):
// [eval] invalid operands 2 and 1.0 to 'mod' (type int and float):
// ./in.cue:27:6
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/004_booleans.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ e: _|_ // conflicting values true and false
}
-- out/eval --
Errors:
incompatible values *adt.Bool and *adt.Bool
incompatible values false and true

Result:
(_|_){
// [eval]
t: (bool){ true }
f: (bool){ false }
e: (_|_){
// [eval] incompatible values *adt.Bool and *adt.Bool
// [eval] incompatible values false and true
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/005_boolean_arithmetic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ f: _|_ // conflicting values true and false
}
-- out/eval --
Errors:
incompatible values *adt.Bool and *adt.Bool
incompatible values false and true

Result:
(_|_){
Expand All @@ -41,6 +41,6 @@ Result:
d: (bool){ true }
e: (bool){ true }
f: (_|_){
// [eval] incompatible values *adt.Bool and *adt.Bool
// [eval] incompatible values false and true
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/006_basic_type.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ f: true
}
-- out/eval --
Errors:
invalid value *adt.BasicType (mismatched types float and int)
invalid value float (mismatched types float and int)

Result:
(_|_){
Expand All @@ -43,7 +43,7 @@ Result:
b: (int){ 1 }
c: (float){ 1.0 }
d: (_|_){
// [eval] invalid value *adt.BasicType (mismatched types float and int)
// [eval] invalid value float (mismatched types float and int)
}
e: (string){ "4" }
f: (bool){ true }
Expand Down
8 changes: 4 additions & 4 deletions cue/testdata/basicrewrite/007_strings_and_bytes.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ e1: _|_ // invalid operation 'b' + "c" (mismatched types bytes and string)
}
-- out/eval --
Errors:
invalid operands *adt.String and *adt.Bytes to '+' (type string and bytes):
invalid operands "a" and '' to '+' (type string and bytes):
./in.cue:10:5
invalid operands *adt.Bytes and *adt.String to '+' (type bytes and string):
invalid operands 'b' and "c" to '+' (type bytes and string):
./in.cue:11:5

Result:
Expand All @@ -56,11 +56,11 @@ Result:
b1: (bytes){ 'abcabcabc' }
b2: (bytes){ 'abcabc' }
e0: (_|_){
// [eval] invalid operands *adt.String and *adt.Bytes to '+' (type string and bytes):
// [eval] invalid operands "a" and '' to '+' (type string and bytes):
// ./in.cue:10:5
}
e1: (_|_){
// [eval] invalid operands *adt.Bytes and *adt.String to '+' (type bytes and string):
// [eval] invalid operands 'b' and "c" to '+' (type bytes and string):
// ./in.cue:11:5
}
}
10 changes: 5 additions & 5 deletions cue/testdata/basicrewrite/010_lists.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ e5: [1, 2, 4, _|_, // invalid value 8 (out of bound <=5)
-- out/eval --
Errors:
conflicting types
invalid value *adt.Num (out of bound *adt.BoundValue)
invalid value 8 (out of bound <=5)
invalid list index d (type string):
./in.cue:5:12
invalid negative index *adt.Num:
invalid negative index -1:
./in.cue:6:8

Result:
Expand All @@ -105,7 +105,7 @@ Result:
// ./in.cue:5:12
}
e3: (_|_){
// [eval] invalid negative index *adt.Num:
// [eval] invalid negative index -1:
// ./in.cue:6:8
}
e4: (_|_){
Expand All @@ -114,7 +114,7 @@ Result:
1: (int){ 2 }
2: (int){ 4 }
3: (_|_){
// [eval] invalid value *adt.Num (out of bound *adt.BoundValue)
// [eval] invalid value 8 (out of bound <=5)
}
}
e5: (_|_){
Expand All @@ -123,7 +123,7 @@ Result:
1: (int){ 2 }
2: (int){ 4 }
3: (_|_){
// [eval] invalid value *adt.Num (out of bound *adt.BoundValue)
// [eval] invalid value 8 (out of bound <=5)
}
}
}
14 changes: 7 additions & 7 deletions cue/testdata/basicrewrite/015_types.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ m: _|_ // invalid operation -false (- bool)
}
-- out/eval --
Errors:
invalid value *adt.BasicType (mismatched types string and int)
invalid value string (mismatched types string and int)
value can never become concrete:
./in.cue:7:5
invalid operation +*adt.UnaryExpr (+ bool):
invalid operation ++true (+ bool):
./in.cue:8:5
invalid operation -*adt.UnaryExpr (- bool):
invalid operation --false (- bool):
./in.cue:9:5

Result:
Expand All @@ -55,21 +55,21 @@ Result:
s: (string){ string }
t: (string){ "s" }
e: (_|_){
// [eval] invalid value *adt.BasicType (mismatched types string and int)
// [eval] invalid value string (mismatched types string and int)
}
e2: (_|_){
// [eval] invalid value *adt.BasicType (mismatched types string and int)
// [eval] invalid value string (mismatched types string and int)
}
b: (_|_){
// [eval] value can never become concrete:
// ./in.cue:7:5
}
p: (_|_){
// [eval] invalid operation +*adt.UnaryExpr (+ bool):
// [eval] invalid operation ++true (+ bool):
// ./in.cue:8:5
}
m: (_|_){
// [eval] invalid operation -*adt.UnaryExpr (- bool):
// [eval] invalid operation --false (- bool):
// ./in.cue:9:5
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/016_comparison.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ err: _|_ // invalid operation 2 == "s" (mismatched types int and string)
}
-- out/eval --
Errors:
invalid operands *adt.Num and *adt.String to '==' (type int and string):
invalid operands 2 and "s" to '==' (type int and string):
./in.cue:9:6

Result:
Expand All @@ -52,7 +52,7 @@ Result:
geq: (bool){ true }
seq: (bool){ true }
err: (_|_){
// [eval] invalid operands *adt.Num and *adt.String to '==' (type int and string):
// [eval] invalid operands 2 and "s" to '==' (type int and string):
// ./in.cue:9:6
}
}
4 changes: 2 additions & 2 deletions cue/testdata/basicrewrite/017_null.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ call: _|_ // cannot call non-function null (type null)
}
-- out/eval --
Errors:
cannot call non-function *adt.Null (type null):
cannot call non-function null (type null):
./in.cue:9:7

Result:
Expand All @@ -50,7 +50,7 @@ Result:
eq2: (bool){ false }
ne1: (bool){ true }
call: (_|_){
// [eval] cannot call non-function *adt.Null (type null):
// [eval] cannot call non-function null (type null):
// ./in.cue:9:7
}
}

0 comments on commit 7903529

Please sign in to comment.