summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-10-30 17:32:28 -0700
committerAlon Zakai <alonzakai@gmail.com>2015-10-30 17:32:28 -0700
commit4a99322972bd744cd97825f6373f1eee3b3d35b1 (patch)
tree15f625e59e75f360cbc5831d66dc3cf6fd5a3543 /test
parentb8b69e896b18efbe553bf1c01e4eb3acbfb909f1 (diff)
downloadbinaryen-4a99322972bd744cd97825f6373f1eee3b3d35b1.tar.gz
binaryen-4a99322972bd744cd97825f6373f1eee3b3d35b1.tar.bz2
binaryen-4a99322972bd744cd97825f6373f1eee3b3d35b1.zip
handle aliasing local and global
Diffstat (limited to 'test')
-rw-r--r--test/unit.asm.js11
-rw-r--r--test/unit.wast68
2 files changed, 68 insertions, 11 deletions
diff --git a/test/unit.asm.js b/test/unit.asm.js
index db14f721b..987374fe2 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -2,6 +2,8 @@ function () {
"use asm";
var t = global.NaN, u = global.Infinity;
+ var Int = 0;
+ var Double = 0.0;
function big_negative() {
var temp = 0.0;
@@ -14,11 +16,18 @@ function () {
function importedDoubles() {
var temp = 0.0;
temp = t + u + (-u) + (-t);
+ if (Int > 0) return -3.4;
+ if (Double > 0.0) return 5.6;
+ return 1.2;
}
function doubleCompares(x, y) {
x = +x;
y = +y;
- if (x > 0.0) return 0.0;
+ var t = +0;
+ var Int = 0.0, Double = 0; // confusing with globals
+ if (x > 0.0) return 1.2;
+ if (Int > 0.0) return -3.4;
+ if (Double > 0) return 5.6;
if (x < y) return +x;
return +y;
}
diff --git a/test/unit.wast b/test/unit.wast
index 72e124b41..554751130 100644
--- a/test/unit.wast
+++ b/test/unit.wast
@@ -24,34 +24,64 @@
)
)
)
- (func $importedDoubles
+ (func $importedDoubles (result f64)
(local $temp f64)
- (set_local $temp
- (f64.add
+ (block $topmost
+ (set_local $temp
(f64.add
(f64.add
- (f64.load align=8
- (i32.const 8)
+ (f64.add
+ (f64.load align=8
+ (i32.const 8)
+ )
+ (f64.load align=8
+ (i32.const 16)
+ )
)
- (f64.load align=8
- (i32.const 16)
+ (f64.neg
+ (f64.load align=8
+ (i32.const 16)
+ )
)
)
(f64.neg
(f64.load align=8
- (i32.const 16)
+ (i32.const 8)
)
)
)
- (f64.neg
+ )
+ (if
+ (i32.gt_s
+ (i32.load align=4
+ (i32.const 24)
+ )
+ (i32.const 0)
+ )
+ (break $topmost
+ (f64.const -3.4)
+ )
+ )
+ (if
+ (f64.gt
(f64.load align=8
- (i32.const 8)
+ (i32.const 32)
)
+ (f64.const 0)
)
+ (break $topmost
+ (f64.const 5.6)
+ )
+ )
+ (break $topmost
+ (f64.const 1.2)
)
)
)
(func $doubleCompares (param $x f64) (param $y f64) (result f64)
+ (local $t f64)
+ (local $Int f64)
+ (local $Double i32)
(block $topmost
(if
(f64.gt
@@ -59,8 +89,26 @@
(f64.const 0)
)
(break $topmost
+ (f64.const 1.2)
+ )
+ )
+ (if
+ (f64.gt
+ (get_local $Int)
(f64.const 0)
)
+ (break $topmost
+ (f64.const -3.4)
+ )
+ )
+ (if
+ (i32.gt_s
+ (get_local $Double)
+ (i32.const 0)
+ )
+ (break $topmost
+ (f64.const 5.6)
+ )
)
(if
(f64.lt