-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
113 lines (93 loc) · 2.42 KB
/
test.js
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
describeRealm('Builtin: Array', function (options) {
let realm;
let backing;
let T;
let address;
before(() => {
realm = options.realm;
backing = realm.backing;
T = realm.T;
address = backing.alloc(T.Array.byteLength);
});
after(() => {
backing.free(address);
});
describe('Array from length', function () {
let arr;
it('should create a new array', function () {
arr = new T.Array(3);
});
it('should have the right length', function () {
arr.length.should.equal(3);
});
it('should be full of nulls', function () {
arr.toJSON().should.eql([null, null, null])
});
it('should set some values', function () {
arr[0] = 'abc';
arr[1] = true;
arr[2] = {
greeting: 'hello world'
};
});
it('should get some values', function () {
arr[0].should.equal('abc')
arr[1].should.equal(true);
arr[2].should.eql({
greeting: 'hello world'
});
});
it('should overwrite some values', function () {
arr[1] = false;
});
it('should get some values again', function () {
arr[0].should.equal('abc')
arr[1].should.equal(false);
arr[2].should.eql({
greeting: 'hello world'
});
});
});
describe('Array from input', function () {
let arr;
it('should create a new array', function () {
arr = new T.Array(['abc', true, {greeting: 'hello world'}]);
});
it('should have the right length', function () {
arr.length.should.equal(3);
});
it('should get some values', function () {
arr[0].should.equal('abc')
arr[1].should.equal(true);
arr[2].should.eql({
greeting: 'hello world'
});
});
it('should overwrite some values', function () {
arr[1] = false;
});
it('should get some values again', function () {
arr[0].should.equal('abc')
arr[1].should.equal(false);
arr[2].should.eql({
greeting: 'hello world'
});
});
});
describe('Multidimensional array', function () {
let arr;
it('should create a new array', function () {
arr = new T.Array.Array([
[1, 1, 1],
[2, 2, 2],
[3, 3, 3]
]);
});
it('should have the right length', function () {
arr.length.should.equal(3);
arr[0].length.should.equal(3);
arr[1].length.should.equal(3);
arr[2].length.should.equal(3);
});
});
});