Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4389848
test_throw_expressions.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
868 B
Referenced Files
None
Subscribers
None
test_throw_expressions.cjs
View Options
const assert = require("assert");
{
const fn = () => throw 42;
try {
fn();
assert(false, "arrow throw expression should throw");
} catch (error) {
assert.strictEqual(error, 42);
}
}
{
true ? 1 : throw 2;
try {
false ? 1 : throw 2;
assert(false, "conditional throw expression should throw");
} catch (error) {
assert.strictEqual(error, 2);
}
}
{
let a;
try {
a = 19 || throw 77;
88 && throw 23;
assert(false, "logical throw expression should throw");
} catch (error) {
assert.strictEqual(a + error, 42);
}
}
{
function fn(arg = throw 42) {
return arg;
}
assert.strictEqual(fn(21), 21);
try {
fn();
assert(false, "parameter initializer throw expression should throw");
} catch (error) {
assert.strictEqual(error, 42);
}
}
console.log("throw expression tests completed!");
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, May 1, 10:32 AM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
542822
Default Alt Text
test_throw_expressions.cjs (868 B)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment