Public
Edited
Feb 26
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
tests = ({
physics: [
() => {
ensure(g > 9);
},
() => {
ensure(g < 10);
},
() => {
ensure(inch > 0.02);
},
() => {
ensure(inch < 0.03);
}
],

pi: {
// This can simulate a failing tets (see below)
ensure() {
ensure(_.isNumber(pi), pi > piMoreThan, pi < 4);
},

expect: [
() => {
expect(pi).to.be.above(3);
},
() => {
expect(pi).to.be.below(4);
},
() => {
expect(pi).to.be.a("number");
}
]
},

min() {
ensure(min(2, 4) === 2), ensure(min(-12, -16) === -16);
},

max() {
ensure(max(2, 4) === 4), ensure(max(-12, -16) === -12);
},

rounding: [
() => {
expect(roundTo(-9.876, 0.1)).to.be(-9.9);
},
() => {
expect(roundTo(9.876, 0.1)).to.be(9.9);
},
() => {
expect(roundTo(9876, 10)).to.be(9880);
},
() => {
expect(roundTo(9876, 1000)).to.be(10000);
}
],

// This line artificially duplicates tests for demo purposes (see below)
si: _.range(fakeTestRepeatCount).map((x) => [
() => {
expect(1 * kilo).to.be(1000);
},
() => {
expect(1 * mega).to.be(1000 * 1000);
},
() => {
expect(1 * mega).to.be(kilo * kilo);
},
() => {
ensure(milli < centi);
},
() => {
ensure(centi < kilo);
}
])
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more