summaryrefslogtreecommitdiff
path: root/parser/interpreter_test.go
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2023-11-15 22:38:46 +0100
committerMarc Vertes <mvertes@free.fr>2023-11-15 22:38:46 +0100
commita79e558d825c5b777c95c5e098b01391ee36781e (patch)
tree977e5131eee46197a6e72377a168df23ca356948 /parser/interpreter_test.go
parenta4d7fb2da6a8390b818dae8d07391c7d76e365e9 (diff)
parser: parse struct type declarations
Recursive structs and embedded structs are not supported yet.
Diffstat (limited to 'parser/interpreter_test.go')
-rw-r--r--parser/interpreter_test.go12
1 files changed, 8 insertions, 4 deletions
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}"},
})
}