diff --git a/go.mod b/go.mod index c3b1cf68..60aa0246 100644 --- a/go.mod +++ b/go.mod @@ -125,7 +125,7 @@ require ( github.com/go-ruby-pagy/pagy v0.0.0-20260707193354-a84fe1d16a86 github.com/go-ruby-paper-trail/paper-trail v0.0.0-20260707193452-4e10f2b4d0b3 github.com/go-ruby-parquet/parquet v0.0.0-20260704170648-c7f0507946f7 - github.com/go-ruby-parser/parser v0.1.2 + github.com/go-ruby-parser/parser v0.1.3 github.com/go-ruby-pathname/pathname v0.0.0-20260629151955-d8d2c4e5f81b github.com/go-ruby-pg/pg v0.0.0-20260702135906-e5650264cc5d github.com/go-ruby-prawn/prawn v0.0.0-20260728194101-a5f2d786bf88 diff --git a/go.sum b/go.sum index 58173bd6..a0ceac2f 100644 --- a/go.sum +++ b/go.sum @@ -490,8 +490,8 @@ github.com/go-ruby-paper-trail/paper-trail v0.0.0-20260707193452-4e10f2b4d0b3 h1 github.com/go-ruby-paper-trail/paper-trail v0.0.0-20260707193452-4e10f2b4d0b3/go.mod h1:z370KNJcUH8n39yLdlT0Y1QvHukxjsq1XjGpIzvfqWE= github.com/go-ruby-parquet/parquet v0.0.0-20260704170648-c7f0507946f7 h1:kuL9coQlysvsIZXLzCfKZguDKvDwTibgJrLCx4jh5Ak= github.com/go-ruby-parquet/parquet v0.0.0-20260704170648-c7f0507946f7/go.mod h1:reJ/Dgyv5OWqVEERevwU1yX6N+CB5RfTQeGWGjmnOFo= -github.com/go-ruby-parser/parser v0.1.2 h1:XqXZaV2/8DeWFj6uqUyyVXYeC4fvUbrA1dBMiGh0q34= -github.com/go-ruby-parser/parser v0.1.2/go.mod h1:NRbX4dYcQ6CgcaSaMmu1dh95QuKGq+RdenUoWU73214= +github.com/go-ruby-parser/parser v0.1.3 h1:04YW8ytWnV7J8Q6PjOjfForJe/YDqzjJiJsMpvYjeUY= +github.com/go-ruby-parser/parser v0.1.3/go.mod h1:NRbX4dYcQ6CgcaSaMmu1dh95QuKGq+RdenUoWU73214= github.com/go-ruby-pathname/pathname v0.0.0-20260629151955-d8d2c4e5f81b h1:/ZN1eLOg0oH4wF8qmd6NOyB4ENYthx6wFwOpZiPhRIE= github.com/go-ruby-pathname/pathname v0.0.0-20260629151955-d8d2c4e5f81b/go.mod h1:IvW5q5Kyl5l3hrYwiHylOEmk5hpGSo7XqcmUXBHF5H0= github.com/go-ruby-pg/pg v0.0.0-20260702135906-e5650264cc5d h1:JKIZD+pJQ64/nla4DHdzMLnc4/v45MyYwnjACwS6dyM= diff --git a/run_test.go b/run_test.go index f63a848b..a90ac0ea 100644 --- a/run_test.go +++ b/run_test.go @@ -29,3 +29,21 @@ func TestRun(t *testing.T) { t.Fatalf("runtime error = %v, want one mentioning boom", err) } } + +// TestRunMultilineTernary exercises a ternary whose `?`/`:` and arms are split +// across lines (parser >= v0.1.3). The newline before the `:` used to fail to +// parse; each form below now parses and evaluates, matching MRI. +func TestRunMultilineTernary(t *testing.T) { + for _, tc := range []struct{ src, want string }{ + {"p (true ?\n 1 :\n 2)", "1\n"}, + {"p (false ?\n \"a\"\n: \"b\")", "\"b\"\n"}, + } { + var out bytes.Buffer + if err := ruby.Run(tc.src, &out); err != nil { + t.Fatalf("Run(%q): %v", tc.src, err) + } + if got := out.String(); got != tc.want { + t.Errorf("Run(%q) = %q, want %q", tc.src, got, tc.want) + } + } +}