             (t/is (= written (buf/size spec)))
             (let [[readed data'] (buf/read* buffer spec)]
               (t/is (= readed (buf/size spec)))
-              (t/is (= data data')))))))))
-
-;; #+clj
-;; (t/deftest spec-data-with-dynamic-types-single
-;;   (let [spec (buf/spec (buf/string*))
-;;         buffer (buf/allocate 20)]
-;;     (buf/write! buffer ["1234567890"] spec)
-;;     (let [[readed data] (buf/read* buffer spec)]
-;;       (t/is (= readed 14))
-;;       (t/is (= data ["1234567890"])))))
-
-;; #+clj
-;; (t/deftest spec-data-with-dynamic-types-combined
-;;   (let [spec (buf/spec (buf/string*) (buf/int64))
-;;         buffer (buf/allocate 40)]
-;;     (buf/write! buffer ["1234567890" 1000] spec)
-;;     (let [[readed data] (buf/read* buffer spec)]
-;;       (t/is (= readed 22))
-;;       (t/is (= data ["1234567890" 1000])))))
-
-;; #+clj
-;; (t/deftest spec-composition
-;;   (let [spec (buf/spec (buf/compose-type (buf/int32) (buf/int32))
-;;                        (buf/compose-type (buf/string 10) (buf/string 5)))
-;;         buffer (buf/allocate (buf/size spec))
-;;         data [[100 200] ["foo" "bar"]]]
-;;     (buf/write! buffer data spec)
-;;     (let [[readed data'] (buf/read* buffer spec)]
-;;       (t/is (= readed (buf/size spec)))
-;;       (t/is (= data' data)))))
+              (cond
+                (instance? js/Int8Array data')
+                (t/is (equals? data data'))
+
+                :else
+                (t/is (= data data'))))))))))
+
+(t/deftest spec-data-with-dynamic-types-single
+  (let [spec (buf/spec (buf/string*))
+        buffer (buf/allocate 20)]
+    (buf/write! buffer ["1234567890"] spec)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 14))
+      (t/is (= data ["1234567890"])))))
+
+(t/deftest spec-data-with-dynamic-types-combined
+  (let [spec (buf/spec (buf/string*) (buf/int32))
+        buffer (buf/allocate 40)]
+    (buf/write! buffer ["1234567890" 1000] spec)
+    (let [[readed data] (buf/read* buffer spec)]
+      (t/is (= readed 18))
+      (t/is (= data ["1234567890" 1000])))))
+
+(t/deftest spec-composition
+  (let [spec (buf/spec (buf/compose-type (buf/int32) (buf/int32))
+                       (buf/compose-type (buf/string 10) (buf/string 5)))
+        buffer (buf/allocate (buf/size spec))
+        data [[100 200] ["foo" "bar"]]]
+    (buf/write! buffer data spec)
+    (let [[readed data'] (buf/read* buffer spec)]
+      (t/is (= readed (buf/size spec)))
+      (t/is (= data' data)))))


#+cljs
(t/deftest spec-data-types
  (let [data [;; (buf/string 5) "12345"
              (buf/short)    100
              (buf/integer)  1001
              (buf/bool)     false
              (buf/double)   (double 4.3)
              (buf/float)    (float 3.5)
              (buf/byte)     (byte 32)]]
              ;; (buf/bytes 5)  (bytes/random-bytes 5)]]
    (doseq [[spec data] (partition 2 data)]
      (let [buffers [(buf/allocate (buf/size spec) {:impl :es6})]]
        (doseq [buffer buffers]

  (let [buffer (buf/allocate 16 {:impl :es6})]
    (t/is (instance? js/DataView buffer))))

(t/deftest spec-constructor
  (let [spec (buf/spec :field1 (buf/int32)
                       :field2 (buf/int16))]
    (t/is (= (count spec) 2))
    (t/is (= (buf/size spec) 6))))

(t/deftest associative-specs-write
  (let [spec (buf/spec :field1 (buf/int32)
                       :field2 (buf/int16))
        buffer (buf/allocate 12)
        data {:field1 1 :field2 4}]
    (t/is (= (buf/write! buffer data spec) 6))
    (t/is (= (impl/read-int buffer 0) 1))
    (t/is (= (impl/read-short buffer 4) 4))))

(t/deftest associative-specs-write-with-offset
  (let [spec (buf/spec :field1 (buf/int32))
        buffer (buf/allocate 12)
        data {:field1 500}]
    (t/is (= (buf/write! buffer data spec {:offset 3}) 4))
    (t/is (= (impl/read-int buffer 3) 500))))

(t/deftest associative-specs-write-wrong-buffer
  ;; write data to wrong buffer (less space)
  (let [spec (buf/spec :field1 (buf/int32))
        buffer (buf/allocate 2)
        data {:field1 1}]
    #+clj
    (t/is (thrown? java.lang.IndexOutOfBoundsException
                   (buf/write! buffer data spec) 12))
    #+cljs
    (t/is (thrown? js/Error
                   (buf/write! buffer data spec) 12))))

(t/deftest associative-specs-read
  (let [spec (buf/spec :field1 (buf/int32)
                       :field2 (buf/int16))
        buffer (buf/allocate 12)]
    (impl/write-int buffer 0 10)
    (impl/write-short buffer 4 100)
    (let [[readed data] (buf/read* buffer spec)]
      (t/is (= readed 6))
      (t/is (= data {:field2 100 :field1 10})))))

(t/deftest associative-specs-read-with-offset
  (let [spec (buf/spec :field1 (buf/int32))
        buffer (buf/allocate 12)]
    (impl/write-int buffer 8 1000)
    (let [[readed data] (buf/read* buffer spec {:offset 8})]
      (t/is (= readed 4))
      (t/is (= data {:field1 1000})))))

(t/deftest indexed-specs-write
  (let [spec (buf/spec (buf/int32) (buf/int16))
        buffer (buf/allocate 12)
        data [1 4]]
    (t/is (= (buf/write! buffer data spec) 6))
    (t/is (= (impl/read-int buffer 0) 1))
    (t/is (= (impl/read-short buffer 4) 4))))

#+clj
(t/deftest indexed-specs-write-with-offset
