aboutsummaryrefslogtreecommitdiffstats
path: root/test/prism/constant_path_node_test.rb
diff options
context:
space:
mode:
authorVinicius Stock <vinistock@users.noreply.github.com>2023-11-21 11:39:23 -0500
committergit <svn-admin@ruby-lang.org>2023-11-21 16:39:27 +0000
commit7a9bb6d2a7d3d75cb8c3d83d09819d5bcea09796 (patch)
treeabfc12f705ce6d5202f77e4f9f971819cb60e826 /test/prism/constant_path_node_test.rb
parent8966d06b96f2c6396d4c7e58b7a51c9bdebbb694 (diff)
downloadruby-7a9bb6d2a7d3d75cb8c3d83d09819d5bcea09796.tar.gz
[ruby/prism] Fix constant path full name when parent is not a
constant (https://github.com/ruby/prism/pull/1742) * Raise if constant path parts contains nodes that can't be used to build full name * Fix typo in constant path error documentation Co-authored-by: Tim Morgan <tim@timmorgan.org> --------- https://github.com/ruby/prism/commit/d73a053262 Co-authored-by: Tim Morgan <tim@timmorgan.org>
Diffstat (limited to 'test/prism/constant_path_node_test.rb')
-rw-r--r--test/prism/constant_path_node_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/prism/constant_path_node_test.rb b/test/prism/constant_path_node_test.rb
index 5bb9830687..9842be0c49 100644
--- a/test/prism/constant_path_node_test.rb
+++ b/test/prism/constant_path_node_test.rb
@@ -15,6 +15,33 @@ module Prism
assert_equal("Foo::Bar::Baz::Qux", constant_path.full_name)
end
+ def test_full_name_for_constant_path_with_self
+ source = <<~RUBY
+ self:: # comment
+ Bar::Baz::
+ Qux
+ RUBY
+
+ constant_path = Prism.parse(source).value.statements.body.first
+ assert_raise(ConstantPathNode::DynamicPartsInConstantPathError) do
+ constant_path.full_name
+ end
+ end
+
+ def test_full_name_for_constant_path_with_variable
+ source = <<~RUBY
+ foo:: # comment
+ Bar::Baz::
+ Qux
+ RUBY
+
+ constant_path = Prism.parse(source).value.statements.body.first
+
+ assert_raise(ConstantPathNode::DynamicPartsInConstantPathError) do
+ constant_path.full_name
+ end
+ end
+
def test_full_name_for_constant_path_target
source = <<~RUBY
Foo:: # comment