Chromium Code Reviews| Index: test/mjsunit/asm/asm-validation.js |
| diff --git a/test/mjsunit/asm/asm-validation.js b/test/mjsunit/asm/asm-validation.js |
| index eae282ca570ace79bcd2ca6fdd7cc0d68afbafeb..8244f870ed1071ca0e5bb45f8b7923865d4a16bd 100644 |
| --- a/test/mjsunit/asm/asm-validation.js |
| +++ b/test/mjsunit/asm/asm-validation.js |
| @@ -8,6 +8,62 @@ function assertValidAsm(func) { |
| assertTrue(%IsAsmWasmCode(func)); |
| } |
| +(function TestConst() { |
| + function Module(s) { |
| + "use asm"; |
| + var fround = s.Math.fround; |
| + // Global constants. These are treated just like numeric literals. |
| + const fConst = fround(-3.0); |
| + const dConst = -3.0; |
| + const iConst = -3; |
| + |
| + // consts can be used to initialize other consts. |
| + const fPrime = fConst; |
| + |
| + // The following methods verify that return statements with global constants |
| + // do not need type annotations. |
| + function f() { |
| + return fPrime; |
| + } |
| + function d() { |
| + return dConst; |
| + } |
| + function i() { |
| + return iConst; |
| + } |
| + |
| + // The following methods verify that locals initialized with global |
| + // constants dono need type annotations. |
|
bradnelson
2016/10/19 21:52:07
dono -> do not ?
John
2016/10/20 15:13:22
Done.
|
| + function fVar() { |
| + var v = fPrime; |
| + return fround(v); |
| + } |
| + function iVar() { |
| + var v = iConst; |
| + return v|0; |
| + } |
| + function dVar() { |
| + var v = dConst; |
| + return +v; |
| + } |
| + |
| + return { |
| + f: f, d: d, i: i, |
| + fVar: fVar, dVar: dVar, iVar: iVar, |
| + }; |
| + } |
| + var m = Module(this); |
| + assertValidAsm(Module); |
| + |
| + assertEquals(-3, m.i()); |
| + assertEquals(-3.0, m.d()); |
| + assertEquals(Math.fround(-3.0), m.f()); |
| + |
| + assertEquals(-3, m.iVar()); |
| + assertEquals(-3.0, m.dVar()); |
| + assertEquals(Math.fround(-3.0), m.fVar()); |
| +})(); |
| + |
| (function TestModuleArgs() { |
| function Module1(stdlib) { |
| "use asm"; |