string-octal-literal.js (2619B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 es6id: 20.1.1.1 6 description: Mathematical value of valid octal integer literals 7 info: | 8 20.1.1.1 Number ( [ value ] ) 9 10 When Number is called with argument number, the following steps are taken: 11 12 1. If no arguments were passed to this function invocation, let n be +0. 13 2. Else, let n be ToNumber(value). 14 15 [...] 16 17 7.1.3.1 ToNumber Applied to the String Type 18 19 All grammar symbols not explicitly defined above have the definitions used 20 in the Lexical Grammar for numeric literals (11.8.3) 21 22 [...] 23 24 The MV of OctalIntegerLiteral :: 0o OctalDigits is the MV of OctalDigits. 25 The MV of OctalIntegerLiteral :: 0O OctalDigits is the MV of OctalDigits. 26 The MV of OctalDigits :: OctalDigit is the MV of OctalDigit. 27 The MV of OctalDigits :: OctalDigits OctalDigit is (the MV of OctalDigits × 28 8) plus the MV of OctalDigit. 29 ---*/ 30 31 assert.sameValue(Number('0o0'), 0, 'lower-case head'); 32 assert.sameValue(Number('0O0'), 0, 'upper-case head'); 33 assert.sameValue(Number('0o00'), 0, 'lower-case head with leading zeros'); 34 assert.sameValue(Number('0O00'), 0, 'upper-case head with leading zeros'); 35 36 assert.sameValue(Number('0o1'), 1, 'lower-case head'); 37 assert.sameValue(Number('0O1'), 1, 'upper-case head'); 38 assert.sameValue(Number('0o01'), 1, 'lower-case head with leading zeros'); 39 assert.sameValue(Number('0O01'), 1, 'upper-case head with leading zeros'); 40 41 assert.sameValue(Number('0o7'), 7, 'lower-case head'); 42 assert.sameValue(Number('0O7'), 7, 'upper-case head'); 43 assert.sameValue(Number('0o07'), 7, 'lower-case head with leading zeros'); 44 assert.sameValue(Number('0O07'), 7, 'upper-case head with leading zeros'); 45 46 assert.sameValue(Number('0o10'), 8, 'lower-case head'); 47 assert.sameValue(Number('0O10'), 8, 'upper-case head'); 48 assert.sameValue(Number('0o010'), 8, 'lower-case head with leading zeros'); 49 assert.sameValue(Number('0O010'), 8, 'upper-case head with leading zeros'); 50 51 assert.sameValue(Number('0o11'), 9, 'lower-case head'); 52 assert.sameValue(Number('0O11'), 9, 'upper-case head'); 53 assert.sameValue(Number('0o011'), 9, 'lower-case head with leading zeros'); 54 assert.sameValue(Number('0O011'), 9, 'upper-case head with leading zeros'); 55 56 assert.sameValue(Number('0o77'), 63, 'lower-case head'); 57 assert.sameValue(Number('0O77'), 63, 'upper-case head'); 58 assert.sameValue(Number('0o077'), 63, 'lower-case head with leading zeros'); 59 assert.sameValue(Number('0O077'), 63, 'upper-case head with leading zeros'); 60 61 reportCompare(0, 0);