Skip to content
Snippets Groups Projects
Commit 4914fa1d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Global JS function parameter validation and updated return types

Many global functions now throw an exception when null or undefined is passed
as a required parameter where null or undefined makes no sense.
e.g. "Argument #1 is an unexpected 'null' or 'undefined' value"
Example exception: is-a/has-a type functions will still return false when
passed null or undefined.

Changed global function return types:
- write() now always returns undefined
- printf() always returns a string, never undefined or garbage string
- prompt() returns null (not undefined) upon no input (as documented)

sbbs works more like jsexec:
- read(0) now returns an empty string instead of undefined
- readln(0) no longer waits for enter

jsexec works more like sbbs:
- add missing write_raw() global function, alias for write()

Include expected number of argment in "Insufficient Arguments" exception
message.

Update JSDOCS for some global methods:
- file_chmod returns boolean, not number
- flags_str requires a minimum of one argument

New tests to validate expected exceptions and return types based on usage.
parent 926b0c5e
No related branches found
No related tags found
No related merge requests found
Pipeline #7832 failed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment