diff --git a/xenomorph/xenomorph/redo/pointer.rkt b/xenomorph/xenomorph/redo/pointer.rkt index d2e07762..afca539f 100644 --- a/xenomorph/xenomorph/redo/pointer.rkt +++ b/xenomorph/xenomorph/redo/pointer.rkt @@ -86,7 +86,7 @@ https://github.com/mbutterick/restructure/blob/master/src/Pointer.coffee [else (error 'unknown-pointer-style)])] [(type val) (resolve-void-pointer (xpointer-type xp) val)]) (when (and val ctx) - (dict-set! ctx 'pointerSize (and (dict-ref ctx 'pointerSize) + (dict-set! ctx 'pointerSize (and (dict-ref ctx 'pointerSize #f) (+ (dict-ref ctx 'pointerSize) (size type val parent))))) (size (xpointer-offset-type xp)))) diff --git a/xenomorph/xenomorph/redo/test/array-test.rkt b/xenomorph/xenomorph/redo/test/array-test.rkt index c5c30eae..f92cd85b 100644 --- a/xenomorph/xenomorph/redo/test/array-test.rkt +++ b/xenomorph/xenomorph/redo/test/array-test.rkt @@ -3,6 +3,7 @@ "../helper.rkt" "../array.rkt" "../number.rkt" + "../pointer.rkt" sugar/unstable/dict) #| @@ -85,7 +86,6 @@ https://github.com/mbutterick/restructure/blob/master/test/Array.coffee "encode length as number before array" (check-equal? (encode (+xarray uint8 uint8) '(1 2 3 4) #f) (bytes 4 1 2 3 4))) -;; todo: reinstate pointer test -#;(test-case +(test-case "add pointers after array if length is encoded at start" - (check-equal? (encode (+xarray (+Pointer uint8 uint8) uint8) '(1 2 3 4)) (bytes 4 5 6 7 8 1 2 3 4))) \ No newline at end of file + (check-equal? (encode (+xarray (+xpointer uint8 uint8) uint8) '(1 2 3 4) #f) (bytes 4 5 6 7 8 1 2 3 4))) \ No newline at end of file