Strict mode now works...
This commit is contained in:
parent
75bf19e38e
commit
fe6fba87e0
5 changed files with 62 additions and 12 deletions
|
|
@ -1,6 +1,7 @@
|
|||
(ns beowulf.mexpr-test
|
||||
(:require [clojure.test :refer :all]
|
||||
[beowulf.read :refer [parse simplify generate]]))
|
||||
[beowulf.bootstrap :refer [*options*]]
|
||||
[beowulf.read :refer [parse simplify generate gsp]]))
|
||||
|
||||
;; These tests are taken generally from the examples on page 10 of
|
||||
;; Lisp 1.5 Programmers Manual:
|
||||
|
|
@ -64,3 +65,10 @@
|
|||
(parse "label[ff;λ[[x];[atom[x]->x; T->ff[car[x]]]]]"))))]
|
||||
(is (= actual expected)))))
|
||||
|
||||
(deftest strict-tests
|
||||
(testing "Strict feature"
|
||||
(binding [*options* {:strict true}]
|
||||
(is (thrown-with-msg?
|
||||
Exception
|
||||
#"Cannot parse meta expressions in strict mode"
|
||||
(gsp "label[ff;λ[[x];[atom[x]->x; T->ff[car[x]]]]]"))))))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
(:require [clojure.math.numeric-tower :refer [abs]]
|
||||
[clojure.test :refer :all]
|
||||
[beowulf.cons-cell :refer :all]
|
||||
[beowulf.read :refer [parse simplify generate]]))
|
||||
[beowulf.bootstrap :refer [*options*]]
|
||||
[beowulf.read :refer [parse simplify generate gsp]]))
|
||||
|
||||
;; broadly, sexprs should be homoiconic
|
||||
|
||||
|
|
@ -24,6 +25,32 @@
|
|||
actual (generate (simplify (parse (str expected))))]
|
||||
(is (= actual expected)))))
|
||||
|
||||
(deftest comment-tests
|
||||
(testing "Reading comments"
|
||||
(let [expected 'A
|
||||
actual (gsp "A ;; comment")]
|
||||
(is (= actual expected)))
|
||||
(let [expected 10
|
||||
actual (gsp "10 ;; comment")]
|
||||
(is (= actual expected)))
|
||||
(let [expected 2/5
|
||||
actual (gsp "4E-1 ;; comment")]
|
||||
(is (= actual expected)))
|
||||
(let [expected "(A B C)"
|
||||
actual (print-str (gsp "(A ;; comment
|
||||
B C)"))]
|
||||
(is (= actual expected)
|
||||
"Really important that comments work inside lists"))
|
||||
;; ;; TODO: Currently failing and I'm not sure why
|
||||
;; (binding [*options* {:strict true}]
|
||||
;; (is (thrown-with-msg?
|
||||
;; Exception
|
||||
;; #"Cannot parse comments in strict mode"
|
||||
;; (gsp "(A ;; comment
|
||||
;; B C)"))))
|
||||
))
|
||||
|
||||
|
||||
(deftest number-tests
|
||||
(testing "Reading octal numbers"
|
||||
(let [expected 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue