Added test cases for #104.
authorJustin Lau <justin@tclau.com>
Sun, 5 May 2013 11:54:27 +0000 (19:54 +0800)
committerMihai Bazon <mihai@bazon.net>
Wed, 8 May 2013 13:22:48 +0000 (16:22 +0300)
Signed-off-by: Justin Lau <justin@tclau.com>
test/compress/issue-143.js [new file with mode: 0644]

diff --git a/test/compress/issue-143.js b/test/compress/issue-143.js
new file mode 100644 (file)
index 0000000..4c79790
--- /dev/null
@@ -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