-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Error constructors to return rather than throw (#749)
* Refactor: Error constructors to return instead of "throwing" * Test: Add a test case for Error Objects in Object.prototype.toString * Fix: Make Error.prototype.toString spec compliant * Test: Add tests for Error.prototype.toString
- Loading branch information
Showing
8 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::{forward, Context}; | ||
|
||
#[test] | ||
fn error_to_string() { | ||
let mut ctx = Context::new(); | ||
let init = r#" | ||
let e = new Error('1'); | ||
let name = new Error(); | ||
let message = new Error('message'); | ||
message.name = ''; | ||
let range_e = new RangeError('2'); | ||
let ref_e = new ReferenceError('3'); | ||
let syntax_e = new SyntaxError('4'); | ||
let type_e = new TypeError('5'); | ||
"#; | ||
forward(&mut ctx, init); | ||
assert_eq!(forward(&mut ctx, "e.toString()"), "\"Error: 1\""); | ||
assert_eq!(forward(&mut ctx, "name.toString()"), "\"Error\""); | ||
assert_eq!(forward(&mut ctx, "message.toString()"), "\"message\""); | ||
assert_eq!(forward(&mut ctx, "range_e.toString()"), "\"RangeError: 2\""); | ||
assert_eq!( | ||
forward(&mut ctx, "ref_e.toString()"), | ||
"\"ReferenceError: 3\"" | ||
); | ||
assert_eq!( | ||
forward(&mut ctx, "syntax_e.toString()"), | ||
"\"SyntaxError: 4\"" | ||
); | ||
assert_eq!(forward(&mut ctx, "type_e.toString()"), "\"TypeError: 5\""); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters