diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-04-17 11:28:52 -0400 |
|---|---|---|
| committer | Kevin Newton <kddnewton@gmail.com> | 2024-04-17 13:54:29 -0400 |
| commit | d186eb36a4abbbefa026ea5630a1b59bb668ef0f (patch) | |
| tree | b502ce29121776aefcead8a7a103e6e8f50f41eb /test/prism | |
| parent | ee6e591b6afbe765b2b1a612d8a7bdfc7cbc606c (diff) | |
[ruby/prism] Add a reflection API for determining the fields of a node
https://github.com/ruby/prism/commit/f3f9950a74
Diffstat (limited to 'test/prism')
| -rw-r--r-- | test/prism/reflection_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/prism/reflection_test.rb b/test/prism/reflection_test.rb new file mode 100644 index 0000000000..869b68b1f8 --- /dev/null +++ b/test/prism/reflection_test.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +require_relative "test_helper" + +module Prism + class ReflectionTest < TestCase + def test_fields_for + fields = Reflection.fields_for(CallNode) + methods = CallNode.instance_methods(false) + + fields.each do |field| + if field.is_a?(Reflection::FlagsField) + field.flags.each do |flag| + assert_includes methods, flag + end + else + assert_includes methods, field.name + end + end + end + end +end |
