This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases from 2358, 2398 that pass from previous PRs (#2410)
Summary: Release Notes: None Previous PRs fixed these issues, but didn't necessarily add the test case from the issue. This PR adds the exact test cases from the issues. Closes #2358 Closes #2398 Pull Request resolved: #2410 Differential Revision: D9259118 Pulled By: cblappert fbshipit-source-id: 3eb347044865a11e2ce5262b2338b7b6e1958c60
- Loading branch information
1 parent
3503c79
commit 22a55f7
Showing
3 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function fn(x, y, obj, cond) { | ||
var arr = x; | ||
var arr2 = y; | ||
|
||
var a = obj.a; | ||
|
||
var mapper1 = function(item) { | ||
if (cond) { | ||
return a; | ||
} | ||
}; | ||
global.__optimize && __optimize(mapper1); | ||
var res = arr.map(mapper1); | ||
|
||
var mapper2 = function(item) { | ||
if (cond) { | ||
return a; | ||
} | ||
}; | ||
global.__optimize && __optimize(mapper2); | ||
var res2 = arr2.map(mapper2); | ||
|
||
return [res, res2]; | ||
} | ||
|
||
global.__optimize && __optimize(fn); | ||
|
||
global.inspect = function() { | ||
return JSON.stringify(fn([1, 2], [3, 4], { a: 5 }, true)); | ||
}; |
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,26 @@ | ||
function fn(x, y, obj, cond) { | ||
var arr = Array.from(x); | ||
var arr2 = Array.from(y); | ||
|
||
var a = obj.a; | ||
|
||
var res = arr.map(function(item) { | ||
if (cond) { | ||
return a; | ||
} | ||
}); | ||
|
||
var res2 = arr2.map(function(item) { | ||
if (cond) { | ||
return a; | ||
} | ||
}); | ||
|
||
return [res, res2]; | ||
} | ||
|
||
global.__optimize && __optimize(fn); | ||
|
||
global.inspect = function() { | ||
return JSON.stringify(fn([1, 2], [3, 4], { a: 5 }, true)); | ||
}; |
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,42 @@ | ||
function fn(props, cond) { | ||
var arr = Array.from(props.x); | ||
var newObj; | ||
|
||
if (cond) { | ||
var _ref8; | ||
var value = | ||
(_ref8 = props.feedback) != null | ||
? (_ref8 = _ref8.display_comments) != null | ||
? _ref8.ordering_mode | ||
: _ref8 | ||
: _ref8; | ||
|
||
var fn2 = function() { | ||
return value; | ||
}; | ||
|
||
var res = arr.map(function(item) { | ||
return item[value]; | ||
}); | ||
} | ||
|
||
return [res, fn2]; | ||
} | ||
|
||
global.__optimize && __optimize(fn); | ||
|
||
global.inspect = function() { | ||
let [res, fn2] = fn( | ||
{ | ||
x: [1, 2], | ||
feedback: { | ||
display_comments: { | ||
ordering_mode: "foo", | ||
}, | ||
}, | ||
}, | ||
true | ||
); | ||
res.push(fn2()); | ||
return JSON.stringify(res); | ||
}; |