|
| 1 | +// Copyright 2017 The go-interpreter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
1 | 5 | package wast
|
2 | 6 |
|
3 | 7 | import (
|
4 |
| - "flag" |
5 | 8 | "fmt"
|
6 | 9 | "testing"
|
7 | 10 | )
|
8 | 11 |
|
9 |
| -var wastFile = flag.String("wast-file", "", "the wast file to test") |
10 |
| - |
11 | 12 | func TestScanner(t *testing.T) {
|
12 |
| - if *wastFile == "" { |
13 |
| - t.Errorf("error: no input file") |
14 |
| - } |
| 13 | + for _, fname := range []string{ |
| 14 | + // "../exec/testdata/spec/address.wast", |
| 15 | + "../exec/testdata/spec/block.wast", |
| 16 | + "../exec/testdata/spec/break-drop.wast", |
| 17 | + "../exec/testdata/spec/br_if.wast", |
| 18 | + // "../exec/testdata/spec/br_table.wast", |
| 19 | + // "../exec/testdata/spec/br.wast", |
| 20 | + "../exec/testdata/spec/call_indirect.wast", |
| 21 | + // "../exec/testdata/spec/endianness.wast", |
| 22 | + "../exec/testdata/spec/fac.wast", |
| 23 | + "../exec/testdata/spec/forward.wast", |
| 24 | + "../exec/testdata/spec/get_local.wast", |
| 25 | + "../exec/testdata/spec/globals.wast", |
| 26 | + "../exec/testdata/spec/if.wast", |
| 27 | + // "../exec/testdata/spec/loop.wast", |
| 28 | + "../exec/testdata/spec/memory_redundancy.wast", |
| 29 | + "../exec/testdata/spec/names.wast", |
| 30 | + "../exec/testdata/spec/nop.wast", |
| 31 | + "../exec/testdata/spec/resizing.wast", |
| 32 | + // "../exec/testdata/spec/return.wast", |
| 33 | + "../exec/testdata/spec/select.wast", |
| 34 | + "../exec/testdata/spec/switch.wast", |
| 35 | + "../exec/testdata/spec/tee_local.wast", |
| 36 | + "../exec/testdata/spec/traps_int_div.wast", |
| 37 | + "../exec/testdata/spec/traps_int_rem.wast", |
| 38 | + // "../exec/testdata/spec/traps_mem.wast", |
| 39 | + "../exec/testdata/spec/unwind.wast", |
| 40 | + } { |
| 41 | + t.Run(fname, func(t *testing.T) { |
15 | 42 |
|
16 |
| - s := NewScanner(*wastFile) |
17 |
| - if len(s.Errors) > 0 { |
18 |
| - fmt.Println(s.Errors[0]) |
19 |
| - return |
20 |
| - } |
| 43 | + s := NewScanner(fname) |
| 44 | + if len(s.Errors) > 0 { |
| 45 | + fmt.Println(s.Errors[0]) |
| 46 | + return |
| 47 | + } |
21 | 48 |
|
22 |
| - var tok *Token |
23 |
| - tok = s.Next() |
24 |
| - for tok.Kind != EOF { |
25 |
| - fmt.Printf("%d:%d %s\n", tok.Line, tok.Column, tok.String()) |
26 |
| - tok = s.Next() |
27 |
| - } |
28 |
| - fmt.Printf("%d:%d %s\n", tok.Line, tok.Column, tok.String()) |
| 49 | + var tok *Token |
| 50 | + tok = s.Next() |
| 51 | + for tok.Kind != EOF { |
| 52 | + fmt.Printf("%d:%d %s\n", tok.Line, tok.Column, tok.String()) |
| 53 | + tok = s.Next() |
| 54 | + } |
| 55 | + fmt.Printf("%d:%d %s\n", tok.Line, tok.Column, tok.String()) |
29 | 56 |
|
30 |
| - for _, err := range s.Errors { |
31 |
| - fmt.Print(err) |
32 |
| - } |
| 57 | + for _, err := range s.Errors { |
| 58 | + fmt.Print(err) |
| 59 | + } |
33 | 60 |
|
34 |
| - if len(s.Errors) > 0 { |
35 |
| - t.Errorf("wast: failed with %d errors", len(s.Errors)) |
| 61 | + if len(s.Errors) > 0 { |
| 62 | + t.Errorf("wast: failed with %d errors", len(s.Errors)) |
| 63 | + } |
| 64 | + }) |
36 | 65 | }
|
37 | 66 | }
|
0 commit comments