Skip to content

Commit

Permalink
Added support for empty test inputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Dec 18, 2023
1 parent bb3487f commit 0310e2f
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions compiler/testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func testFile(t *testing.T, compiler *Compiler, file string) {
var prof *os.File
var lsb bool
base := 10
var testNumber int

for _, annotation := range main.Annotations {
ann := strings.TrimSpace(annotation)
Expand Down Expand Up @@ -115,15 +116,18 @@ func testFile(t *testing.T, compiler *Compiler, file string) {
}
var iv []string
for _, input := range strings.Split(part, ",") {
v := new(big.Int)
if base == 16 && lsb {
input = reverse(input)
}

_, ok := v.SetString(input, 0)
if !ok {
t.Errorf("%s: invalid argument '%s'", file, input)
return
var v *big.Int
if input != "_" {
v = new(big.Int)
if base == 16 && lsb {
input = reverse(input)
}

_, ok := v.SetString(input, 0)
if !ok {
t.Errorf("%s: invalid argument '%s'", file, input)
return
}
}
if sep {
outputs = append(outputs, v)
Expand Down Expand Up @@ -169,14 +173,15 @@ func testFile(t *testing.T, compiler *Compiler, file string) {
if out.Type.Type == types.TArray &&
out.Type.ElementType.Type == types.TUint &&
out.Type.ElementType.Bits == 8 {
t.Errorf("%s: result %d mismatch: got %x, expected %x",
file, idx, rr, re)
t.Errorf("%s/%v: result %d mismatch: got %x, expected %x",
file, testNumber, idx, rr, re)
} else {
t.Errorf("%s: result %d mismatch: got %v, expected %v",
file, idx, rr, re)
t.Errorf("%s/%v: result %d mismatch: got %v, expected %v",
file, testNumber, idx, rr, re)
}
}
}
testNumber++
}
if cpuprof {
pprof.StopCPUProfile()
Expand Down

0 comments on commit 0310e2f

Please sign in to comment.