require('proof')(1, prove)

function prove (assert) {
    var path = require('path')
    var compiler = require('../../../require')
    var composer = require('../../../parse.inc')
    var filename = path.resolve(__filename, '../../../generated/condition.parse.inc.js')

    var parsers = { inc: {} }

    composer(compiler('parsers', filename), [{
        type: 'structure',
        name: 'object',
        fields: [{
            type: 'integer',
            name: 'flag',
            endianness: 'b',
            bits: 16
        }, {
            type: 'condition',
            conditions: [{
                test: 'object.flag == 16',
                fields: [{
                    type: 'integer',
                    name: 'number',
                    endianness: 'b',
                    bits: 16
                }]
            }, {
                fields: [{
                    type: 'integer',
                    name: 'number',
                    endianness: 'b',
                    bits: 8
                }]
            }]
        }]
    }])(parsers)

    var buffer = new Buffer([ 0x00, 0x08, 0x00 ])
    assert((new parsers.inc.object).parse(buffer, 0), {
        start: buffer.length,
        object: { flag: 8, number: 0 },
        parser: null
    }, 'compiled')
}

@@ -10,17 +10,17 @@
 proof')(
-1
+7
 , prove)
@@ -1119,60 +1119,354 @@
     
-assert((new parsers.inc.object).parse(buffer, 0), %7B%0A
+for (var i = 0; i %3C= buffer.length; i++) %7B%0A        var parser = (new parsers.inc.object)%0A        var first = parser.parse(buffer, 0, buffer.length - i)%0A        assert(first.start, buffer.length - i, 'incremental ' + i)%0A        if (first.parser != null) %7B%0A            assert(first.parser.parse(buffer, buffer.length - i, buffer.length), %7B%0A        
     
@@ -1499,16 +1499,24 @@
         
+  
+      
 object: 
@@ -1539,16 +1539,24 @@
 r: 0 %7D,%0A
+        
         
@@ -1568,16 +1568,24 @@
 r: null%0A
+        
     %7D, '
@@ -1592,13 +1592,34 @@
 compiled
-')
+ ' + i)%0A        %7D%0A    %7D
 %0A%7D%0A

Test partial parse of incremental packed integer.