forked from tweag/nickel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestructuring.rs
90 lines (75 loc) · 1.85 KB
/
destructuring.rs
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use assert_matches::assert_matches;
use nickel_lang::error::{Error, EvalError, TypecheckError};
use nickel_lang::term::Term;
use nickel_lang_utilities::eval_file;
#[test]
fn simple() {
assert_eq!(eval_file("destructuring/simple.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn assign() {
assert_eq!(eval_file("destructuring/assign.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn atbind() {
assert_eq!(eval_file("destructuring/atbind.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn open() {
assert_eq!(eval_file("destructuring/open.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn nested() {
assert_eq!(eval_file("destructuring/nested.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn rest() {
assert_eq!(eval_file("destructuring/rest.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn default() {
assert_eq!(eval_file("destructuring/default.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn typecontract() {
assert_eq!(
eval_file("destructuring/typecontract.ncl"),
Ok(Term::Bool(true))
);
}
#[test]
fn mixed() {
assert_eq!(eval_file("destructuring/mixed.ncl"), Ok(Term::Bool(true)));
}
#[test]
fn assign_fail() {
assert_matches!(
eval_file("destructuring/assign_fail.ncl"),
Err(Error::TypecheckError(TypecheckError::UnboundIdentifier(..)))
);
}
#[test]
fn closed_fail() {
assert_matches!(
eval_file("destructuring/closed_fail.ncl"),
Err(Error::EvalError(EvalError::BlameError(..)))
);
}
#[test]
fn rest_fail() {
assert_matches!(
eval_file("destructuring/rest_fail.ncl"),
Err(Error::EvalError(EvalError::FieldMissing(..)))
);
}
#[test]
fn typecontract_fail() {
assert_matches!(
eval_file("destructuring/typecontract_fail.ncl"),
Err(Error::EvalError(EvalError::BlameError(..)))
);
}
#[test]
fn fun() {
assert_eq!(eval_file("destructuring/fun.ncl"), Ok(Term::Bool(true)));
}