Пример #1
0
    def connect(self):
        self.view.window().run_command("tutkain_connect", {
            "host": HOST,
            "port": 1667
        })

        if not wait_until_contains(
                """Babashka 0.2.1\nbabashka.nrepl 0.0.4-SNAPSHOT\n""",
                lambda: self.content(
                    tutkain.get_active_repl_view(self.view.window())),
                delay=1,
        ):
            raise AssertionError("REPL did not respond in time.")
Пример #2
0
    def connect(self):
        self.view.window().run_command("tutkain_connect", {
            "host": HOST,
            "port": 1234
        })

        if not wait_until_contains(
                """Clojure 1.10.1\nnREPL 0.8.0\n""",
                lambda: self.content(
                    tutkain.get_active_repl_view(self.view.window())),
                delay=1,
        ):
            raise AssertionError("REPL did not respond in time.")
Пример #3
0
 def tearDownClass(self):
     view = tutkain.get_active_repl_view(self.view.window())
     view and view.close()
     super().tearDownClass()
Пример #4
0
 def repl_view_content(self):
     if "active_repl_view" in tutkain.state:
         view = tutkain.get_active_repl_view(self.view.window())
         return view.substr(sublime.Region(0, view.size()))
Пример #5
0
    def test_multiple_repl_views(self):
        initial_repl_view = tutkain.get_active_repl_view(self.view.window())

        content = cleandoc("""
        (remove-ns 'app.core)

        (ns app.core)

        (defn square
          [x]
          (* x x))

        (comment
          (square 2)
          (square 4)
          (tap> (square 8))
          )
        """)

        self.set_view_content(content)

        self.view.run_command("tutkain_evaluate_view")

        self.assertContainsEventually(":tutkain/loaded\n",
                                      lambda: self.content(initial_repl_view))

        self.set_selections((80, 90))

        self.view.run_command("tutkain_evaluate_form")

        self.assertEqualsEventually(
            """:tutkain/loaded
app.core=> (square 2)
4\n""",
            lambda: self.content(initial_repl_view),
        )

        self.connect()
        other_repl_view = tutkain.get_active_repl_view(self.view.window())

        self.set_selections((93, 103))
        self.view.run_command("tutkain_evaluate_form")

        self.assertContainsEventually(
            """Clojure 1.10.1
nREPL 0.8.2
app.core=> (square 4)
16\n""",
            lambda: self.content(other_repl_view),
        )

        # Initial REPL view content remains the same
        self.assertContainsEventually(
            """:tutkain/loaded
app.core=> (square 2)
4\n""",
            lambda: self.content(initial_repl_view),
        )

        # Evaluate (tap> ,,,)
        self.set_selections((106, 123))
        self.view.run_command("tutkain_evaluate_form")

        client = tutkain.state["client_by_view"][initial_repl_view.id()]
        panel = tap.find_panel(self.view.window(), client)

        # Tap is in the tap panel only once
        self.assertEqualsEventually("64\n", lambda: self.content(panel))

        self.view.window().focus_view(initial_repl_view)
        self.view.window().focus_view(self.view)
        self.set_selections((93, 103))
        self.view.run_command("tutkain_evaluate_form")

        self.assertEqualsEventually(
            """Clojure 1.10.1
nREPL 0.8.2
app.core=> (square 4)
16
app.core=> (tap> (square 8))
true\n""",
            lambda: self.content(other_repl_view),
        )

        self.assertEqualsEventually(
            """:tutkain/loaded
app.core=> (square 2)
4
app.core=> (square 4)
16\n""",
            lambda: self.content(initial_repl_view),
        )