Skip to content

Commit d4b5f81

Browse files
committed
add a unit test for functions whose randomness is not explicitly set
1 parent c3b2ffe commit d4b5f81

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/jme/jme-tests.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,22 @@ Numbas.queueScript('jme_tests',['qunit','jme','jme-rules','jme-display','jme-cal
24972497
});
24982498

24992499
var defined = Numbas.jme.builtinScope.allFunctions();
2500+
2501+
var unsure_random = [];
2502+
Object.entries(defined).forEach(([name, fns]) => {
2503+
if(name in jme.isDeterministicOps) {
2504+
return;
2505+
}
2506+
if(fns.some(fn => !fn.hasOwnProperty('random')) || (new Set(fns.map(fn => fn.random))).size != 1) {
2507+
unsure_random.push(name);
2508+
}
2509+
});
2510+
2511+
assert.equal(unsure_random.length, 0, 'No ambiguous random built-in functions');
2512+
if(unsure_random.length) {
2513+
console.log('Ambiguous random built-in functions:', unsure_random);
2514+
}
2515+
25002516
for(var x in Numbas.jme.opSynonyms) {
25012517
defined[x] = true;
25022518
}

0 commit comments

Comments
 (0)