Skip to content

Commit 5babbeb

Browse files
author
Kylo Ginsberg
committed
Add asserts for some of the exercises
1 parent 1a21612 commit 5babbeb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/cljlab/functions.clj

+18-1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ vector
386386

387387
;; @@
388388
(defn do-nothing [x] ___)
389+
390+
(assert (= 42 (do-nothing 42)))
391+
(assert (= "wtf"(do-nothing "wtf")))
389392
;; @@
390393

391394
;; **
@@ -404,6 +407,10 @@ vector
404407

405408
;; @@
406409
(defn always-thing [__] ___)
410+
411+
(assert (= :thing (always-thing)))
412+
(assert (= :thing (always-thing 42)))
413+
(assert (= :thing (always-thing "wtf" 42)))
407414
;; @@
408415

409416
;; **
@@ -515,6 +522,8 @@ vector
515522
;; @@
516523
(defn http-get [url]
517524
___)
525+
526+
(assert (.contains (http-get "http://www.w3.org") "html"))
518527
;; @@
519528

520529
;; **
@@ -531,6 +540,9 @@ vector
531540
;; @@
532541
(defn one-less-arg [f x]
533542
(fn [& args] ___))
543+
544+
(defn add-two-numbers [x y] (+ x y))
545+
(assert (= 3 ((one-less-arg add-two-numbers 1) 2)))
534546
;; @@
535547

536548
;; **
@@ -546,8 +558,13 @@ vector
546558
;; @@
547559
(defn two-fns [f g]
548560
___)
549-
;; @@
550561

562+
(defn add-two [x] (+ 2 x))
563+
(defn times-ten [x] (* 10 x))
564+
565+
(assert (= 12 ((two-fns add-two times-ten) 1)))
566+
(assert (= 30 ((two-fns times-ten add-two) 1)))
567+
;; @@
551568
;; **
552569
;;; # Lab Solutions
553570
;;;

0 commit comments

Comments
 (0)