"use strict";
/*global suite: false, test: false, setup: false*/

var assert = require('assert'),
    expector = require('../lib/expector'),
    cje = expector.test.checkJSONExpression;


suite('checkJSONExpresion', function() {
  test('$length', function(done) {
    assert(  cje({$length: 1}, [2]) );
    assert( !cje({$length: 1}, []) );
    assert( !cje({$length: 1}, [2, 3]) );
    assert(  cje({$length: 4}, [1, 2, 3, 4]) );

    done();
  });

  test('$unordered', function(done) {
    assert( cje({$unordered: [1, 2]}, [1, 2]) );
    assert( cje({$unordered: [1, 2]}, [2, 1]) );

    // FIXME: this seems like it should fail
    //assert(!cje({$unordered: [1, 2]}, [1, 2, 3]));

    assert( !cje({$unordered: [1, 2, 3]}, [1, 2]) );

    done();
  });

  test('comparisons', function(done) {
    assert(  cje({a: {$gt:  10}}, {a: 11}) );
    assert( !cje({a: {$gt:  10}}, {a: 10}) );
    assert( !cje({a: {$gt:  10}}, {a: 9})) ;

    assert(  cje({a: {$gte: 10}}, {a: 11}) );
    assert(  cje({a: {$gte: 10}}, {a: 10}) );
    assert( !cje({a: {$gte: 10}}, {a: 9})) ;

    assert( !cje({a: {$lt:  10}}, {a: 11}) );
    assert( !cje({a: {$lt:  10}}, {a: 10}) );
    assert(  cje({a: {$lt:  10}}, {a: 9})) ;

    assert( !cje({a: {$lte: 10}}, {a: 11}) );
    assert(  cje({a: {$lte: 10}}, {a: 10}) );
    assert(  cje({a: {$lte: 10}}, {a: 9})) ;
    done();
  });
});

@@ -436,32 +436,167 @@
  done();%0A  %7D);%0A%0A
+  test('$int', function(done) %7B%0A    assert(  cje(%7Ba: %22$int%22%7D, %7Ba: 2%7D) );%0A    assert( !cje(%7Ba: %22$int%22%7D, %7Ba: 1.5%7D) );%0A    done();%0A  %7D);%0A%0A
   test('$unorder
@@ -620,32 +620,33 @@
 e) %7B%0A    assert(
+ 
  cje(%7B$unordered
@@ -678,16 +678,17 @@
  assert(
+ 
  cje(%7B$u
@@ -721,67 +721,189 @@
  );%0A
-%0A
     
-// FIXME: this seems like it should fail
+assert( !cje(%7B$unordered: %5B1, 2, 3%5D%7D, %5B1, 2%5D) );%0A%0A    done();%0A  %7D);%0A%0A  test('combos', function(done) %7B%0A    assert(  cje(%7B$unordered: %5B1, 2%5D, $length: 2%7D, %5B2, 1%5D) );
 %0A    
-//
 assert(
+ 
 !cje
@@ -926,25 +926,34 @@
 , 2%5D
-%7D
 , 
-%5B1
+$length: 3%7D
 , 
+%5B
 2, 
-3
+1
 %5D)
+ 
 );%0A
-%0A
     
@@ -958,32 +958,44 @@
   assert( !cje(%7B
+$length: 2, 
 $unordered: %5B1, 
@@ -989,38 +989,35 @@
 ordered: %5B1,
- 2,
  3%5D%7D, %5B
-1, 2
+2, 1
 %5D) );%0A%0A    d

add combo and $int tests