A lot of changes. Main ones are:

- fraction type renamed as FractionType and moved from operator-fraction.go to fraction-type.go
- ListType moved from operator-list.go to list-type.go
- all test file were renamed adding the "t_" prefix
- defined a test template in file t_temple_test.go
- new test file t_relational_test.go where relational tests are collected
- lists can now compared as set using operators <, <=, >, and >= (IMPORTANT: here = menas same content, not same list)
This commit is contained in:
2024-05-28 07:26:05 +02:00
parent 78cbb7b36f
commit 3736214c5a
25 changed files with 722 additions and 554 deletions
+44
View File
@@ -0,0 +1,44 @@
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// t_term_test.go
package expr
import (
"testing"
)
func TestString(t *testing.T) {
tk1 := NewValueToken(0, 0, SymInteger, "100", 100)
tk2 := NewToken(0, 0, SymPlus, "+")
tk3 := NewValueToken(0, 0, SymInteger, "50", 500)
tree := NewAst()
if gotErr := tree.addTokens(tk1, tk2, tk3); gotErr == nil {
t.Log("Tree:", tree)
} else {
t.Errorf("err: got <%v>, want <nil>", gotErr)
}
}
func TestGetRoom(t *testing.T) {
tk1 := NewValueToken(0, 0, SymInteger, "100", 100)
tree := NewAst()
if gotErr := tree.addTokens(tk1); gotErr == nil {
t.Log("Tree-root room:", tree.root.getRoom())
} else {
t.Errorf("err: got <%v>, want <nil>", gotErr)
}
}
func TestGetChildrenCount(t *testing.T) {
tk1 := NewValueToken(0, 0, SymInteger, "100", 100)
tree := NewAst()
if gotErr := tree.addTokens(tk1); gotErr == nil {
t.Log("Tree-root children count:", tree.root.getChildrenCount())
} else {
t.Errorf("err: got <%v>, want <nil>", gotErr)
}
}