File tree Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Expand file tree Collapse file tree 2 files changed +56
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ const engine = function(options) {
84
84
if ( typeof options . parser . version === "string" ) {
85
85
let version = options . parser . version . split ( "." ) ;
86
86
version = parseInt ( version [ 0 ] ) * 100 + parseInt ( version [ 1 ] ) ;
87
- if ( isNaN ( options . parser . version ) ) {
87
+ if ( isNaN ( version ) ) {
88
88
throw new Error ( "Bad version number : " + options . parser . version ) ;
89
89
} else {
90
90
options . parser . version = version ;
@@ -93,7 +93,7 @@ const engine = function(options) {
93
93
throw new Error ( "Expecting a number for version" ) ;
94
94
}
95
95
if ( options . parser . version < 500 || options . parser . version > 704 ) {
96
- throw new Error ( "Can only handle versions between 5.0 to 7.4 " ) ;
96
+ throw new Error ( "Can only handle versions between 5.x to 7.x " ) ;
97
97
}
98
98
}
99
99
}
Original file line number Diff line number Diff line change
1
+ const parser = require ( "./main" ) ;
2
+
3
+ describe ( "Test versions" , function ( ) {
4
+ it ( "unserialize a version string" , function ( ) {
5
+ const test = parser . create ( {
6
+ parser : {
7
+ version : "7.3"
8
+ }
9
+ } ) ;
10
+ expect ( test . parser . version ) . toEqual ( 703 ) ;
11
+ } ) ;
12
+ it ( "unserialize a version string - with bugfix ignored" , function ( ) {
13
+ const test = parser . create ( {
14
+ parser : {
15
+ version : "7.3.5"
16
+ }
17
+ } ) ;
18
+ expect ( test . parser . version ) . toEqual ( 703 ) ;
19
+ } ) ;
20
+ it ( "fail to parse array" , function ( ) {
21
+ expect (
22
+ parser . create . bind ( null , {
23
+ parser : {
24
+ version : [ 701 ]
25
+ }
26
+ } )
27
+ ) . toThrow ( new Error ( "Expecting a number for version" ) ) ;
28
+ } ) ;
29
+ it ( "fail to parse bad version numbers" , function ( ) {
30
+ expect (
31
+ parser . create . bind ( null , {
32
+ parser : {
33
+ version : "x.y.z"
34
+ }
35
+ } )
36
+ ) . toThrow ( new Error ( "Bad version number : x.y.z" ) ) ;
37
+ } ) ;
38
+ it ( "unhandled version" , function ( ) {
39
+ expect (
40
+ parser . create . bind ( null , {
41
+ parser : {
42
+ version : "4.9"
43
+ }
44
+ } )
45
+ ) . toThrow ( new Error ( "Can only handle versions between 5.x to 7.x" ) ) ;
46
+ expect (
47
+ parser . create . bind ( null , {
48
+ parser : {
49
+ version : "8.9"
50
+ }
51
+ } )
52
+ ) . toThrow ( new Error ( "Can only handle versions between 5.x to 7.x" ) ) ;
53
+ } ) ;
54
+ } ) ;
You can’t perform that action at this time.
0 commit comments