def test_evaluate_form(self): content = '(+ 1 2)' append_to_view(self.view, content) move_cursor(self.view, 0) self.view.run_command('tutkain_evaluate_form') time.sleep(self.delay) self.assertEquals(tutkain.region_content(self.output_panel), ''';; => (+ 1 2)\n3\n''')
def test_evaluate_view_with_error(self): content = '''(ns app.core) (inc "a")''' append_to_view(self.view, content) self.view.run_command('tutkain_evaluate_view') time.sleep(self.delay) self.assertRegex( tutkain.region_content(self.output_panel), r'.*class java.lang.String cannot be cast to class java.lang.Number.*' )
def test_evaluate_view(self): content = '''(ns app.core) (defn square [x] (* x x))''' append_to_view(self.view, content) self.view.run_command('tutkain_evaluate_view') time.sleep(self.delay) self.assertEquals(tutkain.region_content(self.output_panel), ''';; Loading view...\n''') append_to_view(self.view, ' (square 2)') move_cursor(self.view, 40) self.view.run_command('tutkain_evaluate_form') time.sleep(self.delay) self.assertEquals(tutkain.region_content(self.output_panel), ''';; Loading view... ;; => (square 2) 4 ''')
def test_interrupt_evaluation(self): content = '''(do (Thread/sleep 1000) (println "Boom!"))''' append_to_view(self.view, content) move_cursor(self.view, 0) self.view.run_command('tutkain_evaluate_form') self.view.window().run_command('tutkain_interrupt_evaluation') time.sleep(self.delay) self.assertRegex(tutkain.region_content(self.output_panel), r'.*Execution error .*InterruptedException\).*')
def test_run_test_in_current_namespace(self): content = '''(ns app.core-test (:require [clojure.test :refer [deftest is]])) (deftest ok (is (= 2 (+ 1 1)))) (deftest nok (is (= 3 (+ 1 1)))) ''' append_to_view(self.view, content) self.view.run_command('tutkain_run_tests_in_current_namespace') time.sleep(self.delay) self.assertEquals( tutkain.region_content(self.output_panel).splitlines()[-1], '''{:test 2, :pass 1, :fail 1, :error 0, :type :summary}''')
def test_run_test_in_current_namespace_with_error(self): content = '''(ns error.core-test (:require [clojure.test :refer [deftest is]])) (deftest test-with-error (is (= "JavaScript" (+ 1 "a")))) ''' append_to_view(self.view, content) self.view.run_command('tutkain_run_tests_in_current_namespace') time.sleep(self.delay) self.assertRegex( tutkain.region_content(self.output_panel), r'.*class java.lang.String cannot be cast to class java.lang.Number.*' )