aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/compress/asm.js4
-rw-r--r--test/compress/assignment.js238
2 files changed, 240 insertions, 2 deletions
diff --git a/test/compress/asm.js b/test/compress/asm.js
index f392e78e..9b227326 100644
--- a/test/compress/asm.js
+++ b/test/compress/asm.js
@@ -90,13 +90,13 @@ asm_mixed: {
}
function no_asm_GeometricMean(stdlib, foreign, buffer) {
function logSum(start, end) {
- start = 0 | start, end = 0 | end;
+ start |= 0, end |= 0;
var sum = 0, p = 0, q = 0;
for (p = start << 3, q = end << 3; (0 | p) < (0 | q); p = p + 8 | 0) sum += +log(values[p >> 3]);
return +sum;
}
function geometricMean(start, end) {
- return start = 0 | start, end = 0 | end, +exp(+logSum(start, end) / +(end - start | 0));
+ return start |= 0, end |= 0, +exp(+logSum(start, end) / +(end - start | 0));
}
var exp = stdlib.Math.exp, log = stdlib.Math.log, values = new stdlib.Float64Array(buffer);
return { geometricMean: geometricMean };
diff --git a/test/compress/assignment.js b/test/compress/assignment.js
new file mode 100644
index 00000000..903380a9
--- /dev/null
+++ b/test/compress/assignment.js
@@ -0,0 +1,238 @@
+op_equals_left_local_var: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ var x;
+
+ x = x + 3;
+ x = x - 3;
+ x = x / 3;
+ x = x * 3;
+ x = x >> 3;
+ x = x << 3;
+ x = x >>> 3;
+ x = x | 3;
+ x = x ^ 3;
+ x = x % 3;
+ x = x & 3;
+
+ x = x + g();
+ x = x - g();
+ x = x / g();
+ x = x * g();
+ x = x >> g();
+ x = x << g();
+ x = x >>> g();
+ x = x | g();
+ x = x ^ g();
+ x = x % g();
+ x = x & g();
+ }
+ expect: {
+ var x;
+
+ x += 3;
+ x -= 3;
+ x /= 3;
+ x *= 3;
+ x >>= 3;
+ x <<= 3;
+ x >>>= 3;
+ x |= 3;
+ x ^= 3;
+ x %= 3;
+ x &= 3;
+
+ x += g();
+ x -= g();
+ x /= g();
+ x *= g();
+ x >>= g();
+ x <<= g();
+ x >>>= g();
+ x |= g();
+ x ^= g();
+ x %= g();
+ x &= g();
+ }
+}
+
+op_equals_right_local_var: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ var x;
+
+ x = (x -= 2) ^ x;
+
+ x = 3 + x;
+ x = 3 - x;
+ x = 3 / x;
+ x = 3 * x;
+ x = 3 >> x;
+ x = 3 << x;
+ x = 3 >>> x;
+ x = 3 | x;
+ x = 3 ^ x;
+ x = 3 % x;
+ x = 3 & x;
+
+ x = g() + x;
+ x = g() - x;
+ x = g() / x;
+ x = g() * x;
+ x = g() >> x;
+ x = g() << x;
+ x = g() >>> x;
+ x = g() | x;
+ x = g() ^ x;
+ x = g() % x;
+ x = g() & x;
+ }
+ expect: {
+ var x;
+
+ x = (x -= 2) ^ x;
+
+ x = 3 + x;
+ x = 3 - x;
+ x = 3 / x;
+ x *= 3;
+ x = 3 >> x;
+ x = 3 << x;
+ x = 3 >>> x;
+ x |= 3;
+ x ^= 3;
+ x = 3 % x;
+ x &= 3;
+
+ x = g() + x;
+ x = g() - x;
+ x = g() / x;
+ x = g() * x;
+ x = g() >> x;
+ x = g() << x;
+ x = g() >>> x;
+ x = g() | x;
+ x = g() ^ x;
+ x = g() % x;
+ x = g() & x;
+ }
+}
+op_equals_left_global_var: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ x = x + 3;
+ x = x - 3;
+ x = x / 3;
+ x = x * 3;
+ x = x >> 3;
+ x = x << 3;
+ x = x >>> 3;
+ x = x | 3;
+ x = x ^ 3;
+ x = x % 3;
+ x = x & 3;
+
+ x = x + g();
+ x = x - g();
+ x = x / g();
+ x = x * g();
+ x = x >> g();
+ x = x << g();
+ x = x >>> g();
+ x = x | g();
+ x = x ^ g();
+ x = x % g();
+ x = x & g();
+ }
+ expect: {
+ x += 3;
+ x -= 3;
+ x /= 3;
+ x *= 3;
+ x >>= 3;
+ x <<= 3;
+ x >>>= 3;
+ x |= 3;
+ x ^= 3;
+ x %= 3;
+ x &= 3;
+
+ x += g();
+ x -= g();
+ x /= g();
+ x *= g();
+ x >>= g();
+ x <<= g();
+ x >>>= g();
+ x |= g();
+ x ^= g();
+ x %= g();
+ x &= g();
+ }
+}
+
+op_equals_right_global_var: {
+ options = {
+ evaluate: true,
+ }
+ input: {
+ x = (x -= 2) ^ x;
+
+ x = 3 + x;
+ x = 3 - x;
+ x = 3 / x;
+ x = 3 * x;
+ x = 3 >> x;
+ x = 3 << x;
+ x = 3 >>> x;
+ x = 3 | x;
+ x = 3 ^ x;
+ x = 3 % x;
+ x = 3 & x;
+
+ x = g() + x;
+ x = g() - x;
+ x = g() / x;
+ x = g() * x;
+ x = g() >> x;
+ x = g() << x;
+ x = g() >>> x;
+ x = g() | x;
+ x = g() ^ x;
+ x = g() % x;
+ x = g() & x;
+ }
+ expect: {
+ x = (x -= 2) ^ x;
+
+ x = 3 + x;
+ x = 3 - x;
+ x = 3 / x;
+ x *= 3;
+ x = 3 >> x;
+ x = 3 << x;
+ x = 3 >>> x;
+ x |= 3;
+ x ^= 3;
+ x = 3 % x;
+ x &= 3;
+
+ x = g() + x;
+ x = g() - x;
+ x = g() / x;
+ x = g() * x;
+ x = g() >> x;
+ x = g() << x;
+ x = g() >>> x;
+ x = g() | x;
+ x = g() ^ x;
+ x = g() % x;
+ x = g() & x;
+ }
+}