File tree 3 files changed +50
-5
lines changed
3 files changed +50
-5
lines changed Original file line number Diff line number Diff line change 4
4
* @url http://glayzzle.com
5
5
*/
6
6
7
+ "use strict" ;
8
+
7
9
/* istanbul ignore else */
8
10
if ( process . arch == 'x64' ) {
9
11
var SIZEOF_LONG = 8 ;
10
- var MAX_LENGTH_OF_LONG = 20 ;
12
+ var MAX_LENGTH_OF_LONG = 19 ;
11
13
var long_min_digits = "9223372036854775808" ;
12
14
} else {
13
15
var SIZEOF_LONG = 4 ;
14
- var MAX_LENGTH_OF_LONG = 11 ;
16
+ var MAX_LENGTH_OF_LONG = 10 ;
15
17
var long_min_digits = "2147483648" ;
16
18
}
17
19
@@ -76,8 +78,10 @@ module.exports = {
76
78
return this . tok . T_LNUMBER ;
77
79
} else {
78
80
if (
79
- this . yytext . length == MAX_LENGTH_OF_LONG
80
- && this . yytext < long_min_digits
81
+ this . yytext . length < MAX_LENGTH_OF_LONG || (
82
+ this . yytext . length == MAX_LENGTH_OF_LONG
83
+ && this . yytext < long_min_digits
84
+ )
81
85
) {
82
86
return this . tok . T_LNUMBER ;
83
87
}
Original file line number Diff line number Diff line change 1
1
var should = require ( "should" ) ;
2
- var parser = require ( '../src/index ' ) ;
2
+ var parser = require ( './main ' ) ;
3
3
4
4
describe ( 'Test AST structure' , function ( ) {
5
5
Original file line number Diff line number Diff line change
1
+ var should = require ( "should" ) ;
2
+ var parser = require ( './main' ) ;
3
+
4
+ describe ( 'Test numbers' , function ( ) {
5
+
6
+ describe ( 'comon tests' , function ( ) {
7
+ var ast = parser . parseEval ( [
8
+ '$a = -1.5;' ,
9
+ '$b = 1234;' ,
10
+ '$c = 9223372036854775807;' ,
11
+ '$c = 9223372036854775808;' ,
12
+ '$d = 0x1A;' ,
13
+ '$d = 0xFF;' ,
14
+ '$e = 0b1011;' ,
15
+ '$f = 0123;' ,
16
+ '$g = 1.2e3;' ,
17
+ '$h = 7E-10;'
18
+ ] . join ( '\n' ) ) ;
19
+ it ( 'should be float' , function ( ) {
20
+ ast . children [ 0 ] . right . kind . should . be . exactly ( 'number' ) ;
21
+ ast . children [ 0 ] . right . value . should . be . exactly ( '-1.5' ) ;
22
+ } ) ;
23
+
24
+ } ) ;
25
+ // @fixme should test bad syntaxes
26
+ // like 01239 (octal number with bad token)
27
+ describe ( 'edge tests' , function ( ) {
28
+ var ast = parser . parseEval ( [
29
+ '$a = 0xx;' ,
30
+ '$b = 0b2;' ,
31
+ '$c = 01239;' ,
32
+ '$d = 7E-a;' ,
33
+ '$e = 7EX;'
34
+ ] . join ( '\n' ) , {
35
+ parser : {
36
+ suppressErrors : true
37
+ }
38
+ } ) ;
39
+
40
+ } ) ;
41
+ } ) ;
You can’t perform that action at this time.
0 commit comments