summaryrefslogtreecommitdiff
path: root/usr/austin/eval/expr_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'usr/austin/eval/expr_test.go')
-rw-r--r--usr/austin/eval/expr_test.go198
1 files changed, 99 insertions, 99 deletions
diff --git a/usr/austin/eval/expr_test.go b/usr/austin/eval/expr_test.go
index 2b2dd9d4f..ea11cf69d 100644
--- a/usr/austin/eval/expr_test.go
+++ b/usr/austin/eval/expr_test.go
@@ -26,19 +26,19 @@ var hugeInteger = bignum.Int(1).Shl(64);
var exprTests = []test {
Val("i", 1),
- EErr("zzz", undefined),
+ CErr("zzz", undefined),
// TODO(austin) Test variable in constant context
- //EErr("t", typeAsExpr),
+ //CErr("t", typeAsExpr),
Val("'a'", bignum.Int('a')),
Val("'\\uffff'", bignum.Int('\uffff')),
Val("'\\n'", bignum.Int('\n')),
- EErr("''+x", badCharLit),
+ CErr("''+x", badCharLit),
// Produces two parse errors
- //EErr("'''", ""),
- EErr("'\n'", badCharLit),
- EErr("'\\z'", illegalEscape),
- EErr("'ab'", badCharLit),
+ //CErr("'''", ""),
+ CErr("'\n'", badCharLit),
+ CErr("'\\z'", illegalEscape),
+ CErr("'ab'", badCharLit),
Val("1.0", bignum.Rat(1, 1)),
Val("1.", bignum.Rat(1, 1)),
@@ -48,11 +48,11 @@ var exprTests = []test {
Val("\"abc\"", "abc"),
Val("\"\"", ""),
Val("\"\\n\\\"\"", "\n\""),
- EErr("\"\\z\"", illegalEscape),
- EErr("\"abc", "string not terminated"),
+ CErr("\"\\z\"", illegalEscape),
+ CErr("\"abc", "string not terminated"),
Val("\"abc\" \"def\"", "abcdef"),
- EErr("\"abc\" \"\\z\"", illegalEscape),
+ CErr("\"abc\" \"\\z\"", illegalEscape),
Val("(i)", 1),
@@ -61,56 +61,56 @@ var exprTests = []test {
Val("ai[1]", 2),
Val("ai[i]", 2),
Val("ai[u]", 2),
- EErr("ai[f]", opTypes),
- EErr("ai[0][0]", opTypes),
- EErr("ai[2]", "index 2 exceeds"),
- EErr("ai[1+1]", "index 2 exceeds"),
- EErr("ai[-1]", "negative index"),
- ERTErr("ai[i+i]", "index 2 exceeds"),
- ERTErr("ai[-i]", "negative index"),
- EErr("i[0]", opTypes),
- EErr("f[0]", opTypes),
+ CErr("ai[f]", opTypes),
+ CErr("ai[0][0]", opTypes),
+ CErr("ai[2]", "index 2 exceeds"),
+ CErr("ai[1+1]", "index 2 exceeds"),
+ CErr("ai[-1]", "negative index"),
+ RErr("ai[i+i]", "index 2 exceeds"),
+ RErr("ai[-i]", "negative index"),
+ CErr("i[0]", opTypes),
+ CErr("f[0]", opTypes),
Val("aai[0][0]", 1),
Val("aai[1][1]", 4),
- EErr("aai[2][0]", "index 2 exceeds"),
- EErr("aai[0][2]", "index 2 exceeds"),
+ CErr("aai[2][0]", "index 2 exceeds"),
+ CErr("aai[0][2]", "index 2 exceeds"),
Val("sli[0]", 1),
Val("sli[1]", 2),
- EErr("sli[-1]", "negative index"),
- ERTErr("sli[-i]", "negative index"),
- ERTErr("sli[2]", "index 2 exceeds"),
+ CErr("sli[-1]", "negative index"),
+ RErr("sli[-i]", "negative index"),
+ RErr("sli[2]", "index 2 exceeds"),
Val("s[0]", uint8('a')),
Val("s[1]", uint8('b')),
- EErr("s[-1]", "negative index"),
- ERTErr("s[-i]", "negative index"),
- ERTErr("s[3]", "index 3 exceeds"),
-
- EErr("1(2)", "cannot call"),
- EErr("fn(1,2)", "too many"),
- EErr("fn()", "not enough"),
- EErr("fn(true)", opTypes),
- EErr("fn(true)", "function call"),
+ CErr("s[-1]", "negative index"),
+ RErr("s[-i]", "negative index"),
+ RErr("s[3]", "index 3 exceeds"),
+
+ CErr("1(2)", "cannot call"),
+ CErr("fn(1,2)", "too many"),
+ CErr("fn()", "not enough"),
+ CErr("fn(true)", opTypes),
+ CErr("fn(true)", "function call"),
// Single argument functions don't say which argument.
- //EErr("fn(true)", "argument 1"),
+ //CErr("fn(true)", "argument 1"),
Val("fn(1)", 2),
Val("fn(1.0)", 2),
- EErr("fn(1.5)", constantTruncated),
+ CErr("fn(1.5)", constantTruncated),
Val("fn(i)", 2),
- EErr("fn(u)", opTypes),
+ CErr("fn(u)", opTypes),
- EErr("void()+2", opTypes),
- EErr("oneTwo()+2", opTypes),
+ CErr("void()+2", opTypes),
+ CErr("oneTwo()+2", opTypes),
Val("cap(ai)", 2),
Val("cap(&ai)", 2),
Val("cap(aai)", 2),
Val("cap(sli)", 3),
- EErr("cap(0)", opTypes),
- EErr("cap(i)", opTypes),
- EErr("cap(s)", opTypes),
+ CErr("cap(0)", opTypes),
+ CErr("cap(i)", opTypes),
+ CErr("cap(s)", opTypes),
Val("len(s)", 3),
Val("len(ai)", 2),
@@ -118,36 +118,36 @@ var exprTests = []test {
Val("len(aai)", 2),
Val("len(sli)", 2),
// TODO(austin) Test len of map
- EErr("len(0)", opTypes),
- EErr("len(i)", opTypes),
+ CErr("len(0)", opTypes),
+ CErr("len(i)", opTypes),
- EErr("*i", opTypes),
+ CErr("*i", opTypes),
Val("*&i", 1),
Val("*&(i)", 1),
- EErr("&1", badAddrOf),
- EErr("&c", badAddrOf),
+ CErr("&1", badAddrOf),
+ CErr("&c", badAddrOf),
Val("*(&ai[0])", 1),
Val("+1", bignum.Int(+1)),
Val("+1.0", bignum.Rat(1, 1)),
- EErr("+\"x\"", opTypes),
+ CErr("+\"x\"", opTypes),
Val("-42", bignum.Int(-42)),
Val("-i", -1),
Val("-f", -1.0),
// 6g bug?
//Val("-(f-1)", -0.0),
- EErr("-\"x\"", opTypes),
+ CErr("-\"x\"", opTypes),
// TODO(austin) Test unary !
Val("^2", bignum.Int(^2)),
Val("^(-2)", bignum.Int(^(-2))),
- EErr("^2.0", opTypes),
- EErr("^2.5", opTypes),
+ CErr("^2.0", opTypes),
+ CErr("^2.5", opTypes),
Val("^i", ^1),
Val("^u", ^uint(1)),
- EErr("^f", opTypes),
+ CErr("^f", opTypes),
Val("1+i", 2),
Val("1+u", uint(2)),
@@ -157,8 +157,8 @@ var exprTests = []test {
Val("1+f", 2.0),
Val("1.0+1", bignum.Rat(2, 1)),
Val("\"abc\" + \"def\"", "abcdef"),
- EErr("i+u", opTypes),
- EErr("-1+u", constantUnderflows),
+ CErr("i+u", opTypes),
+ CErr("-1+u", constantUnderflows),
// TODO(austin) Test named types
Val("2-1", bignum.Int(1)),
@@ -170,14 +170,14 @@ var exprTests = []test {
Val("2*i", 2),
Val("3/2", bignum.Int(1)),
Val("3/i", 3),
- EErr("1/0", divByZero),
- EErr("1.0/0", divByZero),
- ERTErr("i/0", divByZero),
+ CErr("1/0", divByZero),
+ CErr("1.0/0", divByZero),
+ RErr("i/0", divByZero),
Val("3%2", bignum.Int(1)),
Val("i%2", 1),
- EErr("3%0", divByZero),
- EErr("3.0%0", opTypes),
- ERTErr("i%0", divByZero),
+ CErr("3%0", divByZero),
+ CErr("3.0%0", opTypes),
+ RErr("i%0", divByZero),
// Examples from "Arithmetic operators"
Val("5/3", bignum.Int(1)),
@@ -222,56 +222,56 @@ var exprTests = []test {
// fractional float, ideal non-fractional float, int, uint,
// and float.
Val("2<<2", bignum.Int(2<<2)),
- EErr("2<<(-1)", constantUnderflows),
- EErr("2<<0x10000000000000000", constantOverflows),
- EErr("2<<2.5", constantTruncated),
+ CErr("2<<(-1)", constantUnderflows),
+ CErr("2<<0x10000000000000000", constantOverflows),
+ CErr("2<<2.5", constantTruncated),
Val("2<<2.0", bignum.Int(2<<2.0)),
- EErr("2<<i", mustBeUnsigned),
+ CErr("2<<i", mustBeUnsigned),
Val("2<<u", 2<<1),
- EErr("2<<f", opTypes),
+ CErr("2<<f", opTypes),
Val("-2<<2", bignum.Int(-2<<2)),
- EErr("-2<<(-1)", constantUnderflows),
- EErr("-2<<0x10000000000000000", constantOverflows),
- EErr("-2<<2.5", constantTruncated),
+ CErr("-2<<(-1)", constantUnderflows),
+ CErr("-2<<0x10000000000000000", constantOverflows),
+ CErr("-2<<2.5", constantTruncated),
Val("-2<<2.0", bignum.Int(-2<<2.0)),
- EErr("-2<<i", mustBeUnsigned),
+ CErr("-2<<i", mustBeUnsigned),
Val("-2<<u", -2<<1),
- EErr("-2<<f", opTypes),
+ CErr("-2<<f", opTypes),
Val("0x10000000000000000<<2", hugeInteger.Shl(2)),
- EErr("0x10000000000000000<<(-1)", constantUnderflows),
- EErr("0x10000000000000000<<0x10000000000000000", constantOverflows),
- EErr("0x10000000000000000<<2.5", constantTruncated),
+ CErr("0x10000000000000000<<(-1)", constantUnderflows),
+ CErr("0x10000000000000000<<0x10000000000000000", constantOverflows),
+ CErr("0x10000000000000000<<2.5", constantTruncated),
Val("0x10000000000000000<<2.0", hugeInteger.Shl(2)),
- EErr("0x10000000000000000<<i", mustBeUnsigned),
- EErr("0x10000000000000000<<u", constantOverflows),
- EErr("0x10000000000000000<<f", opTypes),
+ CErr("0x10000000000000000<<i", mustBeUnsigned),
+ CErr("0x10000000000000000<<u", constantOverflows),
+ CErr("0x10000000000000000<<f", opTypes),
- EErr("2.5<<2", opTypes),
- EErr("2.0<<2", opTypes),
+ CErr("2.5<<2", opTypes),
+ CErr("2.0<<2", opTypes),
Val("i<<2", 1<<2),
- EErr("i<<(-1)", constantUnderflows),
- EErr("i<<0x10000000000000000", constantOverflows),
- EErr("i<<2.5", constantTruncated),
+ CErr("i<<(-1)", constantUnderflows),
+ CErr("i<<0x10000000000000000", constantOverflows),
+ CErr("i<<2.5", constantTruncated),
Val("i<<2.0", 1<<2),
- EErr("i<<i", mustBeUnsigned),
+ CErr("i<<i", mustBeUnsigned),
Val("i<<u", 1<<1),
- EErr("i<<f", opTypes),
+ CErr("i<<f", opTypes),
Val("i<<u", 1<<1),
Val("u<<2", uint(1<<2)),
- EErr("u<<(-1)", constantUnderflows),
- EErr("u<<0x10000000000000000", constantOverflows),
- EErr("u<<2.5", constantTruncated),
+ CErr("u<<(-1)", constantUnderflows),
+ CErr("u<<0x10000000000000000", constantOverflows),
+ CErr("u<<2.5", constantTruncated),
Val("u<<2.0", uint(1<<2)),
- EErr("u<<i", mustBeUnsigned),
+ CErr("u<<i", mustBeUnsigned),
Val("u<<u", uint(1<<1)),
- EErr("u<<f", opTypes),
+ CErr("u<<f", opTypes),
Val("u<<u", uint(1<<1)),
- EErr("f<<2", opTypes),
+ CErr("f<<2", opTypes),
// <, <=, >, >=
Val("1<2", 1<2),
@@ -298,11 +298,11 @@ var exprTests = []test {
Val("s>\"ac\"", false),
Val("s>=\"abc\"", true),
- EErr("i<u", opTypes),
- EErr("i<f", opTypes),
- EErr("i<s", opTypes),
- EErr("&i<&i", opTypes),
- EErr("ai<ai", opTypes),
+ CErr("i<u", opTypes),
+ CErr("i<f", opTypes),
+ CErr("i<s", opTypes),
+ CErr("&i<&i", opTypes),
+ CErr("ai<ai", opTypes),
// ==, !=
Val("1==1", true),
@@ -332,12 +332,12 @@ var exprTests = []test {
Val("fn==fn", true),
Val("fn==func(int)int{return 0}", false),
- EErr("i==u", opTypes),
- EErr("i==f", opTypes),
- EErr("&i==&f", opTypes),
- EErr("ai==ai", opTypes),
- EErr("t==t", opTypes),
- EErr("fn==oneTwo", opTypes),
+ CErr("i==u", opTypes),
+ CErr("i==f", opTypes),
+ CErr("&i==&f", opTypes),
+ CErr("ai==ai", opTypes),
+ CErr("t==t", opTypes),
+ CErr("fn==oneTwo", opTypes),
}
func TestExpr(t *testing.T) {