Skip to content

Commit a723f40

Browse files
committed
Test all methods of the YARP Ruby API
1 parent dddfb29 commit a723f40

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ruby_api_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require "yarp_test_helper"
4+
5+
class YARPRubyAPITest < Test::Unit::TestCase
6+
def test_ruby_api
7+
filepath = __FILE__
8+
source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8)
9+
10+
assert_equal YARP.lex(source, filepath).value, YARP.lex_file(filepath).value
11+
12+
assert_equal YARP.dump(source, filepath), YARP.dump_file(filepath)
13+
14+
serialized = YARP.dump(source, filepath)
15+
ast1 = YARP.load(source, serialized).value
16+
ast2 = YARP.parse(source, filepath).value
17+
ast3 = YARP.parse_file(filepath).value
18+
19+
assert_equal_nodes ast1, ast2
20+
assert_equal_nodes ast2, ast3
21+
end
22+
end

0 commit comments

Comments
 (0)