summaryrefslogtreecommitdiff
path: root/test/prism/api/parse_comments_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/prism/api/parse_comments_test.rb')
-rw-r--r--test/prism/api/parse_comments_test.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/prism/api/parse_comments_test.rb b/test/prism/api/parse_comments_test.rb
new file mode 100644
index 0000000000..4dbcca1827
--- /dev/null
+++ b/test/prism/api/parse_comments_test.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require_relative "../test_helper"
+
+module Prism
+ class ParseCommentsTest < TestCase
+ def test_parse_comments
+ comments = Prism.parse_comments("# foo")
+
+ assert_kind_of Array, comments
+ assert_equal 1, comments.length
+ end
+
+ def test_parse_file_comments
+ comments = Prism.parse_file_comments(__FILE__)
+
+ assert_kind_of Array, comments
+ assert_equal 1, comments.length
+ end
+
+ def test_parse_file_comments_error
+ error = assert_raise Errno::ENOENT do
+ Prism.parse_file_comments("idontexist.rb")
+ end
+
+ assert_equal "No such file or directory - idontexist.rb", error.message
+
+ assert_raise TypeError do
+ Prism.parse_file_comments(nil)
+ end
+ end
+ end
+end