@@ -32,6 +32,65 @@ func TestBasicParsing(t *testing.T) {
3232 }
3333}
3434
35+ // TestParseTransaction tests the ParseTransaction entry point.
36+ func TestParseTransaction (t * testing.T ) {
37+ input := `(transaction (epoch (writes) (reads)))`
38+ result , err := lqp .ParseTransaction (input )
39+ if err != nil {
40+ t .Fatalf ("Failed to parse transaction: %v" , err )
41+ }
42+ if result == nil {
43+ t .Fatal ("ParseTransaction returned nil" )
44+ }
45+ if len (result .Epochs ) != 1 {
46+ t .Errorf ("Expected 1 epoch, got %d" , len (result .Epochs ))
47+ }
48+ }
49+
50+ // TestParseFragment tests the ParseFragment entry point.
51+ func TestParseFragment (t * testing.T ) {
52+ input := `(fragment :test_frag (def :my_rel ([x::INT] (relatom :my_rel x))))`
53+ result , err := lqp .ParseFragment (input )
54+ if err != nil {
55+ t .Fatalf ("Failed to parse fragment: %v" , err )
56+ }
57+ if result == nil {
58+ t .Fatal ("ParseFragment returned nil" )
59+ }
60+ }
61+
62+ // TestParseDelegatesToParseTransaction verifies Parse and ParseTransaction return equal results.
63+ func TestParseDelegatesToParseTransaction (t * testing.T ) {
64+ input := `(transaction (epoch (writes) (reads)))`
65+ r1 , err := lqp .Parse (input )
66+ if err != nil {
67+ t .Fatalf ("Parse failed: %v" , err )
68+ }
69+ r2 , err := lqp .ParseTransaction (input )
70+ if err != nil {
71+ t .Fatalf ("ParseTransaction failed: %v" , err )
72+ }
73+ if ! proto .Equal (r1 , r2 ) {
74+ t .Error ("Parse and ParseTransaction should return equal results" )
75+ }
76+ }
77+
78+ // TestParseFragmentRejectsTransaction verifies ParseFragment rejects transaction input.
79+ func TestParseFragmentRejectsTransaction (t * testing.T ) {
80+ _ , err := lqp .ParseFragment (`(transaction (epoch (writes) (reads)))` )
81+ if err == nil {
82+ t .Error ("ParseFragment should reject transaction input" )
83+ }
84+ }
85+
86+ // TestParseTransactionRejectsFragment verifies ParseTransaction rejects fragment input.
87+ func TestParseTransactionRejectsFragment (t * testing.T ) {
88+ _ , err := lqp .ParseTransaction (`(fragment :f (def :r ([x::INT] (relatom :r x))))` )
89+ if err == nil {
90+ t .Error ("ParseTransaction should reject fragment input" )
91+ }
92+ }
93+
3594// TestParseLQPFiles parses all LQP files and compares against binary snapshots.
3695func TestParseLQPFiles (t * testing.T ) {
3796 root := repoRoot (t )
0 commit comments