Debian Codegraph @

js/src/tests/test262/built-ins/parseFloat/shell.js

raw
1 // GENERATED, DO NOT EDIT
2 // file: decimalToHexString.js
3 // Copyright (C) 2017 André Bargull. All rights reserved.
4 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 description: |
7 Collection of functions used to assert the correctness of various encoding operations.
8 defines: [decimalToHexString, decimalToPercentHexString]
9 ---*/
10
11 function decimalToHexString(n) {
12 var hex = "0123456789ABCDEF";
13 n >>>= 0;
14 var s = "";
15 while (n) {
16 s = hex[n & 0xf] + s;
17 n >>>= 4;
18 }
19 while (s.length < 4) {
20 s = "0" + s;
21 }
22 return s;
23 }
24
25 function decimalToPercentHexString(n) {
26 var hex = "0123456789ABCDEF";
27 return "%" + hex[(n >> 4) & 0xf] + hex[n & 0xf];
28 }
29
30 // file: isConstructor.js
31 // Copyright (C) 2017 André Bargull. All rights reserved.
32 // This code is governed by the BSD license found in the LICENSE file.
33
34 /*---
35 description: |
36 Test if a given function is a constructor function.
37 defines: [isConstructor]
38 features: [Reflect.construct]
39 ---*/
40
41 function isConstructor(f) {
42 if (typeof f !== "function") {
43 throw new Test262Error("isConstructor invoked with a non-function value");
44 }
45
46 try {
47 Reflect.construct(function(){}, [], f);
48 } catch (e) {
49 return false;
50 }
51 return true;
52 }