relu-core
Version:
29 lines (28 loc) • 1.18 kB
JavaScript
var should = require("should");
var rp = require("../");
var checkRefs = require("./checkRefs");
describe("restricted", function() {
it("should provide correct writable flag", checkRefs(function() {
var x = rp.const([1, {a: 2}]).readonly();
var y = rp.variable([1, {a: 2}]).readonly();
var z = rp.variable([1, {a: 2}]).fixed();
var a = rp.variable([1, {a: 2}]).fixedArray();
x.isWritable().should.be.eql(false);
x(0).isWritable().should.be.eql(false);
x(1, "a").isWritable().should.be.eql(false);
y.isWritable().should.be.eql(false);
y(0).isWritable().should.be.eql(false);
y(1, "a").isWritable().should.be.eql(false);
z.isWritable().should.be.eql(false);
z(0).isWritable().should.be.eql(true);
z(1, "a").isWritable().should.be.eql(true);
a.isWritable().should.be.eql(false);
a(0).isWritable().should.be.eql(true);
a(1, "a").isWritable().should.be.eql(true);
}));
// it("should provide correct writable flag in complex cases", checkRefs(function() {
// var x = rp.delegated(rp.const(rp.variable({a: 1}).fixed()));
// x.isWritable().should.be.eql(false);
// x("a").isWritable().should.be.eql(true);
// }));
});