mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Merge pull request #850 from paulkaplan/fix-null-params
Do not return "null" when cannot find argument param.
This commit is contained in:
commit
405a56aa5e
2 changed files with 17 additions and 4 deletions
|
@ -15,8 +15,8 @@ class Scratch3ProcedureBlocks {
|
||||||
return {
|
return {
|
||||||
procedures_definition: this.definition,
|
procedures_definition: this.definition,
|
||||||
procedures_call: this.call,
|
procedures_call: this.call,
|
||||||
argument_reporter_string_number: this.param,
|
argument_reporter_string_number: this.argumentReporterStringNumber,
|
||||||
argument_reporter_boolean: this.param
|
argument_reporter_boolean: this.argumentReporterBoolean
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +47,19 @@ class Scratch3ProcedureBlocks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
param (args, util) {
|
argumentReporterStringNumber (args, util) {
|
||||||
const value = util.getParam(args.VALUE);
|
const value = util.getParam(args.VALUE);
|
||||||
|
if (value === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
argumentReporterBoolean (args, util) {
|
||||||
|
const value = util.getParam(args.VALUE);
|
||||||
|
if (value === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,8 @@ test('PushGetParam', t => {
|
||||||
th.pushParam('testParam', 'testValue');
|
th.pushParam('testParam', 'testValue');
|
||||||
t.strictEquals(th.peekStackFrame().params.testParam, 'testValue');
|
t.strictEquals(th.peekStackFrame().params.testParam, 'testValue');
|
||||||
t.strictEquals(th.getParam('testParam'), 'testValue');
|
t.strictEquals(th.getParam('testParam'), 'testValue');
|
||||||
|
// Params outside of define stack always evaluate to null
|
||||||
|
t.strictEquals(th.getParam('nonExistentParam'), null);
|
||||||
|
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue