diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-11-02 14:01:20 -0400 |
---|---|---|
committer | Kevin Newton <kddnewton@gmail.com> | 2023-11-03 10:13:49 -0400 |
commit | 05f5c545d232554b6ffb183d6948ad37f46df53b (patch) | |
tree | 43ab5b181b7fb31e5421a9adda59f822e0d65c45 /test/prism/ruby_api_test.rb | |
parent | ca7297efd389eca792c706326d1af138acf5a4f6 (diff) | |
download | ruby-05f5c545d232554b6ffb183d6948ad37f46df53b.tar.gz |
[ruby/prism] Wire up options through the FFI API
https://github.com/ruby/prism/commit/f0aa8ad93b
Diffstat (limited to 'test/prism/ruby_api_test.rb')
-rw-r--r-- | test/prism/ruby_api_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/prism/ruby_api_test.rb b/test/prism/ruby_api_test.rb index efe8bc1c1b..844a7796a3 100644 --- a/test/prism/ruby_api_test.rb +++ b/test/prism/ruby_api_test.rb @@ -20,6 +20,19 @@ module Prism assert_equal_nodes ast2, ast3 end + def test_options + assert_equal "", Prism.parse("__FILE__").value.statements.body[0].filepath + assert_equal "foo.rb", Prism.parse("__FILE__", filepath: "foo.rb").value.statements.body[0].filepath + + refute Prism.parse("\"foo\"").value.statements.body[0].frozen? + assert Prism.parse("\"foo\"", frozen_string_literal: true).value.statements.body[0].frozen? + refute Prism.parse("\"foo\"", frozen_string_literal: false).value.statements.body[0].frozen? + + assert_kind_of Prism::CallNode, Prism.parse("foo").value.statements.body[0] + assert_kind_of Prism::LocalVariableReadNode, Prism.parse("foo", scopes: [[:foo]]).value.statements.body[0] + assert_equal 2, Prism.parse("foo", scopes: [[:foo], []]).value.statements.body[0].depth + end + def test_literal_value_method assert_equal 123, parse_expression("123").value assert_equal 3.14, parse_expression("3.14").value |