Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit ed72ea9

Browse files
committed
test(parser): fix weird cast
1 parent 07e4541 commit ed72ea9

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

parser/ast_test.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package parser
22

33
import (
4-
"fmt"
54
"github.com/planklang/goplank/lexer"
65
"github.com/planklang/goplank/parser/types"
76
"testing"
@@ -37,18 +36,21 @@ func TestParse(t *testing.T) {
3736
if arg.Type() != types.DefaultLiteralType {
3837
t.Errorf("Excepted %s, got %s", types.DefaultLiteralType, arg.Type())
3938
}
40-
fmt.Printf("%s %s\n", arg.Type(), arg.Value())
41-
p, ok := arg.Value().(types.Literal)
39+
p, ok := arg.Value().(string)
4240
if !ok {
4341
t.Errorf("Cannot convert %s to literal", arg.Value())
4442
}
45-
if p.Value() != "x" {
46-
t.Error("Expected x, got", p.Value())
43+
if p != "x" {
44+
t.Error("Expected x, got", p)
4745
}
4846
//TODO: check range
4947
if len(axis.Modifiers) != 0 {
5048
t.Error("Expected zero modifiers, got", len(axis.Modifiers))
5149
}
50+
if t.Failed() {
51+
println(tree)
52+
t.FailNow()
53+
}
5254

5355
lex, err = lexer.Lex("axis x 'Label'")
5456
if err != nil {
@@ -79,26 +81,30 @@ func TestParse(t *testing.T) {
7981
if arg1.Type() != types.DefaultLiteralType {
8082
t.Errorf("Excepted %s, got %s", types.DefaultLiteralType, arg1.Type())
8183
}
82-
p, ok = arg1.Value().(types.Literal)
84+
p, ok = arg1.Value().(string)
8385
if !ok {
84-
t.Errorf("Cannot convert %s to literal", arg1.Value())
86+
t.Errorf("Cannot convert %s to literal", arg1.Type())
8587
}
86-
if p.Value() != "x" {
87-
t.Error("Expected x, got", p.Value())
88+
if p != "x" {
89+
t.Error("Expected x, got", p)
8890
}
8991
arg2 := vs[1]
9092
if arg2.Type() != types.StringType {
9193
t.Errorf("Excepted %s, got %s", types.StringType, arg1.Type())
9294
}
93-
p2, ok := arg1.Value().(types.String)
95+
p2, ok := arg2.Value().(string)
9496
if !ok {
95-
t.Errorf("Cannot convert %s to literal", arg2.Value())
97+
t.Errorf("Cannot convert %s to string", arg2.Type())
9698
}
97-
if p2.Value() != "Label" {
98-
t.Error("Expected Label, got", p2.Value())
99+
if p2 != "Label" {
100+
t.Error("Expected Label, got", p2)
99101
}
100102
//TODO: check range
101103
if len(axis.Modifiers) != 0 {
102104
t.Error("Expected zero modifiers, got", len(axis.Modifiers))
103105
}
106+
if t.Failed() {
107+
println(tree.String())
108+
t.FailNow()
109+
}
104110
}

0 commit comments

Comments
 (0)