@@ -38,32 +38,35 @@ engine.unequival = function(a, b){
3838
3939/**
4040 * Checks that the types of a and b are suitable for comparison in an
41- * inequality expression. It is assumed that a check has already been made
42- * that there is at least one value in a and b.
41+ * inequality expression.
4342 * @param a the left side of the inequality expression (which should be an array of
4443 * one value).
4544 * @param b the right side of the inequality expression (which should be an array of
4645 * one value).
4746 * @return the singleton values of the arrays a, and b. If one was an FP_Type
48- * and the other was convertible, the coverted value will be retureed .
47+ * and the other was convertible, the converted value will be returned .
4948 */
5049function typecheck ( a , b ) {
51- util . assertAtMostOne ( a , "Singleton was expected" ) ;
52- util . assertAtMostOne ( b , "Singleton was expected" ) ;
50+ util . assertOnlyOne ( a , "Singleton was expected" ) ;
51+ util . assertOnlyOne ( b , "Singleton was expected" ) ;
5352 a = util . valDataConverted ( a [ 0 ] ) ;
5453 b = util . valDataConverted ( b [ 0 ] ) ;
55- let lClass = a instanceof FP_DateTime ? FP_DateTime : a . constructor ;
56- let rClass = b instanceof FP_DateTime ? FP_DateTime : b . constructor ;
57- if ( lClass !== rClass ) {
58- util . raiseError ( 'Type of "' + a + '" (' + lClass . name + ') did not match type of "' +
59- b + '" (' + rClass . name + ')' , 'InequalityExpression' ) ;
54+ if ( a != null && b != null ) {
55+ let lClass = a instanceof FP_DateTime ? FP_DateTime : a . constructor ;
56+ let rClass = b instanceof FP_DateTime ? FP_DateTime : b . constructor ;
57+ if ( lClass !== rClass ) {
58+ util . raiseError ( 'Type of "' + a + '" (' + lClass . name + ') did not match type of "' +
59+ b + '" (' + rClass . name + ')' , 'InequalityExpression' ) ;
60+ }
6061 }
6162 return [ a , b ] ;
6263}
6364
6465engine . lt = function ( a , b ) {
65- if ( ! a . length || ! b . length ) return [ ] ;
6666 const [ a0 , b0 ] = typecheck ( a , b ) ;
67+ if ( a0 == null || b0 == null ) {
68+ return [ ] ;
69+ }
6770 if ( a0 instanceof FP_Type ) {
6871 const compare = a0 . compare ( b0 ) ;
6972 return compare === null ? [ ] : compare < 0 ;
@@ -72,8 +75,10 @@ engine.lt = function(a, b){
7275} ;
7376
7477engine . gt = function ( a , b ) {
75- if ( ! a . length || ! b . length ) return [ ] ;
7678 const [ a0 , b0 ] = typecheck ( a , b ) ;
79+ if ( a0 == null || b0 == null ) {
80+ return [ ] ;
81+ }
7782 if ( a0 instanceof FP_Type ) {
7883 const compare = a0 . compare ( b0 ) ;
7984 return compare === null ? [ ] : compare > 0 ;
@@ -82,8 +87,10 @@ engine.gt = function(a, b){
8287} ;
8388
8489engine . lte = function ( a , b ) {
85- if ( ! a . length || ! b . length ) return [ ] ;
8690 const [ a0 , b0 ] = typecheck ( a , b ) ;
91+ if ( a0 == null || b0 == null ) {
92+ return [ ] ;
93+ }
8794 if ( a0 instanceof FP_Type ) {
8895 const compare = a0 . compare ( b0 ) ;
8996 return compare === null ? [ ] : compare <= 0 ;
@@ -92,8 +99,10 @@ engine.lte = function(a, b){
9299} ;
93100
94101engine . gte = function ( a , b ) {
95- if ( ! a . length || ! b . length ) return [ ] ;
96102 const [ a0 , b0 ] = typecheck ( a , b ) ;
103+ if ( a0 == null || b0 == null ) {
104+ return [ ] ;
105+ }
97106 if ( a0 instanceof FP_Type ) {
98107 const compare = a0 . compare ( b0 ) ;
99108 return compare === null ? [ ] : compare >= 0 ;
0 commit comments