-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
69 lines (58 loc) · 1.47 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
import {Realm} from "../..";
import {Struct} from "./";
import {$Backing, $Address} from "../../symbols";
describeRealm('ReferenceType', function (options) {
let realm;
let StructType;
let ReferenceType;
let T;
let Point, Series, Line;
let series, line;
before(() => {
realm = options.realm;
StructType = realm.StructType;
ReferenceType = realm.ReferenceType;
T = realm.T;
});
it('should create some structs', function () {
Point = new StructType({
x: T.Float64,
y: T.Float64
});
Series = new StructType(Point, 100);
Line = new StructType({
from: Point.ref,
to: Point.ref
});
});
it('should create a line between two points', function () {
line = new Line({
from: {
x: 10,
y: 10
},
to: {
x: 90,
y: 90
}
});
});
it('should have created two new points', function () {
line.from.should.be.an.instanceOf(Point);
line.to.should.be.an.instanceOf(Point);
});
it('should create a series of points', function () {
series = new Series();
});
it('should have 100 embedded points', function () {
for (let i = 0; i < 100; i++) {
series[i].should.be.an.instanceOf(Point);
}
(typeof series[100]).should.equal('undefined');
});
it('should not create a line between points embedded within a series', function () {
(() => {
new Line({from: series[0], to: series[99]});
}).should.throw(ReferenceError);
});
});