- 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)
50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
|
// All rights reserved.
|
|
|
|
// t_template_test.go
|
|
package expr
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestRelational(t *testing.T) {
|
|
section := "Relational"
|
|
inputs := []inputType{
|
|
/* 1 */ {`1 == 3-2`, true, nil},
|
|
/* 2 */ {`"a" == "a"`, true, nil},
|
|
/* 3 */ {`true == false`, false, nil},
|
|
/* 4 */ {`1.0 == 3.0-2`, true, nil},
|
|
/* 5 */ {`[1,2] == [2,1]`, false, nil},
|
|
/* 6 */ {`1 != 3-2`, false, nil},
|
|
/* 7 */ {`"a" != "a"`, false, nil},
|
|
/* 8 */ {`true != false`, true, nil},
|
|
/* 9 */ {`1.0 != 3.0-2`, false, nil},
|
|
/* 10 */ {`[1,2] != [2,1]`, true, nil},
|
|
/* 11 */ {`1|2 == 1|3`, false, nil},
|
|
/* 12 */ {`1|2 != 1|3`, true, nil},
|
|
/* 13 */ {`1|2 == 4|8`, true, nil},
|
|
/* 14 */ {`1 < 8`, true, nil},
|
|
/* 15 */ {`1 <= 8`, true, nil},
|
|
/* 16 */ {`"a" < "b"`, true, nil},
|
|
/* 17 */ {`"a" <= "b"`, true, nil},
|
|
/* 18 */ {`1.0 < 8`, true, nil},
|
|
/* 19 */ {`1.0 <= 8`, true, nil},
|
|
/* 20 */ {`1.0 <= 1.0`, true, nil},
|
|
/* 21 */ {`1.0 == 1`, true, nil},
|
|
/* 22 */ {`1|2 < 1|3`, false, nil},
|
|
/* 23 */ {`1|2 <= 1|3`, false, nil},
|
|
/* 24 */ {`1|2 > 1|3`, true, nil},
|
|
/* 25 */ {`1|2 >= 1|3`, true, nil},
|
|
/* 26 */ {`[1,2,3] > [2]`, true, nil},
|
|
/* 27 */ {`[1,2,3] > [9]`, false, nil},
|
|
/* 28 */ {`[1,2,3] >= [6]`, false, nil},
|
|
/* 29 */ {`[1,2,3] >= [2,6]`, false, nil},
|
|
}
|
|
|
|
// t.Setenv("EXPR_PATH", ".")
|
|
|
|
// parserTestSpec(t, section, inputs, 27)
|
|
parserTest(t, section, inputs)
|
|
}
|