UglifyJS/test/compress/issue-143.js

66 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

/**
2022-10-05 18:06:21 +00:00
* There was an incorrect sort behavior documented in issue #143:
* (x = f()) <= x x >= (x = f())
*
* For example, let the equation be:
* (a = parseInt('100')) <= a
*
* If a was an integer and has the value of 99,
* (a = parseInt('100')) <= a 100 <= 100 true
*
* When transformed incorrectly:
* a >= (a = parseInt('100')) 99 >= 100 false
*/
2022-10-05 18:06:21 +00:00
transformation_sort_order_equal: {
options = {
comparisons: true,
2018-07-01 06:34:42 +00:00
}
2022-10-05 18:06:21 +00:00
input: {
console.log((a = parseInt("100")) == a);
}
expect: {
console.log((a = parseInt("100")) == a);
}
expect_stdout: "true"
}
2022-10-05 18:06:21 +00:00
transformation_sort_order_unequal: {
options = {
comparisons: true,
2018-07-01 06:34:42 +00:00
}
2022-10-05 18:06:21 +00:00
input: {
console.log((a = parseInt("100")) != a);
}
expect: {
console.log((a = parseInt("100")) != a);
}
expect_stdout: "false"
}
2022-10-05 18:06:21 +00:00
transformation_sort_order_lesser_or_equal: {
options = {
comparisons: true,
2018-07-01 06:34:42 +00:00
}
2022-10-05 18:06:21 +00:00
input: {
console.log((a = parseInt("100")) <= a);
}
expect: {
console.log((a = parseInt("100")) <= a);
}
expect_stdout: "true"
}
2022-10-05 18:06:21 +00:00
transformation_sort_order_greater_or_equal: {
options = {
comparisons: true,
2018-07-01 06:34:42 +00:00
}
2022-10-05 18:06:21 +00:00
input: {
console.log((a = parseInt("100")) >= a);
}
expect: {
console.log((a = parseInt("100")) >= a);
}
expect_stdout: "true"
}