forked from elixirscript/elixirscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtuple.spec.js
More file actions
54 lines (43 loc) · 1.47 KB
/
Copy pathtuple.spec.js
File metadata and controls
54 lines (43 loc) · 1.47 KB
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
"use strict";
var Kernel = require('../lib/kernel');
var Tuple = require('../lib/tuple');
var expect = require('chai').expect;
describe('Tuple', function(){
describe('duplicate', function(){
it('must make a tuple with the value duplicated the specified amount of times', function(){
let t = Tuple.duplicate("value", 3);
expect(t.count()).to.equal(3);
expect(Kernel.elem(t, 0)).to.equal("value");
expect(Kernel.elem(t, 1)).to.equal("value");
expect(Kernel.elem(t, 2)).to.equal("value");
t = Tuple.duplicate("value", 0);
expect(t.count()).to.equal(0);
});
});
describe('delete_at', function(){
it('must delete first item', function(){
let t = Kernel.SpecialForms.tuple(1, 2, 3);
t = Tuple.delete_at(t, 0);
expect(t.get(0)).to.equal(2);
});
});
describe('toString', function(){
it('must display correctly', function(){
let t = Kernel.SpecialForms.tuple(1, 2, 3);
expect(Kernel.to_string(t)).to.equal("{1, 2, 3}");
});
});
describe('from_list', function(){
it('must create a tuple from a list', function(){
let list = Kernel.SpecialForms.list(1, 2, 3);
let tuple = Tuple.from_list(list);
expect(Kernel.to_string(tuple)).to.equal("{1, 2, 3}");
});
});
describe('to_list', function(){
it('must create a list from a tuple', function(){
let t = Kernel.SpecialForms.tuple(1, 2, 3);
expect(Tuple.to_list(t).length).to.equal(3);
});
});
});