-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix spread in new and call expressions (#1021)
* Fix spread in new and call expressions * Fix formatting * Add unit tests * Fix unit test Co-authored-by: tofpie <tofpie@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
62 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::exec; | ||
|
||
#[test] | ||
fn spread_with_new() { | ||
let scenario = r#" | ||
function F(m) { | ||
this.m = m; | ||
} | ||
function f(...args) { | ||
return new F(...args); | ||
} | ||
let a = f('message'); | ||
a.m; | ||
"#; | ||
assert_eq!(&exec(scenario), r#""message""#); | ||
} | ||
|
||
#[test] | ||
fn spread_with_call() { | ||
let scenario = r#" | ||
function f(m) { | ||
return m; | ||
} | ||
function g(...args) { | ||
return f(...args); | ||
} | ||
let a = g('message'); | ||
a; | ||
"#; | ||
assert_eq!(&exec(scenario), r#""message""#); | ||
} |