def test_complete_midword(self): offset = 123 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) output = source_kitten.complete(offset, file, project_directory, text) self.assertTrue(len(output) > 0) self.assertEqual(output[0]["name"], "color") self.assertEqual(output[0]["typeName"], "String")
def test_cursor_info_unsaved(self): offset = 31 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) text = text.replace("consumedBananas", "consumedBananaz", 1) output = source_kitten.cursor_info(offset, file, project_directory, text) self.assertEqual(output["key.name"], "consumedBananaz")
def test_complete_with_haste_simple(self): offset = 121 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) output = subl_source_kitten.complete_with_haste( offset, file, project_directory, text) expectation = [ ["color\tString", "color"], ["flavor\tInt", "flavor"], ] self.assertEqual(list(output), expectation)
def test_complete_changed_code_on_unsaved(self): offset = 162 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) output = source_kitten.complete(offset, file, project_directory, text) self.assertTrue(len(output) > 0) text = text.replace("consumedBananas", "consumedBananaz", 1) output = source_kitten.complete(offset, file, project_directory, text) self.assertTrue(len(output) == 0) text = text.replace("consumedBananas", "consumedBananaz", 1) output = source_kitten.complete(offset, file, project_directory, text) self.assertTrue(len(output) > 0)
def test_cursor_info(self): offset = 78 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) output = source_kitten.cursor_info(offset, file, project_directory, text) self.assertEqual(output["key.name"], "Banana") self.assertEqual(output["key.typename"], "Banana.Type") self.assertEqual(output["key.filepath"], project_directory + "/Banana.swift") self.assertEqual(output["key.offset"], 7) self.assertEqual(output["key.length"], 6)
def test_complete_midword_type(self): offset = 80 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Banana.swift" text = file_contents_helper.read(file) output = source_kitten.complete(offset, file, project_directory, text) self.assertTrue(len(output) > 0) found_string_as_autocomplete = False for entry in output: if entry["name"] == "String" and entry["typeName"] == "String": found_string_as_autocomplete = True self.assertTrue(found_string_as_autocomplete)
def test_complete_simple(self): offset = 121 project_directory = path_helper.monkey_example_directory() file = project_directory + "/Monkey.swift" text = file_contents_helper.read(file) output = source_kitten.complete(offset, file, project_directory, text) expectation = [ ["color\tString", "color"], ["flavor\tInt", "flavor"], ] self.assertEqual(len(output), 2) self.assertEqual(output[0]["name"], "color") self.assertEqual(output[0]["typeName"], "String") self.assertEqual(output[1]["name"], "flavor") self.assertEqual(output[1]["typeName"], "Int")