| 8 | |
| 9 | |
| 10 | class Test_RubyParser(unittest.TestCase): |
| 11 | def setUp(self) -> None: |
| 12 | with open('tests/test_parser/test_sample/ruby_test_sample.rb', 'r') as file: |
| 13 | self.code_sample = file.read() |
| 14 | |
| 15 | tree = parse_code(self.code_sample, 'ruby') |
| 16 | self.root_node = tree.root_node |
| 17 | |
| 18 | return super().setUp() |
| 19 | |
| 20 | def test_get_function_list(self): |
| 21 | root = self.root_node |
| 22 | |
| 23 | function_list = RubyParser.get_function_list(root) |
| 24 | |
| 25 | self.assertEqual(len(function_list), 2) |
| 26 | |
| 27 | def test_get_class_list(self): |
| 28 | root = self.root_node |
| 29 | |
| 30 | class_list = RubyParser.get_class_list(root) |
| 31 | |
| 32 | self.assertEqual(len(class_list), 3) |
| 33 | |
| 34 | def test_get_docstring(self): |
| 35 | code_sample = """ |
| 36 | module Encryption |
| 37 | |
| 38 | # Search for links. |
| 39 | # |
| 40 | # @param query [String] The search query. |
| 41 | # @option options [String, RedditKit::Subreddit] subreddit The optional subreddit to search. |
| 42 | def encrypt(string) |
| 43 | Digest::SHA2.hexdigest(string) |
| 44 | end |
| 45 | end |
| 46 | |
| 47 | =begin |
| 48 | comment line 1 |
| 49 | comment line 2 |
| 50 | =end |
| 51 | class Orange |
| 52 | def initialize |
| 53 | @juice_available = 100 |
| 54 | end |
| 55 | def squeeze |
| 56 | @juice_available -= 50 |
| 57 | end |
| 58 | end |
| 59 | |
| 60 | orange = Orange.new |
| 61 | orange.squeeze |
| 62 | """ |
| 63 | |
| 64 | tree = parse_code(code_sample, 'ruby') |
| 65 | root = tree.root_node |
| 66 | |
| 67 | fn = RubyParser.get_function_list(root)[0] |
nothing calls this directly
no outgoing calls
no test coverage detected