reign
Version:
A persistent, typed-objects implementation.
77 lines (63 loc) • 1.87 kB
JavaScript
;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _ = require("../..");
var _2 = require("./");
var _symbols = require("../../symbols");
describeRealm('ReferenceType', function (options) {
var realm = void 0;
var StructType = void 0;
var ReferenceType = void 0;
var T = void 0;
var Point = void 0,
Series = void 0,
Line = void 0;
var series = void 0,
line = void 0;
before(function () {
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 (var 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 () {
(function () {
new Line({ from: series[0], to: series[99] });
}).should.throw(ReferenceError);
});
});