-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.sml
67 lines (40 loc) · 1.91 KB
/
test.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use "assignment_01.sml";
val date1 = (12,10,2012);
val date2 = (12,20,2012);
val date3 = (11,20,2012);
val strings = ["SML","IS","A","COOL","LANGUAGE"];
(*
This is my test file for assignment 1
all the fuctions are tested for truth
function(arguments) should = expectation
*)
(* 1 val is_older = fn : (int * int * int) * (int * int * int) -> bool *)
is_older(date1,date2) = true ;
is_older(date1,date3) = false ;
(* 2 val number_in_month = fn : (int * int * int) list * int -> int *)
number_in_month([date1,date2,date3],12) = 2;
(* 3 val number_in_months = fn : (int * int * int) list * int list -> int *)
number_in_months([date1,date2,date3],[12]) = 2;
number_in_months([date1,date2,date3],[12,11]) = 3;
(* 4 val dates_in_month = fn : (int * int * int) list * int -> (int * int * int) list *)
dates_in_month([date1,date2,date3],12) = [date1,date2];
(* 5 val dates_in_months = fn : (int * int * int) list * int list -> (int * int * int) list *)
dates_in_months([date1,date2,date3],[12]) = [date1,date2];
dates_in_months([date1,date2,date3],[12,11]) = [date1,date2,date3];
(* 6 val get_nth = fn : string list * int -> string *)
get_nth(strings,3) = "A";
get_nth(strings,4) = "COOL";
get_nth2(strings,3) = "A";
get_nth2(strings,4) = "COOL";
(* 7 val = date_to_string = fn : int * int * int -> string *)
date_to_string(date3) = "November 20, 2012";
(* 8 val number_before_reaching_sum = fn : int * int list -> int *)
number_before_reaching_sum(7,[1,2,3,4,5,6,7,8,9]) = 6;
number_before_reaching_sum(8,[1,2,3,4,5,6,7,8,9]) = 6;
number_before_reaching_sum(9,[1,2,3,4,5,6,7,8,9]) = 6;
number_before_reaching_sum(10,[1,2,3,4,5,6,7,8,9]) = 6;
number_before_reaching_sum(11,[1,2,3,4,5,6,7,8,9]) = 10;
number_before_reaching_sum(16,[1,2,3,4,5,6,7,8,9]) = 15;
number_before_reaching_sum(20,[1,2,3,4,5,6,7,8,9]) = 15;
number_before_reaching_sum(21,[1,2,3,4,5,6,7,8,9]) = 15;
number_before_reaching_sum(22,[1,2,3,4,5,6,7,8,9]) = 21;