MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeText-parser / Test_JavascriptParser

Class Test_JavascriptParser

tests/test_parser/test_javascript.py:10–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class Test_JavascriptParser(unittest.TestCase):
11 def setUp(self) -> None:
12 with open('tests/test_parser/test_sample/javascript_test_sample.js', 'r') as file:
13 self.code_sample = file.read()
14
15 tree = parse_code(self.code_sample, 'javascript')
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 = JavascriptParser.get_function_list(root)
24
25 self.assertEqual(len(function_list), 7)
26
27 def test_get_class_list(self):
28 root = self.root_node
29
30 class_list = JavascriptParser.get_class_list(root)
31
32 self.assertEqual(len(class_list), 2)
33
34 def test_get_docstring(self):
35 code_sample = """
36 /**
37 * Dispatched when the repositories are loaded by the request saga
38 *
39 * @param {array} repos The repository data
40 * @param {string} username The current username
41 *
42 * @return {object} An action object with a type of LOAD_REPOS_SUCCESS passing the repos
43 */
44 function songsLoaded(repos, username) {
45 return {
46 type: LOAD_SONGS_SUCCESS,
47 repos,
48 username,
49 };
50 }
51
52 class Car {
53 /**
54 * Present the object Car
55 *
56 * @return {None}
57 */
58 present() {
59 return 'I have a ' + this.carname;
60 }
61 }
62 """
63
64 tree = parse_code(code_sample, 'javascript')
65 root = tree.root_node
66
67 fn1, fn2 = JavascriptParser.get_function_list(root)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected