mirror of https://github.com/boa-dev/boa.git
Browse Source
* 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.toStringpull/802/head
João Borges
4 years ago
committed by
GitHub
8 changed files with 73 additions and 12 deletions
@ -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\""); |
||||
} |
Loading…
Reference in new issue