@@ -93,28 +93,47 @@ describe('compiler', () => {
9393 ] ,
9494 ] ) ( 'should compile %p using multi-statements' , expectToEqual ) ;
9595
96- it . each ( [
97- [ 'python train.py --epochs=%[]%' , 'Empty comma-separated list' ] ,
98- [ 'python train.py --epochs=%(10,%[1,2,3]%,2)%' , 'Invalid number of arguments for range' ] ,
99- [ 'python train.py --epochs=%(in,out,1)%' , 'Non numeric range parameters' ] ,
100- [ 'python train.py --epochs=%(1,10,0)%' , 'Increment cannot be equal to zero' ] ,
101- ] ) ( 'should throw a syntax error for %p' , expectToThrow ) ;
96+ it ( 'should throw if there is an empty comma-separated list' , ( ) => {
97+ expectToThrow ( 'python train.py --epochs=%[]%' , 'Empty comma-separated list' ) ;
98+ } ) ;
10299
103- it . each ( [
104- [
100+ it ( 'should throw if there is invalid arguments for the range operator' , ( ) => {
101+ expectToThrow ( 'python train.py --epochs=%(10,%[1,2,3]%,2)%' , 'Invalid number of arguments for range' ) ;
102+ } ) ;
103+
104+ it ( 'should throw if the range operator get non-numeric operators' , ( ) => {
105+ expectToThrow ( 'python train.py --epochs=%(in,out,1)%' , 'Non numeric range parameters' ) ;
106+ } ) ;
107+
108+ it ( 'should throw if the range operator is equal to zero' , ( ) => {
109+ expectToThrow ( 'python train.py --epochs=%(1,10,0)%' , 'Increment cannot be equal to zero' ) ;
110+ } ) ;
111+
112+ it ( `should throw if a range operator exceeds the maximum allowed domain of ${ limits . range } values` , ( ) => {
113+ expectToThrow (
114+ 'python train.py --foo=%(0,1,0.0000001)%' ,
115+ `Range operator exceeds the maximum allowed domain of ${ limits . range } values` ,
116+ ) ;
117+ } ) ;
118+
119+ it ( `should throw if the command generate more than the allowed limit of ${ limits . outputs } outputs` , ( ) => {
120+ expectToThrow (
121+ 'python train.py --foo=%(0,100)% --bar=%(0,100)% --baz%(0,100)%' ,
122+ `Command exceeds the maximum of ${ limits . outputs } outputs` ,
123+ ) ;
124+ } ) ;
125+
126+ it ( `should throw if the command exceeds the maximum allowed length of ${ limits . length } characters` , ( ) => {
127+ expectToThrow (
105128 `python train.py ${ new Array ( limits . length * 2 ) . join ( '#' ) } ` ,
106129 `Command exceeds the maximum allowed length of ${ limits . length } characters` ,
107- ] ,
108- [
109- 'python train.py --foo=%(0,1,0.000001)%' ,
110- `Range operator exceeds the maximum allowed domain of ${ limits . range } values` ,
111- ] ,
112- ] ) ( 'should not compile %p and be rate limited' , expectToThrow ) ;
130+ ) ;
131+ } ) ;
113132
114133 /**
115134 * @link https://github.com/csquare-ai/crossp/issues/1
116135 */
117- it ( 'should not have round issues' , ( ) => {
136+ it ( 'should not have rounding issues with %(0.1,0.5,0.1)% ' , ( ) => {
118137 expectToEqual ( 'python --train.py --lr=%(0.1,0.5,0.1)%' , [
119138 'python --train.py --lr=0.1' ,
120139 'python --train.py --lr=0.2' ,
@@ -123,4 +142,22 @@ describe('compiler', () => {
123142 'python --train.py --lr=0.5' ,
124143 ] ) ;
125144 } ) ;
145+
146+ /**
147+ * @link https://github.com/csquare-ai/crossp/issues/3
148+ */
149+ it ( 'should not have rounding issues with %(10,100,10)%' , ( ) => {
150+ expectToEqual ( 'python --train.py --lr=%(10,100,10)%' , [
151+ 'python --train.py --lr=10' ,
152+ 'python --train.py --lr=20' ,
153+ 'python --train.py --lr=30' ,
154+ 'python --train.py --lr=40' ,
155+ 'python --train.py --lr=50' ,
156+ 'python --train.py --lr=60' ,
157+ 'python --train.py --lr=70' ,
158+ 'python --train.py --lr=80' ,
159+ 'python --train.py --lr=90' ,
160+ 'python --train.py --lr=100' ,
161+ ] ) ;
162+ } ) ;
126163} ) ;
0 commit comments