Commit af176c0 1 parent 00331ca commit af176c0 Copy full SHA for af176c0
File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 117
117
(let [prog "
118
118
(defprotocol IFruit (subtotal [item] [item subtotal]))
119
119
(defrecord Apple [price] IFruit (subtotal [_] price) (subtotal [_ discount] (- price discount)))
120
- [(subtotal (->Apple 100)) (subtotal (->Apple 100) 5)]
121
- " ]
122
- (is (= [100 95 ] (tu/eval* prog {})))))
120
+ (extend-type String IFruit (subtotal ([s] (count s)) ([s discount] (- (count s) discount))))
121
+ [(subtotal (->Apple 100)) (subtotal (->Apple 100) 5) (subtotal \" foo\" ) (subtotal \" foo\" 2)]
122
+ "
123
+ prog #?(:clj prog
124
+ :cljs (-> prog
125
+ (str/replace " String" " js/String" )))]
126
+ (is (= [100 95 3 1 ] (tu/eval* prog #?(:clj {}
127
+ :cljs {:classes {:allow :all
128
+ 'js #js {:String js/String}}}))))))
123
129
124
130
#?(:clj
125
131
(deftest import-test
You can’t perform that action at this time.
0 commit comments