From 130273179353424f09517047157273a98bbeaee6 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 18 Oct 2023 01:33:22 -0400 Subject: [PATCH] Updated analyzer tests to account for lexer changes --- analyzer/assignment_test.go | 5 +++-- analyzer/cast_test.go | 28 ++++++++++++++-------------- analyzer/function_test.go | 4 ++-- analyzer/name_test.go | 32 +------------------------------- analyzer/type_test.go | 20 ++++++-------------- 5 files changed, 26 insertions(+), 63 deletions(-) diff --git a/analyzer/assignment_test.go b/analyzer/assignment_test.go index f48d541..f2b29cd 100644 --- a/analyzer/assignment_test.go +++ b/analyzer/assignment_test.go @@ -201,7 +201,7 @@ testString (test, Bird: ([fly distance:F64] [land]) BlueJay: Int BlueJay::[fly distance:F64] = { } -BlueJay::[fly land] = { } +BlueJay::[land] = { } [main] = { a:BlueJay b:Bird = [@a] @@ -224,7 +224,8 @@ B:([g]:Int) d:Int = { a:F64 b } e:Byte = [f] g:(x:Int y:(w:F64 z:F64)) = (x: 1 y: (w: 1.2 z: 78.5)) - h:F64 = g.x.z + gx:(w:F64 z:F64) = g.x + h:F64 = gx.z i:A j:Int = [i::g] k:B = i diff --git a/analyzer/cast_test.go b/analyzer/cast_test.go index 9c92aff..f5b0604 100644 --- a/analyzer/cast_test.go +++ b/analyzer/cast_test.go @@ -6,7 +6,7 @@ func TestCastErrIntPointer (test *testing.T) { testStringErr (test, "cannot convert from *Int to Int", 2, 14, ` -[main]:Int = [~ [@ a:Int] Int] +[main]:Int = [~ Int [@ a:Int]] `) } @@ -14,7 +14,7 @@ func TestCastErrIntStruct (test *testing.T) { testStringErr (test, "cannot convert from (x:Int y:Int) to Int", 2, 14, ` -[main]:Int = [~ a:(x:Int y:Int) Int] +[main]:Int = [~ Int a:(x:Int y:Int)] `) } @@ -22,7 +22,7 @@ func TestCastErrIntArray (test *testing.T) { testStringErr (test, "cannot convert from 5:Int to Int", 2, 14, ` -[main]:Int = [~ a:5:Int Int] +[main]:Int = [~ Int a:5:Int] `) } @@ -30,7 +30,7 @@ func TestCastErrIntSlice (test *testing.T) { testStringErr (test, "cannot convert from *:Int to Int", 2, 14, ` -[main]:Int = [~ a:*:Int Int] +[main]:Int = [~ Int a:*:Int] `) } @@ -38,7 +38,7 @@ func TestCastErrPointerInt (test *testing.T) { testStringErr (test, "cannot convert from Int to *Int", 2, 15, ` -[main]:*Int = [~ [@ a:Int] *Int] +[main]:*Int = [~ *Int [@ a:Int]] `) } @@ -46,7 +46,7 @@ func TestCastErrStructInt (test *testing.T) { testStringErr (test, "cannot convert from Int to (x:Int y:Int)", 2, 24, ` -[main]:(x:Int y:Int) = [~ a:Int (x:Int y:Int)] +[main]:(x:Int y:Int) = [~ (x:Int y:Int) a:Int] `) } @@ -54,7 +54,7 @@ func TestCastErrArrayInt (test *testing.T) { testStringErr (test, "cannot convert from Int to 5:Int", 2, 13, ` -[main]:Int = [~ a:5:Int Int] +[main]:Int = [~ Int a:5:Int] `) } @@ -62,7 +62,7 @@ func TestCastErrSliceInt (test *testing.T) { testStringErr (test, "cannot convert from Int to *:Int", 2, 16, ` -[main]:*:Int = [~ a:Int *:Int] +[main]:*:Int = [~ *:Int a:Int] `) } @@ -72,16 +72,16 @@ testString (test, Bird: ([fly distance:F64] [land]) BlueJay: Int BlueJay::[fly distance:F64] = { } -BlueJay::[fly land] = { } +BlueJay::[land] = { } IntDerived: Int [main] = { a:IntDerived = 5 - b:Int [~ [~ [~ a Byte] F64] Int] - c:Int [~~ [~~ [~~ a Byte] F64] Int] + b:Int [~ Int [~ F64 [~ Byte a]]] + c:Int [~~ Int [~~ F64 [~~ Byte a]]] d:(x:Int y:Int) = (x: 1 y: 2) - e:(z:Int a:Int) = [~~ d (z:Int a:Int)] - f:Bird = [@ [~~ 0 BlueJay]] - g:*:Int = (~ h:5:Int *:int) + e:(z:Int a:Int) = [~~ (z:Int a:Int) d] + f:Bird = [@ [~~ BlueJay 0]] + g:*:Int = [~ *:Int h:5:Int] } `) } diff --git a/analyzer/function_test.go b/analyzer/function_test.go index 3052d2b..6be4b17 100644 --- a/analyzer/function_test.go +++ b/analyzer/function_test.go @@ -7,14 +7,14 @@ testStringErr (test, "hello already declared at stream0.fspl:2:1", 3, 1, ` [hello] = { } -[world] = { } +[hello] = { } `) } func TestFunctionUnique (test *testing.T) { testString (test, ` -hello: *Int +[hello] = { } [world] = { } `) } diff --git a/analyzer/name_test.go b/analyzer/name_test.go index 01266c1..dd53a26 100644 --- a/analyzer/name_test.go +++ b/analyzer/name_test.go @@ -39,20 +39,10 @@ testStringErr (test, `) } -func TestVariableUniqueErrShadowBuiltin (test *testing.T) { -testStringErr (test, -"cannot shadow builtin false ", 3, 2, -` -[main] = { - false:Bool = true -} -`) -} - func TestVariableUnique (test *testing.T) { testString (test, ` -x: Int +[x] = { } [y] = { } [main x:Int] = { x:Int @@ -66,17 +56,6 @@ x: Int `) } -func TestVariableNameErrType (test *testing.T) { -testStringErr (test, -"named type example cannot be used as location expression", 4, 2, -` -example: Int -[main] = { - example = 5 -} -`) -} - func TestVariableNameErrFunction (test *testing.T) { testStringErr (test, "function example cannot be used as location expression", 4, 2, @@ -131,15 +110,6 @@ testString (test, `) } -func TestFunctionNameErrType (test *testing.T) { -testStringErr (test, -"cannot call named type example", 3, 3, -` -example: Int -[main] = [example] -`) -} - func TestFunctionNameErrVar (test *testing.T) { testStringErr (test, "cannot call example:Int", 4, 3, diff --git a/analyzer/type_test.go b/analyzer/type_test.go index f01f569..d941a4d 100644 --- a/analyzer/type_test.go +++ b/analyzer/type_test.go @@ -4,18 +4,10 @@ import "testing" func TestTypedefUniqueErr (test *testing.T) { testStringErr (test, -"hello already declared at stream0.fspl:2:1", 3, 1, +"Hello already declared at stream0.fspl:2:1", 3, 1, ` -hello: *Int -hello: (x:Int y:Int) -`) -} - -func TestTypedefUniqueErrShadowReservedConst (test *testing.T) { -testStringErr (test, -"cannot shadow builtin true", 2, 1, -` -true: Int +Hello: *Int +Hello: (x:Int y:Int) `) } @@ -38,8 +30,8 @@ String: Int func TestTypedefUnique (test *testing.T) { testString (test, ` -hello: *Int -world: (x:Int y:Int) +Hello: *Int +World: (x:Int y:Int) `) } @@ -66,7 +58,7 @@ func TestTypeNamedErrMissing (test *testing.T) { testStringErr (test, "no type named Missing", 2, 10, ` -present: Missing +Present: Missing `) }