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_source_files_simple_project(self):
        project_directory = path_helper.monkey_example_directory()

        output = swift_project.source_files(project_directory)

        expectation = [
            project_directory + "/Banana.swift",
            project_directory + "/Monkey.swift"
        ]

        self.assertEqual(sorted(list(output)), sorted(expectation))
    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")
Esempio n. 4
0
    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")
Esempio n. 9
0
    def test_snippet_markers(self):
        file = ""
        text = "Monkey()."
        offset = 9
        project_directory = path_helper.monkey_example_directory()
        output = subl_source_kitten.complete(offset, file, project_directory,
                                             text)

        expectation = [
            ['consumedBananas\t[Banana]', 'consumedBananas'],
            ['eat(:)\tVoid', 'eat(${1:<banana: Banana>})'],
            [
                'give(banana:toMonkey:)\tVoid',
                'give(banana: ${1:<Banana>}, toMonkey: ${2:<Monkey>})'
            ]
        ]

        self.assertEqual(list(output), expectation)