33// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44//-------------------------------------------------------------------------------------------------------
55
6+ WScript . LoadScriptFile ( "..\\UnitTestFramework\\UnitTestFramework.js" ) ;
7+
68function foo ( ) { }
79
810var all = [ undefined , null ,
@@ -12,14 +14,14 @@ var all = [ undefined, null,
1214 1 << 32 , - ( 1 << 32 ) , ( 1 << 32 ) - 1 , 1 << 31 , - ( 1 << 31 ) , 1 << 25 , - 1 << 25 , 65536 , 46341 ,
1315 Number . MIN_VALUE , Number . NaN , Number . POSITIVE_INFINITY , Number . NEGATIVE_INFINITY ,
1416 new Number ( NaN ) , new Number ( + 0 ) , new Number ( - 0 ) , new Number ( 0 ) , new Number ( 1 ) ,
15- new Number ( 10.0 ) , new Number ( 10.1 ) ,
16- new Number ( Number . MIN_VALUE ) , new Number ( Number . NaN ) ,
17+ new Number ( 10.0 ) , new Number ( 10.1 ) ,
18+ new Number ( Number . MIN_VALUE ) , new Number ( Number . NaN ) ,
1719 new Number ( Number . POSITIVE_INFINITY ) , new Number ( Number . NEGATIVE_INFINITY ) ,
1820 "" , "hello" , "hel" + "lo" , "+0" , "-0" , "0" , "1" , "10.0" , "10.1" ,
1921 new String ( "" ) , new String ( "hello" ) , new String ( "he" + "llo" ) ,
2022 new Object ( ) , [ 1 , 2 , 3 ] , new Object ( ) , [ 1 , 2 , 3 ] , foo
2123 ] ;
22-
24+
2325function AsmModule ( stdlib , foreign , buffer ) {
2426 "use asm" ;
2527
@@ -32,7 +34,7 @@ function AsmModule(stdlib,foreign,buffer) {
3234 var fd2 = + foreign . d2 ;
3335 var fun1 = foreign . fun1 ;
3436 var fun2 = foreign . fun2 ;
35-
37+
3638 // stdlib immutable variable type double
3739 var sInf = stdlib . Infinity , sNaN = stdlib . NaN ;
3840 // stdlib math (double) -> double
@@ -67,7 +69,7 @@ function AsmModule(stdlib,foreign,buffer) {
6769 var PI = stdlib . Math . PI ;
6870 var SQRT1_2 = stdlib . Math . SQRT1_2 ;
6971 var SQRT2 = stdlib . Math . SQRT2 ;
70-
72+
7173 //views
7274 var a = new stdlib . Int8Array ( buffer ) ;
7375 var b = new stdlib . Int16Array ( buffer ) ;
@@ -77,62 +79,62 @@ function AsmModule(stdlib,foreign,buffer) {
7779 var f = new stdlib . Uint32Array ( buffer ) ;
7880 var g = new stdlib . Float32Array ( buffer ) ;
7981 var h = new stdlib . Float64Array ( buffer ) ;
80-
82+
8183 function f1 ( x ) {
8284 x = + x ;
8385 return + acos ( x ) ;
8486 }
85-
87+
8688 function f2 ( x ) {
8789 x = + x ;
8890 return + asin ( x ) ;
8991 }
90-
92+
9193 function f3 ( x ) {
9294 x = + x ;
9395 return + atan ( x ) ;
9496 }
95-
97+
9698 function f4 ( x ) {
9799 x = + x ;
98100 return + cos ( x ) ;
99101 }
100-
102+
101103 function f5 ( x ) {
102104 x = + x ;
103105 return + sin ( x ) ;
104106 }
105-
107+
106108 function f6 ( x ) {
107109 x = + x ;
108110 return + tan ( x ) ;
109111 }
110-
112+
111113 function f7 ( x ) {
112114 x = + x ;
113115 return + ceil ( x ) ;
114116 }
115-
117+
116118 function f8 ( x ) {
117119 x = + x ;
118120 return + floor ( x ) ;
119121 }
120-
122+
121123 function f9 ( x ) {
122124 x = + x ;
123125 return + exp ( x ) ;
124126 }
125-
127+
126128 function f10 ( x ) {
127129 x = + x ;
128130 return + log ( x ) ;
129131 }
130-
132+
131133 function f11 ( x ) {
132134 x = + x ;
133135 return + sqrt ( x ) ;
134136 }
135-
137+
136138 // stdlib math (signed) -> signed ^ (doublish) -> double
137139 function f12 ( x ) {
138140 x = + x ;
@@ -142,14 +144,14 @@ function AsmModule(stdlib,foreign,buffer) {
142144 x = x | 0 ;
143145 return abs ( x | 0 ) | 0 ;
144146 }
145-
147+
146148 // stdlib math (doublish, doublish) -> double
147149 function f14 ( x , y ) {
148150 x = + x ;
149151 y = + y ;
150152 return + atan2 ( x , y ) ;
151153 }
152-
154+
153155 function f15 ( x , y ) {
154156 x = + x ;
155157 y = + y ;
@@ -161,29 +163,29 @@ function AsmModule(stdlib,foreign,buffer) {
161163 y = y | 0 ;
162164 return imul ( x , y ) | 0 ;
163165 }
164-
166+
165167 function f17 ( x ) {
166168 x = fround ( x ) ;
167169 return fround ( ceil ( x ) ) ;
168170 }
169-
171+
170172 function f18 ( x ) {
171173 x = fround ( x ) ;
172174 return fround ( floor ( x ) ) ;
173175 }
174-
176+
175177 function f19 ( x ) {
176178 x = fround ( x ) ;
177179 return fround ( sqrt ( x ) ) ;
178180 }
179-
181+
180182 function f20 ( x ) {
181183 x = fround ( x ) ;
182184 return fround ( abs ( x ) ) ;
183185 }
184-
185-
186- return {
186+
187+
188+ return {
187189 f1 : f1 ,
188190 f2 : f2 ,
189191 f3 : f3 ,
@@ -215,7 +217,19 @@ var asmModule = AsmModule(global,env,buffer);
215217for ( var i = 0 ; i < all . length ; ++ i ) {
216218 print ( "f1 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f1 ( all [ i ] ) ) ) ;
217219 print ( "f2 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f2 ( all [ i ] ) ) ) ;
218- print ( "f3 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f3 ( all [ i ] ) ) ) ;
220+
221+ if ( ( i == 11 || i == 41 || i == 54 ) && all [ i ] == 10 ) {
222+ // f3 => atan(f->1.47....) OSX != Windows / Linux
223+ if ( WScript . Platform && WScript . Platform . OS == "darwin" )
224+ {
225+ assert . areEqual ( asmModule . f3 ( all [ i ] ) , 1.4711276743037344 ) ;
226+ } else {
227+ assert . areEqual ( asmModule . f3 ( all [ i ] ) , 1.4711276743037347 ) ;
228+ }
229+ } else {
230+ print ( "f3 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f3 ( all [ i ] ) ) ) ;
231+ }
232+
219233 print ( "f4 (a[" + i + "](" + all [ i ] + "))= " + Math . round ( asmModule . f4 ( all [ i ] ) ) ) ;
220234 print ( "f5 (a[" + i + "](" + all [ i ] + "))= " + Math . round ( asmModule . f5 ( all [ i ] ) ) ) ;
221235 print ( "f6 (a[" + i + "](" + all [ i ] + "))= " + Math . round ( asmModule . f6 ( all [ i ] ) ) ) ;
@@ -231,8 +245,8 @@ for (var i=0; i<all.length; ++i) {
231245 print ( "f19 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f19 ( all [ i ] ) ) ) ;
232246 print ( "f20 (a[" + i + "](" + all [ i ] + "))= " + ( asmModule . f20 ( all [ i ] ) ) ) ;
233247}
234- for ( var i = 0 ; i < all . length ; ++ i ) {
235- for ( var j = 0 ; j < all . length ; ++ j ) {
248+ for ( var i = 0 ; i < all . length ; ++ i ) {
249+ for ( var j = 0 ; j < all . length ; ++ j ) {
236250 // rounding atan2, because crt call gives us slightly different precision
237251 print ( "f14 (a[" + i + "](" + all [ i ] + ") , a[" + j + "](" + all [ j ] + ") )= " + Math . round ( asmModule . f14 ( all [ i ] , all [ j ] ) ) ) ;
238252 print ( "f15 (a[" + i + "](" + all [ i ] + ") , a[" + j + "](" + all [ j ] + ") )= " + Math . round ( asmModule . f15 ( all [ i ] , all [ j ] ) ) | 0 ) ;
0 commit comments