1+ // Flags: --expose_internals 
12'use strict' ; 
23require ( '../common' ) ; 
34var  assert  =  require ( 'assert' ) ; 
@@ -12,39 +13,41 @@ var O_RDWR = fs.constants.O_RDWR || 0;
1213var  O_TRUNC  =  fs . constants . O_TRUNC  ||  0 ; 
1314var  O_WRONLY  =  fs . constants . O_WRONLY  ||  0 ; 
1415
15- assert . equal ( fs . _stringToFlags ( 'r' ) ,  O_RDONLY ) ; 
16- assert . equal ( fs . _stringToFlags ( 'r+' ) ,  O_RDWR ) ; 
17- assert . equal ( fs . _stringToFlags ( 'w' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY ) ; 
18- assert . equal ( fs . _stringToFlags ( 'w+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR ) ; 
19- assert . equal ( fs . _stringToFlags ( 'a' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY ) ; 
20- assert . equal ( fs . _stringToFlags ( 'a+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR ) ; 
21- 
22- assert . equal ( fs . _stringToFlags ( 'wx' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
23- assert . equal ( fs . _stringToFlags ( 'xw' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
24- assert . equal ( fs . _stringToFlags ( 'wx+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
25- assert . equal ( fs . _stringToFlags ( 'xw+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
26- assert . equal ( fs . _stringToFlags ( 'ax' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
27- assert . equal ( fs . _stringToFlags ( 'xa' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
28- assert . equal ( fs . _stringToFlags ( 'ax+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
29- assert . equal ( fs . _stringToFlags ( 'xa+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
16+ const  {  stringToFlags }  =  require ( 'internal/fs' ) ; 
17+ 
18+ assert . equal ( stringToFlags ( 'r' ) ,  O_RDONLY ) ; 
19+ assert . equal ( stringToFlags ( 'r+' ) ,  O_RDWR ) ; 
20+ assert . equal ( stringToFlags ( 'w' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY ) ; 
21+ assert . equal ( stringToFlags ( 'w+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR ) ; 
22+ assert . equal ( stringToFlags ( 'a' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY ) ; 
23+ assert . equal ( stringToFlags ( 'a+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR ) ; 
24+ 
25+ assert . equal ( stringToFlags ( 'wx' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
26+ assert . equal ( stringToFlags ( 'xw' ) ,  O_TRUNC  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
27+ assert . equal ( stringToFlags ( 'wx+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
28+ assert . equal ( stringToFlags ( 'xw+' ) ,  O_TRUNC  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
29+ assert . equal ( stringToFlags ( 'ax' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
30+ assert . equal ( stringToFlags ( 'xa' ) ,  O_APPEND  |  O_CREAT  |  O_WRONLY  |  O_EXCL ) ; 
31+ assert . equal ( stringToFlags ( 'ax+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
32+ assert . equal ( stringToFlags ( 'xa+' ) ,  O_APPEND  |  O_CREAT  |  O_RDWR  |  O_EXCL ) ; 
3033
3134( '+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx' ) 
3235  . split ( ' ' ) 
3336  . forEach ( function ( flags )  { 
34-     assert . throws ( function ( )  {  fs . _stringToFlags ( flags ) ;  } ) ; 
37+     assert . throws ( function ( )  {  stringToFlags ( flags ) ;  } ) ; 
3538  } ) ; 
3639
3740assert . throws ( 
38-   ( )  =>  fs . _stringToFlags ( { } ) , 
41+   ( )  =>  stringToFlags ( { } ) , 
3942  / U n k n o w n   f i l e   o p e n   f l a g :   \[ o b j e c t   O b j e c t \] / 
4043) ; 
4144
4245assert . throws ( 
43-   ( )  =>  fs . _stringToFlags ( true ) , 
46+   ( )  =>  stringToFlags ( true ) , 
4447  / U n k n o w n   f i l e   o p e n   f l a g :   t r u e / 
4548) ; 
4649
4750assert . throws ( 
48-   ( )  =>  fs . _stringToFlags ( null ) , 
51+   ( )  =>  stringToFlags ( null ) , 
4952  / U n k n o w n   f i l e   o p e n   f l a g :   n u l l / 
5053) ; 
0 commit comments