[ruby/prism] Wire up options through the FFI API

f0aa8ad93b
This commit is contained in:
Kevin Newton 2023-11-02 14:01:20 -04:00
parent ca7297efd3
commit 05f5c545d2
No known key found for this signature in database
GPG key ID: 0EAD74C79EC73F26
12 changed files with 335 additions and 234 deletions

View file

@ -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