forked from elixirscript/elixirscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.spec.js
More file actions
41 lines (31 loc) · 829 Bytes
/
try.spec.js
File metadata and controls
41 lines (31 loc) · 829 Bytes
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
import Core from "../lib/core";
const Patterns = Core.Patterns;
const SpecialForms = Core.SpecialForms;
import Enum from "../lib/enum";
import chai from 'chai';
var expect = chai.expect;
describe('try', () => {
it('try', () => {
/*
try do
1 / x
else
y when y < 1 and y > -1 ->
:small
_ ->
:large
end
*/
let x = 1;
let value = SpecialForms._try(function() {
return 1 / x;
}, null, null, Patterns.defmatch(Patterns.make_case([Patterns.variable()], function(y) {
return Symbol.for('small');
}, function(y) {
return (y < 1) && (y > -1);
}), Patterns.make_case([Patterns.wildcard()], function() {
return Symbol.for('large');
})), null);
expect(value).to.equal(Symbol.for('large'));
});
});