Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christianp committed Feb 13, 2024
1 parent 2e1c375 commit 9b00688
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tests/jme-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14479,6 +14479,17 @@ newBuiltin('with_precision', [TNum,'nothing or number', 'nothing or string'], TN
}
});

newBuiltin('imprecise', [TNum], TNum, null, {
evaluate: function(args, scope) {
var n = args[0];

delete n.precision;
delete n.precisionType;

return n;
}
});

newBuiltin('parsedecimal', [TString,TString], TDecimal, function(s,style) {return util.parseDecimal(s,false,style,true);});
newBuiltin('parsedecimal', [TString,sig.listof(sig.type('string'))], TDecimal, function(s,styles) {return util.parseDecimal(s,false,styles,true);}, {unwrapValues: true});
newBuiltin('parsedecimal_or_fraction', [TString], TDecimal, function(s,style) {return util.parseDecimal(s,true,"plain-en",true);});
Expand Down Expand Up @@ -18862,7 +18873,11 @@ JMEifier.prototype = {
var precisionType = options.precisionType === undefined ? 'nothing' : this.string(options.precisionType,{});
var store_precision = options.store_precision === undefined ? this.settings.store_precision : options.store_precision;
if(store_precision) {
out = 'with_precision('+out+', ' + precision + ', '+ precisionType +')';
if(precision == 'nothing' && precisionType == 'nothing') {
out = 'imprecise('+out+')';
} else {
out = 'with_precision('+out+', ' + precision + ', '+ precisionType +')';
}
return out;
}
} else {
Expand Down
11 changes: 11 additions & 0 deletions tests/jme/doc-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,17 @@ export default
],
"examples": []
},
{
"name": "imprecise",
"keywords": [
"precision"
],
"noexamples": true,
"calling_patterns": [
"imprecise(n)"
],
"examples": []
},
{
"name": "withintolerance",
"keywords": [
Expand Down
26 changes: 25 additions & 1 deletion tests/numbas-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -14070,6 +14070,17 @@ newBuiltin('with_precision', [TNum,'nothing or number', 'nothing or string'], TN
}
});

newBuiltin('imprecise', [TNum], TNum, null, {
evaluate: function(args, scope) {
var n = args[0];

delete n.precision;
delete n.precisionType;

return n;
}
});

newBuiltin('parsedecimal', [TString,TString], TDecimal, function(s,style) {return util.parseDecimal(s,false,style,true);});
newBuiltin('parsedecimal', [TString,sig.listof(sig.type('string'))], TDecimal, function(s,styles) {return util.parseDecimal(s,false,styles,true);}, {unwrapValues: true});
newBuiltin('parsedecimal_or_fraction', [TString], TDecimal, function(s,style) {return util.parseDecimal(s,true,"plain-en",true);});
Expand Down Expand Up @@ -18453,7 +18464,11 @@ JMEifier.prototype = {
var precisionType = options.precisionType === undefined ? 'nothing' : this.string(options.precisionType,{});
var store_precision = options.store_precision === undefined ? this.settings.store_precision : options.store_precision;
if(store_precision) {
out = 'with_precision('+out+', ' + precision + ', '+ precisionType +')';
if(precision == 'nothing' && precisionType == 'nothing') {
out = 'imprecise('+out+')';
} else {
out = 'with_precision('+out+', ' + precision + ', '+ precisionType +')';
}
return out;
}
} else {
Expand Down Expand Up @@ -23721,6 +23736,7 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
'reviewShowAdvice'
]
);
tryGetAttribute(settings,xml,'settings/feedback/results_options',['printquestions','printadvice'], ['resultsprintquestions', 'resultsprintadvice']);
var serializer = new XMLSerializer();
var isEmpty = Numbas.xml.isEmpty;
var introNode = this.xml.selectSingleNode(feedbackPath+'/intro/content/span');
Expand Down Expand Up @@ -23826,6 +23842,10 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
if(feedback) {
tryLoad(feedback,['showActualMark','showTotalMark','showAnswerState','allowRevealAnswer','adviceThreshold'], exam);
tryLoad(feedback,['intro'],exam,['introMessage']);
var results_options = tryGet(feedback,'results_options')
if(results_options) {
tryLoad(results_options,['resultsprintquestions','resultsprintadvice'],settings);
}
var feedbackmessages = tryGet(feedback,'feedbackmessages');
if(feedbackmessages) {
feedbackmessages.forEach(function(d) {
Expand Down Expand Up @@ -23957,6 +23977,8 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
* @property {boolean} reviewShowScore - Show student's score in review mode?
* @property {boolean} reviewShowFeedback - Show part feedback messages in review mode?
* @property {boolean} reviewShowAdvice - Show question advice in review mode?
* @property {boolean} resultsprintquestions - Show questions in printed results?
* @property {boolean} resultsprintadvice - Show advice in printed results?
* @memberof Numbas.Exam
* @instance
*/
Expand Down Expand Up @@ -23993,6 +24015,8 @@ Exam.prototype = /** @lends Numbas.Exam.prototype */ {
reviewShowFeedback: true,
reviewShowExpectedAnswer: true,
reviewShowAdvice: true,
resultsprintquestions: true,
resultsprintadvice: true,
diagnosticScript: 'diagnosys',
customDiagnosticScript: ''
},
Expand Down

0 comments on commit 9b00688

Please sign in to comment.