diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-28 09:51:16 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-03-28 12:04:35 -0400 |
| commit | fcc06fa82ab6f3916d8d9202c47db4fae48137dd (patch) | |
| tree | c84e756b2e85218983d2304a13f722670581a208 /test | |
| parent | 97b2cc34359968459a6eba2ac166f3650adf47be (diff) | |
[ruby/prism] CLI -x flag
https://github.com/ruby/prism/commit/2068e3c30a
Diffstat (limited to 'test')
| -rw-r--r-- | test/prism/command_line_test.rb | 23 | ||||
| -rw-r--r-- | test/prism/ruby_api_test.rb | 15 |
2 files changed, 23 insertions, 15 deletions
diff --git a/test/prism/command_line_test.rb b/test/prism/command_line_test.rb index 57ab0dee45..96ceb2da38 100644 --- a/test/prism/command_line_test.rb +++ b/test/prism/command_line_test.rb @@ -65,5 +65,28 @@ module Prism result = Prism.parse("1 if 2..3", command_line: "e") assert_equal 0, result.warnings.length end + + def test_command_line_x_implicit + result = Prism.parse(<<~RUBY) + #!/bin/bash + exit 1 + + #!/usr/bin/env ruby + 1 + RUBY + + assert_kind_of IntegerNode, result.value.statements.body.first + end + + def test_command_line_x_explicit + result = Prism.parse(<<~RUBY, command_line: "x") + exit 1 + + #!/usr/bin/env ruby + 1 + RUBY + + assert_kind_of IntegerNode, result.value.statements.body.first + end end end diff --git a/test/prism/ruby_api_test.rb b/test/prism/ruby_api_test.rb index 4153a69ad7..49296117bf 100644 --- a/test/prism/ruby_api_test.rb +++ b/test/prism/ruby_api_test.rb @@ -233,21 +233,6 @@ module Prism assert_equal 16, base[parse_expression("0x1")] end - def test_offset - source = <<~RUBY - #!/bin/sh - - echo "foo" - exit 0 - - #!/usr/bin/env ruby - - puts "bar" - RUBY - - assert Prism.parse_success?(source, offset: 30) - end - private def parse_expression(source) |
