You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
609 B
40 lines
609 B
4 weeks ago
|
import dbc from "./dbc.mjs";
|
||
|
|
||
|
try {
|
||
|
dbc.check(1 == 2, "Math is wrong!");
|
||
|
} catch(e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
dbc.sentinel(1 == 2);
|
||
|
} catch(e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
dbc.pre(() => 1 == 2, "Pre failed!");
|
||
|
} catch(e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
dbc.post(() => 1 == 2, "Post failed!");
|
||
|
} catch(e) {
|
||
|
console.error(e);
|
||
|
}
|
||
|
|
||
|
const test_func = (x,y) => {
|
||
|
dbc.pre(() => x < y, "x must be less than y");
|
||
|
|
||
|
let result = x + y;
|
||
|
|
||
|
dbc.check(result > 100, "the result must be > 100");
|
||
|
|
||
|
result = result % 100;
|
||
|
|
||
|
dbc.post(() => result < 100, "x was not < 100");
|
||
|
}
|
||
|
|
||
|
test_func(12, 10002343034);
|