diff options
author | EuAndreh <eu@euandre.org> | 2024-12-11 16:48:12 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-11 16:48:12 -0300 |
commit | 27b4729bd1a57740ea68e774d58d9cb3f45c5589 (patch) | |
tree | 152ff5686ade087e29e102cbbd39c0405cb63c02 /tests/unit/driver/parser/lac_test.go | |
parent | Consolidate packages spread across multiple files into single one (diff) | |
download | cotia-27b4729bd1a57740ea68e774d58d9cb3f45c5589.tar.gz cotia-27b4729bd1a57740ea68e774d58d9cb3f45c5589.tar.xz |
Do the same single file consolidation on tests
Diffstat (limited to 'tests/unit/driver/parser/lac_test.go')
-rw-r--r-- | tests/unit/driver/parser/lac_test.go | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/tests/unit/driver/parser/lac_test.go b/tests/unit/driver/parser/lac_test.go deleted file mode 100644 index c2368e8..0000000 --- a/tests/unit/driver/parser/lac_test.go +++ /dev/null @@ -1,120 +0,0 @@ -package parser - -import ( - "strings" - "testing" - - "urubu/grammar" - "urubu/spec/grammar/parser" -) - -func TestParserWithLAC(t *testing.T) { - specSrc := ` -#name test; - -s - : t t - ; -t - : c t - | d - ; - -c: 'c'; -d: 'd'; -` - - src := `ccd` - - actLogWithLAC := []string{ - "shift/c", - "shift/c", - "shift/d", - "miss", - } - - actLogWithoutLAC := []string{ - "shift/c", - "shift/c", - "shift/d", - "reduce/t", - "reduce/t", - "reduce/t", - "miss", - } - - ast, err := parser.Parse(strings.NewReader(specSrc)) - if err != nil { - t.Fatal(err) - } - - b := grammar.GrammarBuilder{ - AST: ast, - } - gram, _, err := b.Build() - if err != nil { - t.Fatal(err) - } - - t.Run("LAC is enabled", func(t *testing.T) { - semAct := &testSemAct{ - gram: gram, - } - - toks, err := NewTokenStream(gram, strings.NewReader(src)) - if err != nil { - t.Fatal(err) - } - - p, err := NewParser(toks, NewGrammar(gram), SemanticAction(semAct)) - if err != nil { - t.Fatal(err) - } - - err = p.Parse() - if err != nil { - t.Fatal(err) - } - - if len(semAct.actLog) != len(actLogWithLAC) { - t.Fatalf("unexpected action log; want: %+v, got: %+v", actLogWithLAC, semAct.actLog) - } - - for i, e := range actLogWithLAC { - if semAct.actLog[i] != e { - t.Fatalf("unexpected action log; want: %+v, got: %+v", actLogWithLAC, semAct.actLog) - } - } - }) - - t.Run("LAC is disabled", func(t *testing.T) { - semAct := &testSemAct{ - gram: gram, - } - - toks, err := NewTokenStream(gram, strings.NewReader(src)) - if err != nil { - t.Fatal(err) - } - - p, err := NewParser(toks, NewGrammar(gram), SemanticAction(semAct), DisableLAC()) - if err != nil { - t.Fatal(err) - } - - err = p.Parse() - if err != nil { - t.Fatal(err) - } - - if len(semAct.actLog) != len(actLogWithoutLAC) { - t.Fatalf("unexpected action log; want: %+v, got: %+v", actLogWithoutLAC, semAct.actLog) - } - - for i, e := range actLogWithoutLAC { - if semAct.actLog[i] != e { - t.Fatalf("unexpected action log; want: %+v, got: %+v", actLogWithoutLAC, semAct.actLog) - } - } - }) -} |