aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorJustin Lau <justin@tclau.com>2013-05-05 19:54:27 +0800
committerMihai Bazon <mihai@bazon.net>2013-05-08 16:22:48 +0300
commit672699613e79c24d4e744313f5c0a51400958d8a (patch)
treedb1d84e3271d6db5a876bf867c5629b7aac37195 /test/compress
parent645d5bdbc53d2293ed329a4c55b2af2cdeb5ace2 (diff)
downloadtracifyjs-672699613e79c24d4e744313f5c0a51400958d8a.tar.gz
tracifyjs-672699613e79c24d4e744313f5c0a51400958d8a.zip
Added test cases for #104.
Signed-off-by: Justin Lau <justin@tclau.com>
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/issue-143.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/compress/issue-143.js b/test/compress/issue-143.js
new file mode 100644
index 00000000..4c79790b
--- /dev/null
+++ b/test/compress/issue-143.js
@@ -0,0 +1,48 @@
+/**
+ * There was an incorrect sort behaviour 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
+ */
+
+tranformation_sort_order_equal: {
+ options = {
+ comparisons: true,
+ };
+
+ input: { (a = parseInt('100')) == a }
+ expect: { (a = parseInt('100')) == a }
+}
+
+tranformation_sort_order_unequal: {
+ options = {
+ comparisons: true,
+ };
+
+ input: { (a = parseInt('100')) != a }
+ expect: { (a = parseInt('100')) != a }
+}
+
+tranformation_sort_order_lesser_or_equal: {
+ options = {
+ comparisons: true,
+ };
+
+ input: { (a = parseInt('100')) <= a }
+ expect: { (a = parseInt('100')) <= a }
+}
+tranformation_sort_order_greater_or_equal: {
+ options = {
+ comparisons: true,
+ };
+
+ input: { (a = parseInt('100')) >= a }
+ expect: { (a = parseInt('100')) >= a }
+} \ No newline at end of file