tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

constructor-from-string-syntax-errors.js (1448B)


      1 // Copyright (C) 2017 Caio Lima. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: Invalid String into BigInt constructor should throw SyntaxError
      6 esid: sec-string-to-bigint
      7 info: |
      8  ToBigInt ( argument )
      9 
     10  String:
     11 
     12  Let n be StringToBigInt(prim).
     13  If n is NaN, throw a SyntaxError exception.
     14  Return n.
     15 
     16  StringToBigInt ( argument )
     17 
     18  Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity, decimal points, or exponents.
     19 
     20 features: [BigInt]
     21 ---*/
     22 
     23 assert.throws(SyntaxError, function() {
     24  BigInt("10n");
     25 });
     26 
     27 assert.throws(SyntaxError, function() {
     28  BigInt("10x");
     29 });
     30 
     31 assert.throws(SyntaxError, function() {
     32  BigInt("10b");
     33 });
     34 
     35 assert.throws(SyntaxError, function() {
     36  BigInt("10.5");
     37 });
     38 
     39 assert.throws(SyntaxError, function() {
     40  BigInt("0b");
     41 });
     42 
     43 assert.throws(SyntaxError, function() {
     44  BigInt("-0x1");
     45 });
     46 
     47 assert.throws(SyntaxError, function() {
     48  BigInt("-0XFFab");
     49 });
     50 
     51 assert.throws(SyntaxError, function() {
     52  BigInt("0oa");
     53 });
     54 
     55 assert.throws(SyntaxError, function() {
     56  BigInt("000 12");
     57 });
     58 
     59 assert.throws(SyntaxError, function() {
     60  BigInt("0o");
     61 });
     62 
     63 assert.throws(SyntaxError, function() {
     64  BigInt("0x");
     65 });
     66 
     67 assert.throws(SyntaxError, function() {
     68  BigInt("00o");
     69 });
     70 
     71 assert.throws(SyntaxError, function() {
     72  BigInt("00b");
     73 });
     74 
     75 assert.throws(SyntaxError, function() {
     76  BigInt("00x");
     77 });
     78 
     79 reportCompare(0, 0);