File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ impl Environment {
88
88
// clojure.std functions
89
89
let thread_sleep_fn = clojure_std:: thread:: SleepFn { } ;
90
90
let nanotime_fn = clojure_std:: time:: NanoTimeFn { } ;
91
-
91
+
92
92
// Hardcoded fns
93
93
let lexical_eval_fn = Value :: LexicalEvalFn { } ;
94
94
// Hardcoded macros
Original file line number Diff line number Diff line change @@ -36,4 +36,37 @@ impl IFn for AddFn {
36
36
) ) ,
37
37
} )
38
38
}
39
- }
39
+ }
40
+
41
+
42
+ #[ cfg( test) ]
43
+ mod tests {
44
+ mod plus_tests {
45
+ use crate :: ifn:: IFn ;
46
+ use crate :: value:: Value ;
47
+ use std:: rc:: Rc ;
48
+ use crate :: rust_core:: AddFn ;
49
+
50
+ #[ test]
51
+ fn plus_without_arguments_returns_zero ( ) {
52
+ let addition = AddFn { } ;
53
+ let args = vec ! [ ] ;
54
+ assert_eq ! ( Value :: I32 ( 0 ) , addition. invoke( args) ) ;
55
+ }
56
+
57
+ #[ test]
58
+ fn plus_with_one_argument_returns_identity ( ) {
59
+ let addition = AddFn { } ;
60
+ let args = vec ! [ Rc :: new( Value :: I32 ( 5 ) ) ] ;
61
+ assert_eq ! ( Value :: I32 ( 5 ) , addition. invoke( args) ) ;
62
+ }
63
+
64
+ #[ test]
65
+ fn plus_with_two_argument_returns_product ( ) {
66
+ let addition = AddFn { } ;
67
+ let args = vec ! [ Rc :: new( Value :: I32 ( 5 ) ) , Rc :: new( Value :: I32 ( 6 ) ) ] ;
68
+ assert_eq ! ( Value :: I32 ( 11 ) , addition. invoke( args) ) ;
69
+ }
70
+
71
+ }
72
+ }
You can’t perform that action at this time.
0 commit comments