From a79e558d825c5b777c95c5e098b01391ee36781e Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 15 Nov 2023 22:38:46 +0100 Subject: parser: parse struct type declarations Recursive structs and embedded structs are not supported yet. --- parser/interpreter_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'parser/interpreter_test.go') diff --git a/parser/interpreter_test.go b/parser/interpreter_test.go index 7ac1212..ac8dfc4 100644 --- a/parser/interpreter_test.go +++ b/parser/interpreter_test.go @@ -174,19 +174,23 @@ func TestConst(t *testing.T) { run(t, []etest{ {src: "const a = 1+2; a", res: "3"}, {src: "const a, b = 1, 2; a+b", res: "3"}, + {src: "const huge = 1 << 100; const four = huge >> 98; four", res: "4"}, {src: src0 + "c", res: "2"}, }) } func TestType(t *testing.T) { + src0 := `type( + I int + S string +) +` run(t, []etest{ {src: "type t int; var a t = 1; a", res: "1"}, {src: "type t = int; var a t = 1; a", res: "1"}, - {src: `type ( - I int - S string -); var s S = "xx"; s`, res: "xx"}, + {src: src0 + `var s S = "xx"; s`, res: "xx"}, + {src: "type T struct {a string; b, c int}; var t T; t", res: "{ 0 0}"}, }) } -- cgit v1.2.3