-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathclz32.js
90 lines (85 loc) · 1.76 KB
/
clz32.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
// intended to test inlining of Math.clz32
// compliance tests are in es6 UT folder
function module(glob, imp, b) {
var clz = glob.Math.clz32;
function f1(a)
{
a = a|0;
return clz(a);
}
function f2()
{
return clz(0);
}
function f3()
{
return clz(0x80000000);
}
function f4()
{
return clz(32768);
}
function f5()
{
return clz(NaN);
}
function f6()
{
return clz(Infinity);
}
function f7()
{
return clz(undefined);
}
function f8()
{
return clz(true);
}
function f9()
{
return clz();
}
return {
f1:f1,
f2:f2,
f3:f3,
f4:f4,
f5:f5,
f6:f6,
f7:f7,
f8:f8,
f9:f9
}
}
var global = this;
var env = {}
var heap = new ArrayBuffer(1<<20);
var m = module(global, env, heap);
print(m.f1(0));
print(m.f1(0));
print(m.f1(0x80000000));
print(m.f1(32768));
print(m.f1(NaN));
print(m.f1(Infinity));
print(m.f1(undefined));
print(m.f1(true));
print(m.f2());
print(m.f2());
print(m.f3());
print(m.f3());
print(m.f4());
print(m.f4());
print(m.f5());
print(m.f5());
print(m.f6());
print(m.f6());
print(m.f7());
print(m.f7());
print(m.f8());
print(m.f8());
print(m.f9());
print(m.f9());