-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds some tests for error handling in the code evaluation flow. It also fixes the broken ui integration with code errors.
- Loading branch information
1 parent
5ffcf77
commit 21ae2b5
Showing
7 changed files
with
49 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
(ns bean.code-errors) | ||
|
||
(defn get-error [sheet] | ||
(:code-error sheet)) | ||
|
||
(defn named-ref-error [named error] | ||
(str "name: " named ". " error)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(ns bean.code-test | ||
(:require [clojure.test :refer [deftest testing is]] | ||
[bean.code :as code] | ||
[bean.grid :as grid])) | ||
|
||
(deftest code-errors-test | ||
(testing "When the code has a parse error, it is escalated on reevaluation" | ||
(is (= (-> (grid/new-sheet [[""]] "") | ||
(code/set-code "foo: 99fail") | ||
code/reevaluate | ||
:code-error) | ||
"Parse Error: idx 7. [{:tag :string, :expecting \"*\"} {:tag :regexp, :expecting #\"^\\s+\"} {:tag :string, :expecting \"+\"} {:tag :string, :expecting \"\\n\"}]"))) | ||
|
||
(testing "When the code has an error in a statement, it is escalated on reevaluation" | ||
(is (= (-> (grid/new-sheet [[""]] "") | ||
(code/set-code "foo: B3") | ||
code/reevaluate | ||
:code-error) | ||
"name: foo. Invalid address [2 1]"))) | ||
|
||
(testing "When the code has an error in a statement, it is escalated on initial | ||
evaluation after the grid is evaluated" | ||
(is (= (-> (grid/new-sheet [["1"]] "foo: A1+\"bar\"") | ||
grid/eval-sheet | ||
:code-error) | ||
"name: foo. + only works for Integers")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters