hara-native 0.1.13

HAL-free native host runtime and package launcher for Hara
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
{:format :hara-native/native-protocol-conformance
 :version 1
 :coverage
 {:native/portable
  [{:type "std.native.Maths"
    :methods ["abs" "acos" "acosh" "asin" "asinh" "atan" "atan2" "atanh"
              "ceil" "cos" "cosh" "exp" "floor" "pow" "sin" "sinh" "sqrt"
              "tan" "tanh"]}
   {:type "std.native.Num"
    :methods ["long" "double" "parse-long" "parse-double"]}
   {:type "std.native.Bits"
    :methods ["and" "or" "xor" "not" "shift-left" "shift-right"]}
   {:type "std.native.String"
    :methods ["length" "blank?" "includes?" "starts-with?" "ends-with?" "char-at"
              "slice" "index-of" "last-index-of" "join" "split" "split-lines"
              "repeat" "replace" "replace-first" "trim" "trim-left" "trim-right"
              "upper" "lower" "capitalize" "decapitalize" "pad-left" "pad-right"
              "reverse" "encode-utf8" "decode-utf8" "to-fixed"]}
   {:type "std.native.Bytes"
    :methods ["new" "count" "get" "set" "copy" "slice" "u8" "s8"]}
   {:type "std.native.Crypto"
    :methods ["sha256" "sha512" "hmac-sha256" "hmac-sha512" "random-bytes" "secure-equal?"
              "ed25519-keypair" "ed25519-public" "ed25519-sign" "ed25519-verify"
              "x25519-keypair" "x25519-public" "x25519-shared" "p256-keypair" "p256-public"
              "p256-sign" "p256-verify" "p256-shared"]}
   {:type "std.native.Promise"
    :methods ["run" "new" "from" "all" "delay"]}
   {:type "std.native.Coroutine"
    :methods ["create" "yield" "await"]}
   {:type "std.native.Stream"
    :methods ["create" "generate" "next"]}
   {:type "std.native.Arr"
    :methods ["new" "get" "set" "push-first" "push-last" "pop-first" "pop-last" "insert"
              "remove" "clone" "slice" "map" "filter" "fold-left" "fold-right"]}
   {:type "std.native.Obj"
    :methods ["new" "get" "set" "has?" "delete" "clone" "assign" "keys" "vals" "pairs"]}
   {:type "std.native.Runtime"
    :methods ["load-string" "macroexpand-1" "gensym" "ns-publics" "ns-aliases" "ns-find"
              "ns-create" "ns-name" "var-sym" "current" "snapshot" "vars" "namespaces"
              "namespace" "module" "alias-state" "intern-var" "eval-in" "eval"]}
   {:type "std.native.Printer"
    :methods ["p" "println" "capture"]}
   {:type "std.native.Document"
    :methods ["element" "text" "fragment" "annotate" "pass" "escaped" "group" "line" "break"
              "nest" "align" "normalize" "valid?" "render"]}
   {:type "std.native.Edn"
    :methods ["read" "read-forms" "write" "pretty"]}
   {:type "std.native.Json"
    :methods ["read" "write" "pretty"]}
   {:type "std.native.Instrument"
    :methods ["provider" "validate" "inspect" "disassemble" "transform" "execute"]}
   {:type "std.native.Test"
    :methods ["catalog" "config" "context" "events" "compare" "check" "register" "facts" "get"
              "remove" "purge" "reset" "run-fact" "run" "summary" "result" "passed?" "actual"
              "expected" "failures" "failure-seq" "failure-count" "failure" "failure?"]}
   {:type "std.native.Command"
    :methods ["create" "config" "install" "uninstall" "routes" "snapshot" "restore" "reset"
              "closed?" "close" "parse" "dispatch" "run"]}
   {:type "std.native.RegExp"
    :methods ["compile" "pattern" "find?" "find" "matches" "replace" "split"]}
   {:type "std.native.Result"
    :methods ["create" "synchronize" "success?" "error?" "status" "data"
              "error-value" "context" "with-context"]}
   {:type "std.native.Schema"
    :methods ["compile" "of" "kind" "form" "ast" "origin"]}
   {:type "std.native.Exception"
    :methods ["new" "message" "class"]}
   {:type "std.native.Base"
    :methods ["list" "vector" "vec" "set" "hash-map" "hash-set" "map-entry" "bytes" "atom"
              "pointer" "symbol" "keyword" "uuid" "reduced" "unreduced" "hash"
              "apply" "resolve" "namespace" "current-namespace" "select-namespace" "def"
              "struct" "mutable" "protocol" "with-declaration" "extend" "multimethod" "method"
              "field" "number?" "long?" "satisfies?"
              "special-symbol?" "type" "instance?"]}
   {:type "std.native.Algo"
    :methods ["deque" "ordered-map" "ordered-set" "priority-map" "queue" "sorted-map" "sorted-set"
              "trie" "deque?" "ordered-map?" "ordered-set?" "priority-map?" "queue?" "sorted-map?"
              "sorted-set?" "trie?"]}
   {:type "std.native.Iter"
    :methods ["seq" "iter" "iter-finite?" "iter-materialize" "iter-next?" "iter-next"
              "iter-close" "iter-concat" "iter-map" "iter-filter" "iter-mapcat"
              "iter-take-while" "iter-drop-while" "iter-keep" "iter-interpose" "iter-interleave"
              "iter-every?" "iter-any?" "iter-take" "iter-drop" "iter-zip" "iter-cycle"
              "iter-partition-pair" "iter-partition-all" "iter-partition" "iter-range" "iter-constantly"
              "iter-repeatedly" "iter-iterate"]}]
  }
 :suites
 [{:id :native
   :setup nil
   :cases
   [{:id :native/maths-abs
     :program (= 2 (std.native.Maths/abs -2))
     :expect {:display "true"}}
    {:id :native/maths-abs-arity
     :program (std.native.Maths/abs)
     :expect {:error :native/arity}}
    {:id :native/maths-abs-type
     :program (std.native.Maths/abs "not-a-number")
     :expect {:error :native/type}}
    {:id :native/maths-portable-surface
     :program (= [0 0 0 0 0 0 0 2 1 1 1 1 8 0 0 2 0 0 2]
                 [(std.native.Maths/acos 1)
                  (std.native.Maths/acosh 1)
                  (std.native.Maths/asin 0)
                  (std.native.Maths/asinh 0)
                  (std.native.Maths/atan 0)
                  (std.native.Maths/atan2 0 1)
                  (std.native.Maths/atanh 0)
                  (std.native.Maths/ceil (std.native.Num/parse-double "1.5"))
                  (std.native.Maths/cos 0)
                  (std.native.Maths/cosh 0)
                  (std.native.Maths/exp 0)
                  (std.native.Maths/floor (std.native.Num/parse-double "1.5"))
                  (std.native.Maths/pow 2 3)
                  (std.native.Maths/sin 0)
                  (std.native.Maths/sinh 0)
                  (std.native.Maths/sqrt 4)
                  (std.native.Maths/tan 0)
                  (std.native.Maths/tanh 0)
                  (std.native.Maths/abs -2)])
     :expect {:display "true"}}
    {:id :native/num-and-bits-portable-surface
     :program (= [2 true 42 true 2 7 5 -2 8 2]
                 [(std.native.Num/long (std.native.Num/parse-double "2.0"))
                  (std.native.Base/number? (std.native.Num/double 2))
                  (std.native.Num/parse-long "42")
                  (std.native.Base/number? (std.native.Num/parse-double "4.5"))
                  (std.native.Bits/and 6 3)
                  (std.native.Bits/or 6 3)
                  (std.native.Bits/xor 6 3)
                  (std.native.Bits/not 1)
                  (std.native.Bits/shift-left 1 3)
                  (std.native.Bits/shift-right 8 2)])
     :expect {:display "true"}}
    {:id :native/string-portable-surface
     :program (= [3 true true true true \a "ar" 1 3 "a,b" ["a" "b"] ["a" "b"] "abab" "xbx" "xba" "a" "a  " "  a" "HARA" "hara" "Hara" "hara" "00a" "a00" "arah" "λ" "1.50"]
                 [(std.native.String/length "abc")
                  (std.native.String/blank? "  \n")
                  (std.native.String/includes? "hara" "ar")
                  (std.native.String/starts-with? "hara" "ha")
                  (std.native.String/ends-with? "hara" "ra")
                  (std.native.String/char-at "hara" 1)
                  (std.native.String/slice "hara" 1 3)
                  (std.native.String/index-of "hara" "ar")
                  (std.native.String/last-index-of "ababa" "ba")
                  (std.native.String/join "," ["a" "b"])
                  (std.native.String/split "a,b" ",")
                  (std.native.String/split-lines "a\nb")
                  (std.native.String/repeat "ab" 2)
                  (std.native.String/replace "aba" "a" "x")
                  (std.native.String/replace-first "aba" "a" "x")
                  (std.native.String/trim "  a  ")
                  (std.native.String/trim-left "  a  ")
                  (std.native.String/trim-right "  a  ")
                  (std.native.String/upper "hara")
                  (std.native.String/lower "HARA")
                  (std.native.String/capitalize "hara")
                  (std.native.String/decapitalize "Hara")
                  (std.native.String/pad-left "a" 3 "0")
                  (std.native.String/pad-right "a" 3 "0")
                  (std.native.String/reverse "hara")
                  (std.native.String/decode-utf8 (std.native.String/encode-utf8 "λ"))
                  (std.native.String/to-fixed (std.native.Num/parse-double "1.5") 2)])
     :expect {:display "true"}}
    {:id :native/bytes-portable-surface
     :program (let [source (std.native.Bytes/new 1 2 -1)
                    copy (std.native.Bytes/copy source)
                    _ (std.native.Bytes/set copy 0 9)]
                (= [3 2 1 9 2 255 -1]
                   [(std.native.Bytes/count source)
                    (std.native.Bytes/get source 1)
                    (std.native.Bytes/get source 0)
                    (std.native.Bytes/get copy 0)
                    (std.native.Bytes/get (std.native.Bytes/slice source 1 3) 0)
                    (std.native.Bytes/u8 -1)
                    (std.native.Bytes/s8 255)]))
     :expect {:display "true"}}
    {:id :native/crypto-portable-surface
     :program (let [value (std.native.String/encode-utf8 "hara")]
                (= [64 128 true]
                   [(std.native.String/length (std.native.Crypto/sha256 value))
                    (std.native.String/length (std.native.Crypto/sha512 value))
                    (std.native.Crypto/secure-equal? value value)]))
     :expect {:display "true"}}
    {:id :native/promise-protocol-boundary
     :program (= [42 :fulfilled]
                 [(std.protocol.ipromise.IPromise/value (std.native.Promise/from 42))
                  (std.protocol.ipromise.IPromise/state (std.native.Promise/from 42))])
     :expect {:display "true"}}
    {:id :native/array-and-object-mutation
     :program (let [array (std.native.Arr/new 1 2)
                    array-copy (std.native.Arr/clone array)
                    object (std.native.Obj/new "answer" 42)
                    object-copy (std.native.Obj/clone object)
                    _ (std.native.Arr/set array-copy 0 9)
                    _ (std.native.Obj/set object-copy "answer" 9)
                    _ (std.native.Obj/delete object-copy "answer")]
                (= [:std.native.Array 2 1 :std.native.Object 42 true false]
                   [(std.native.Base/type array)
                    (std.native.Arr/get array 1)
                    (std.native.Arr/get array 0)
                    (std.native.Base/type object)
                    (std.native.Obj/get object "answer")
                    (std.native.Obj/has? object "answer")
                    (std.native.Obj/has? object-copy "answer")]))
     :expect {:display "true"}}
    {:id :native/mutable-reader-tags-and-lookup
     :program (let [array #arr[1 (+ 1 1)]
                    object #obj{"answer" (+ 40 2)}
                    lookup (std.protocol.ideref.IDeref/deref
                            (std.native.Base/resolve 'std.protocol.ilookup.ILookup))
                    array-value (std.protocol.ilookup.ILookup/lookup array 1)
                    array-missing (std.protocol.ilookup.ILookup/lookup array 9 :missing)
                    object-value (std.protocol.ilookup.ILookup/lookup object "answer")
                    object-missing (std.protocol.ilookup.ILookup/lookup object "missing" :missing)
                    _ (std.native.Arr/set array 0 7)
                    _ (std.native.Obj/set object "answer" 43)]
                (= [true true 2 :missing 42 :missing 7 43]
                   [(std.native.Base/satisfies? lookup array)
                    (std.native.Base/satisfies? lookup object)
                    array-value
                    array-missing
                    object-value
                    object-missing
                    (std.protocol.ilookup.ILookup/lookup array 0)
                    (std.protocol.ilookup.ILookup/lookup object "answer")]))
     :expect {:display "true"}}
    {:id :native/mutable-reader-tag-display
     :program (= "[#arr[1 2] #obj{\"answer\" 42} #obj{}]"
                 (std.native.Printer/capture
                   (fn []
                     (std.native.Printer/p
                       [#arr[1 (+ 1 1)] #obj {"answer" (+ 40 2)} #obj {}]))))
     :expect {:display "true"}}
    {:id :native/uuid-reader-tag
     :program (let [value #uuid "00000000-0000-0000-0000-000000000000"]
                (= [true :std.native.UUID "#uuid \"00000000-0000-0000-0000-000000000000\""]
                   [(= value (std.native.Base/uuid "00000000-0000-0000-0000-000000000000"))
                    (std.native.Base/type value)
                    (std.native.Printer/capture
                      (fn [] (std.native.Printer/p value)))]))
     :expect {:display "true"}}
    {:id :native/runtime-and-codecs
     :program (= [42 {:a 1} "{:a 1}" {"a" 1} "{\"a\":1}"]
                 [(std.native.Runtime/load-string "(+ 19 23)")
                  (std.native.Edn/read "{:a 1}")
                  (std.native.Edn/write {:a 1})
                  (std.native.Json/read "{\"a\":1}")
                  (std.native.Json/write {"a" 1})])
     :expect {:display "true"}}
    {:id :native/regexp-portable-surface
     :program (let [expression (std.native.RegExp/compile "a+")]
                (= [:std.native.RegExp "a+" true "aa" [true false true] "12:x" ["a" "b" "c"]]
                   [(std.native.Base/type expression)
                    (std.native.RegExp/pattern expression)
                    (std.native.RegExp/find? expression "caa")
                    (std.native.RegExp/find expression "caa")
                    [(std.native.RegExp/matches expression "aa")
                     (std.native.RegExp/matches expression "caa")
                     (std.native.RegExp/matches (std.native.RegExp/compile "a|abc") "abc")]
                    (std.native.RegExp/replace (std.native.RegExp/compile "([a-z]+)-([0-9]+)") "x-12" "$2:$1")
                    (std.native.RegExp/split (std.native.RegExp/compile ",+") "a,,b,c")]))
     :expect {:display "true"}}
    {:id :native/result-exception-and-schema
     :program (let [success-result (std.native.Result/create :success 42)
                    failure-result (std.native.Result/create :error "boom")
                    exception-value (std.native.Exception/new "boom" {:ex/class :ex.class/demo})]
                (= [:success true true 42 42 "boom" {:trace 8} "boom" "exception" :std.native.SchemaType]
                   [(std.native.Result/status success-result)
                    (std.native.Result/success? success-result)
                    (std.native.Result/error? failure-result)
                    (std.native.Result/data success-result)
                    (std.native.Result/data (std.native.Result/synchronize 42))
                    (std.native.Exception/message (std.native.Result/error-value failure-result))
                    (std.native.Result/context (std.native.Result/with-context success-result {:trace 8}))
                    (std.native.Exception/message exception-value)
                    (std.native.Exception/class exception-value)
                    (std.native.Base/type (std.native.Schema/compile :int))]))
     :expect {:display "true"}}
    {:id :native/schema-introspection-semantics
     :program (let [schema (std.native.Schema/compile :int)
                    target (std.native.Base/namespace 'hnc.schema)
                    value (std.native.Base/def target 'answer 42 nil)]
                (= [nil :primitive :int {:name :int :kind :primitive} nil]
                   [(std.native.Schema/of value)
                    (std.native.Schema/kind schema)
                    (std.native.Schema/form schema)
                    (std.native.Schema/ast schema)
                    (std.native.Schema/origin schema)]))
     :expect {:display "true"}}
    {:id :native/base-portable-surface
     :program (let [atom (std.native.Base/atom 1)
                    entry (std.native.Base/map-entry :a 1)
                    pointer (std.native.Base/pointer {:context :base})]
                (= [true [1 2] [1 2] #{1 2} {:a 1} #{1 2} 3 true :a 1 1 :base 'base/value :base/value true true true]
                   [(= '(1 2) (std.native.Base/list 1 2))
                    (std.native.Base/vector 1 2)
                    (std.native.Base/vec (std.native.Base/list 1 2))
                    (std.native.Base/set [1 2 1])
                    (std.native.Base/hash-map :a 1)
                    (std.native.Base/hash-set 1 2)
                    (std.native.Bytes/count (std.native.Base/bytes 1 2 -3))
                    (= (std.native.Base/hash [1 2])
                       (std.native.Base/hash (std.native.Base/list 1 2)))
                    (std.protocol.ipair.IPair/key entry)
                    (std.protocol.ipair.IPair/value entry)
                    (std.protocol.ideref.IDeref/deref atom)
                    (std.protocol.ipointer.IPointer/ptr-context pointer)
                    (std.native.Base/symbol "base" "value")
                    (std.native.Base/keyword "base" "value")
                    (std.native.Base/number? (std.native.Num/parse-double "1.5"))
                    (std.native.Base/long? 1)
                    (std.native.Base/instance? (std.protocol.ideref.IDeref/deref (std.native.Base/resolve 'std.native.Promise)) (std.native.Promise/from 1))]))
     :expect {:display "true"}}
    {:id :native/base-namespace-and-protocol-semantics
     :program (let [initial (std.native.Base/current-namespace)
                    target (std.native.Base/namespace 'hnc.base-current)
                    protocol (std.protocol.ideref.IDeref/deref
                              (std.native.Base/resolve 'std.protocol.ilookup.ILookup))
                    result (do
                             (std.native.Base/select-namespace target)
                             (= ['hnc.base-current 'hnc.base-current true false true]
                                [(std.native.Runtime/ns-name
                                  (std.native.Base/current-namespace))
                                 (std.native.Runtime/ns-name
                                  (std.native.Base/select-namespace target))
                                 (std.native.Base/special-symbol? 'if)
                                 (std.native.Base/special-symbol? 'answer)
                                 (std.native.Base/satisfies? protocol {:answer 42})]))
                    _ (std.native.Base/select-namespace initial)]
                result)
     :expect {:display "true"}}
    {:id :native/algo-collection-semantics
     :program (let [deque (std.native.Algo/deque 1 2)
                    ordered-map (std.native.Algo/ordered-map :a 1)
                    ordered-set (std.native.Algo/ordered-set 2 1)
                    priority-map (std.native.Algo/priority-map :a 2)
                    queue (std.native.Algo/queue 1 2)
                    sorted-map (std.native.Algo/sorted-map :a 1)
                    sorted-set (std.native.Algo/sorted-set 2 1)
                    trie (std.native.Algo/trie "a" 1)]
                (= [:std.native.Deque :std.native.OrderedMap :std.native.OrderedSet
                    :std.native.PriorityMap :std.native.Queue :std.native.SortedMap
                    :std.native.SortedSet :std.native.Trie true true true true true true
                    true true]
                   [(std.native.Base/type deque)
                    (std.native.Base/type ordered-map)
                    (std.native.Base/type ordered-set)
                    (std.native.Base/type priority-map)
                    (std.native.Base/type queue)
                    (std.native.Base/type sorted-map)
                    (std.native.Base/type sorted-set)
                    (std.native.Base/type trie)
                    (std.native.Algo/deque? deque)
                    (std.native.Algo/ordered-map? ordered-map)
                    (std.native.Algo/ordered-set? ordered-set)
                    (std.native.Algo/priority-map? priority-map)
                    (std.native.Algo/queue? queue)
                    (std.native.Algo/sorted-map? sorted-map)
                    (std.native.Algo/sorted-set? sorted-set)
                    (std.native.Algo/trie? trie)]))
     :expect {:display "true"}}
    {:id :native/iter-full-portable-fixture
     :program (let [concatenated (std.native.Iter/iter-concat [1 2] [3 4])
                    mapped (std.native.Iter/iter-mapcat (fn [value] [value (+ value 10)]) [1 2])
                    kept (std.native.Iter/iter-keep (fn [value] (if (= value 2) value nil)) [1 2 3])
                    taken (std.native.Iter/iter-take 2 [1 2 3])
                    dropped (std.native.Iter/iter-drop 1 [1 2 3])
                    cycled (std.native.Iter/iter-cycle [1 2])
                    pairs (std.native.Iter/iter-partition-pair [1 2 3 4])
                    ranged (std.native.Iter/iter-range 0 10)
                    constant (std.native.Iter/iter-constantly 7)
                    iterated (std.native.Iter/iter-iterate (fn [value] (+ value 1)) 1)]
                (= [[1 2] true 3 2 2 [1 2 false] 2 1 2 [0 1 2] [7 7] [1 2 3]]
                   [(std.native.Iter/iter-materialize (std.native.Iter/seq [1 2]))
                    (std.native.Iter/iter-finite? [1])
                    (do (std.native.Iter/iter-next concatenated)
                        (std.native.Iter/iter-next concatenated)
                        (std.native.Iter/iter-next concatenated))
                    (do (std.native.Iter/iter-next mapped)
                        (std.native.Iter/iter-next mapped)
                        (std.native.Iter/iter-next mapped))
                    (std.native.Iter/iter-next kept)
                    [(std.native.Iter/iter-next taken)
                     (std.native.Iter/iter-next taken)
                     (std.native.Iter/iter-next? taken)]
                    (std.native.Iter/iter-next dropped)
                    (do (std.native.Iter/iter-next cycled)
                        (std.native.Iter/iter-next cycled)
                        (std.native.Iter/iter-next cycled))
                    (std.protocol.inth.INth/nth (std.native.Iter/iter-next pairs) 1)
                    [(std.native.Iter/iter-next ranged)
                     (std.native.Iter/iter-next ranged)
                     (std.native.Iter/iter-next ranged)]
                    [(std.native.Iter/iter-next constant)
                     (std.native.Iter/iter-next constant)]
                    [(std.native.Iter/iter-next iterated)
                     (std.native.Iter/iter-next iterated)
                     (std.native.Iter/iter-next iterated)]]))
     :expect {:display "true"}}
    {:id :native/iter-lazy-and-partition-semantics
     :program (let [take-while (std.native.Iter/iter-take-while
                                 (fn [value] (< value 3)) [1 2 3 4])
                    drop-while (std.native.Iter/iter-drop-while
                                 (fn [value] (< value 3)) [1 2 3 4])
                    interpose (std.native.Iter/iter-interpose 0 [1 2 3])
                    interleave (std.native.Iter/iter-interleave [1 2] [3 4])
                    partition-all (std.native.Iter/iter-partition-all 2 [1 2 3])
                    partition (std.native.Iter/iter-partition 2 [1 2 3])
                    repeated (std.native.Iter/iter-repeatedly (fn [] 7))]
                (= [1 2 false 3 1 0 2 0 3 1 3 2 4 [1 2] [3] false [1 2]
                    false true true 7 7 7]
                   [(std.native.Iter/iter-next take-while)
                    (std.native.Iter/iter-next take-while)
                    (std.native.Iter/iter-next? take-while)
                    (std.native.Iter/iter-next drop-while)
                    (std.native.Iter/iter-next interpose)
                    (std.native.Iter/iter-next interpose)
                    (std.native.Iter/iter-next interpose)
                    (std.native.Iter/iter-next interpose)
                    (std.native.Iter/iter-next interpose)
                    (std.native.Iter/iter-next interleave)
                    (std.native.Iter/iter-next interleave)
                    (std.native.Iter/iter-next interleave)
                    (std.native.Iter/iter-next interleave)
                    (std.native.Iter/iter-next partition-all)
                    (std.native.Iter/iter-next partition-all)
                    (std.native.Iter/iter-next? partition-all)
                    (std.native.Iter/iter-next partition)
                    (std.native.Iter/iter-next? partition)
                    (std.native.Iter/iter-every? (fn [value] (< value 4)) [1 2 3])
                    (std.native.Iter/iter-any? (fn [value] (= value 2)) [1 2 3])
                    (std.native.Iter/iter-next repeated)
                    (std.native.Iter/iter-next repeated)
                    (std.native.Iter/iter-next repeated)]))
     :expect {:display "true"}}
    {:id :native/native-boundary-errors-and-result-deref
     :program (let [success-result (std.native.Result/create :success 42)
                    failure-result (std.native.Result/create :error "boom")]
                (= [true true 42 true]
                   [(try (std.native.Maths/abs) false (catch error true))
                    (try (std.native.Maths/abs "bad") false (catch error true))
                    (std.protocol.ideref.IDeref/deref success-result)
                    (try (std.protocol.ideref.IDeref/deref failure-result)
                         false
                         (catch error true))]))
     :expect {:display "true"}}
    {:id :native/base-reduced-uuid-and-apply
     :program (= [42 42 42 true :std.native.Reduced :std.native.Vector]
                 [(std.native.Base/unreduced (std.native.Base/reduced 42))
                  (std.native.Base/unreduced 42)
                  (std.native.Base/apply + [19 23])
                  (= (std.native.Base/uuid "00000000-0000-0000-0000-000000000000")
                     (std.native.Base/uuid "00000000-0000-0000-0000-000000000000"))
                  (std.native.Base/type (std.native.Base/reduced 1))
                  (std.native.Base/type (std.native.Base/vector 1))])
     :expect {:display "true"}}
    {:id :native/iter-portable-surface
     :program (let [iter (std.native.Iter/iter [1 2 3])
                    mapped (std.native.Iter/iter-map (fn [value] (* value 2)) [1 2])
                    filtered (std.native.Iter/iter-filter (fn [value] (= value 2)) [1 2 3])
                    zipped (std.native.Iter/iter-zip [1 2] [3 4])
                    closed (std.native.Iter/iter [1])]
                (std.native.Iter/iter-close closed)
                (= [[1 2] 1 true true 2 2 3 false]
                   [(std.native.Iter/iter-materialize [1 2])
                    (std.native.Iter/iter-next iter)
                    (std.native.Iter/iter-next? iter)
                    (std.native.Iter/iter-finite? mapped)
                    (std.native.Iter/iter-next mapped)
                    (std.native.Iter/iter-next filtered)
                    (std.protocol.inth.INth/nth (std.native.Iter/iter-next zipped) 1)
                    (std.native.Iter/iter-next? closed)]))
     :expect {:display "true"}}
    {:id :native/base-vector
     :program (= [1 2 3] (std.native.Base/vector 1 2 3))
     :expect {:display "true"}}
    {:id :native/base-map-entry
     :program (let [entry (std.native.Base/map-entry :answer 42)]
                (= [:std.native.MapEntry :answer 42]
                   [(std.native.Base/type entry)
                    (std.protocol.ipair.IPair/key entry)
                    (std.protocol.ipair.IPair/value entry)]))
     :expect {:display "true"}}
    {:id :native/base-declaration-abi
     :program (let [target (std.native.Base/namespace 'hnc.native)
                    user-type (std.native.Base/struct
                               target 'User (std.native.Base/vector 'name))
                    session-type (std.native.Base/mutable
                                  target 'Session (std.native.Base/vector 'token))
                    _ (std.native.Base/def target 'answer (fn [] 42) nil)
                    greeting (std.native.Base/protocol
                              target 'IGreeting {'greet 1} (std.native.Base/vector))
                    _ (std.native.Base/extend
                        target user-type greeting
                        {'greet (fn [user] "hello Ada")})
                    user ((std.protocol.ideref.IDeref/deref
                           (std.native.Base/resolve target '->User)) "Ada")
                    session ((std.protocol.ideref.IDeref/deref
                              (std.native.Base/resolve target '->Session)) "session-token")
                    dispatch (std.native.Base/with-declaration
                              target
                              (fn []
                                (std.native.Base/multimethod target 'classify (fn [value] value))
                                (std.native.Base/method target 'classify :answer (fn [value] 42))
                                ((std.protocol.ideref.IDeref/deref
                                  (std.native.Base/resolve target 'classify)) :answer)))]
                (= [42 "hello Ada" "session-token" true 42]
                   [((std.protocol.ideref.IDeref/deref
                      (std.native.Base/resolve target 'answer)))
                    ((std.protocol.ideref.IDeref/deref
                      (std.native.Base/resolve target 'greet)) user)
                    (std.native.Base/field session :token)
                    (do (std.native.Base/protocol
                          target 'IGreeting {'welcome 1} (std.native.Base/vector))
                        (= nil (std.native.Base/resolve target 'greet)))
                    dispatch]))
     :expect {:display "true"}}
    {:id :native/vector-type
     :program (= :std.native.Vector (std.native.Base/type [1]))
     :expect {:display "true"}}
    {:id :native/map-entry-type
     :program (= :std.native.MapEntry
                 (std.native.Base/type
                   (std.protocol.ifind.IFind/find {:answer 42} :answer)))
     :expect {:display "true"}}
    {:id :native/coroutine-create-yield
     :program (do
                (def hnc-coroutine
                  (std.native.Coroutine/create
                    (fn [] (std.native.Coroutine/yield 42))))
                (= 42
                   (std.protocol.icoroutine.ICoroutine/resume hnc-coroutine)))
     :expect {:display "true"}}
    {:id :native/instrument-provider
     :program (= :std.native.Keyword
                 (std.native.Base/type
                   (std.protocol.ilookup.ILookup/lookup
                     (std.native.Instrument/provider)
                     :provider/id)))
     :expect {:display "true"}}
    {:id :native/crypto-key-and-signature-semantics
     :program (let [message (std.native.Base/bytes 1 2 3)
                    ed (std.native.Crypto/ed25519-keypair)
                    ed-private (std.protocol.ilookup.ILookup/lookup ed :private)
                    ed-public (std.protocol.ilookup.ILookup/lookup ed :public)
                    ed-signature (std.native.Crypto/ed25519-sign ed-private message)
                    x-left (std.native.Crypto/x25519-keypair)
                    x-right (std.native.Crypto/x25519-keypair)
                    x-left-private (std.protocol.ilookup.ILookup/lookup x-left :private)
                    x-left-public (std.protocol.ilookup.ILookup/lookup x-left :public)
                    x-right-private (std.protocol.ilookup.ILookup/lookup x-right :private)
                    x-right-public (std.protocol.ilookup.ILookup/lookup x-right :public)
                    p (std.native.Crypto/p256-keypair)
                    p-private (std.protocol.ilookup.ILookup/lookup p :private)
                    p-public (std.protocol.ilookup.ILookup/lookup p :public)
                    p-signature (std.native.Crypto/p256-sign p-private message)]
                (= ["039058c6f2c0cb492c533b0a4d14ef77cc0f78abccced5287d84a1a2011cfb81"
                    64 128 4 true true true true true true true true true true true]
                   [(std.native.Crypto/sha256 message)
                    (std.native.String/length (std.native.Crypto/hmac-sha256 message message))
                    (std.native.String/length (std.native.Crypto/hmac-sha512 message message))
                    (std.native.Bytes/count (std.native.Crypto/random-bytes 4))
                    (std.native.Crypto/secure-equal? message message)
                    (= 32 (std.native.Bytes/count ed-private))
                    (= ed-public (std.native.Crypto/ed25519-public ed-private))
                    (std.native.Crypto/ed25519-verify ed-public message ed-signature)
                    (= 32 (std.native.Bytes/count x-left-private))
                    (= x-left-public (std.native.Crypto/x25519-public x-left-private))
                    (= (std.native.Crypto/x25519-shared x-left-private x-right-public)
                       (std.native.Crypto/x25519-shared x-right-private x-left-public))
                    (= 32 (std.native.Bytes/count p-private))
                    (= p-public (std.native.Crypto/p256-public p-private))
                    (std.native.Crypto/p256-verify p-public message p-signature)
                    (= 32 (std.native.Bytes/count
                             (std.native.Crypto/p256-shared p-private p-public)))]))
     :expect {:display "true"}}
    {:id :native/promise-construction-semantics
     :program (let [from (std.native.Promise/from 42)
                    run (std.native.Promise/run (fn [] 7))
                    made (std.native.Promise/new (fn [resolve reject] (resolve 9)))
                    all (std.native.Promise/all [(std.native.Promise/from 1)
                                                 (std.native.Promise/from 2)])
                    delayed (std.native.Promise/delay 0 (fn [] 3))]
                (= [42 7 9 1 2 3]
                   [(std.protocol.ideref.IDeref/deref from)
                    (std.protocol.ideref.IDeref/deref run)
                    (std.protocol.ideref.IDeref/deref made)
                    (std.protocol.inth.INth/nth
                      (std.protocol.ideref.IDeref/deref all) 0)
                    (std.protocol.inth.INth/nth
                      (std.protocol.ideref.IDeref/deref all) 1)
                    (std.protocol.ideref.IDeref/deref delayed)]))
     :expect {:display "true"}}
    {:id :native/array-mutation-and-fold-semantics
     :program (let [array (std.native.Arr/new 1 2)
                    _ (std.native.Arr/push-first array 0)
                    _ (std.native.Arr/push-last array 3)
                    _ (std.native.Arr/insert array 2 9)
                    removed (std.native.Arr/remove array 2)
                    first (std.native.Arr/pop-first array)
                    last (std.native.Arr/pop-last array)]
                (= [9 0 3 1 2 2 4 1 3 3]
                   [removed
                    first
                    last
                    (std.native.Arr/get (std.native.Arr/slice array 0) 0)
                    (std.native.Arr/get (std.native.Arr/slice array 0) 1)
                    (std.native.Arr/get (std.native.Arr/map array (fn [value] (* value 2))) 0)
                    (std.native.Arr/get (std.native.Arr/map array (fn [value] (* value 2))) 1)
                    (std.native.Arr/get (std.native.Arr/filter array (fn [value] (= value 1))) 0)
                    (std.native.Arr/fold-left array (fn [acc value] (+ acc value)) 0)
                    (std.native.Arr/fold-right array (fn [value acc] (+ acc value)) 0)]))
     :expect {:display "true"}}
    {:id :native/object-assignment-and-views
     :program (let [object (std.native.Obj/new "a" 1)
                    _ (std.native.Obj/assign object (std.native.Obj/new "b" 2))]
                (= [2 "a" "b" 1 2 "a" 1 "b" 2]
                   [(std.native.Obj/get object "b")
                    (std.native.Arr/get (std.native.Obj/keys object) 0)
                    (std.native.Arr/get (std.native.Obj/keys object) 1)
                    (std.native.Arr/get (std.native.Obj/vals object) 0)
                    (std.native.Arr/get (std.native.Obj/vals object) 1)
                    (std.native.Arr/get (std.native.Arr/get (std.native.Obj/pairs object) 0) 0)
                    (std.native.Arr/get (std.native.Arr/get (std.native.Obj/pairs object) 0) 1)
                    (std.native.Arr/get (std.native.Arr/get (std.native.Obj/pairs object) 1) 0)
                    (std.native.Arr/get (std.native.Arr/get (std.native.Obj/pairs object) 1) 1)]))
     :expect {:display "true"}}
    {:id :native/coroutine-await-semantics
     :program (do
                (def hnc-await-coroutine
                  (std.native.Coroutine/create
                    (fn [] (std.native.Coroutine/await (std.native.Promise/from 8)))))
                (= 8
                   (std.protocol.icoroutine.ICoroutine/resume hnc-await-coroutine)))
     :expect {:display "true"}}
    {:id :native/stream-create-generate-and-next
     :program (let [stream (std.native.Stream/create
                              (fn [] (std.native.Promise/from 42)))
                    generated (std.native.Stream/generate
                               (fn [value] (std.native.Promise/from value)) 7)]
                (= [42 nil]
                   [(std.protocol.ideref.IDeref/deref (std.native.Stream/next stream))
                    (std.protocol.ideref.IDeref/deref (std.native.Stream/next generated))]))
     :expect {:display "true"}}
    {:id :native/runtime-namespace-and-evaluation-semantics
     :program (let [target (std.native.Runtime/ns-create
                            (std.native.Base/symbol "hnc.runtime-functional"))
                    _ (std.native.Base/def target (std.native.Base/symbol "answer") 42 nil)
                    first (std.native.Runtime/gensym "hnc")
                    second (std.native.Runtime/gensym "hnc")]
                (std.native.Iter/iter-every? (fn [value] value)
                  (std.native.Iter/iter-take 18
                    (std.native.Iter/iter-map
                      (fn [pair]
                        (= (std.protocol.inth.INth/nth pair 0)
                           (std.protocol.inth.INth/nth pair 1)))
                      (std.native.Iter/iter-zip ['hnc.runtime-functional
                    'hnc.runtime-functional/direct
                    :std.native.Namespace
                    :std.native.OrderedMap :std.native.OrderedMap
                    :std.native.Symbol :std.native.OrderedMap :std.native.OrderedMap
                    :std.native.Vector :std.native.OrderedMap
                    :std.native.OrderedMap
                    nil 42 3 42 false
                    'hnc.runtime-functional/copy 'hnc.runtime-functional]
                   [(std.native.Runtime/ns-name target)
                    (std.native.Runtime/var-sym
                      (std.native.Base/def target (std.native.Base/symbol "direct") 1 nil))
                    (std.native.Base/type
                      (std.native.Runtime/ns-find (std.native.Base/symbol "hnc.runtime-functional")))
                    (std.native.Base/type (std.native.Runtime/ns-publics target))
                    (std.native.Base/type (std.native.Runtime/ns-aliases target))
                    (std.native.Base/type (std.native.Runtime/current))
                    (std.native.Base/type (std.native.Runtime/snapshot))
                    (std.native.Base/type (std.native.Runtime/vars target))
                    (std.native.Base/type (std.native.Runtime/namespaces))
                    (std.native.Base/type (std.native.Runtime/namespace target))
                    (std.native.Base/type
                      (std.native.Runtime/module "classpath:hnc/runtime-functional.hal"))
                    (std.native.Runtime/alias-state (std.native.Base/symbol "missing"))
                    (std.native.Runtime/eval (quote 42))
                    (std.native.Runtime/eval-in target [(quote 3)])
                    (std.native.Runtime/macroexpand-1 (quote 42))
                    (= first second)
                    (std.native.Runtime/var-sym
                      (std.native.Runtime/intern-var target (std.native.Base/symbol "copy")
                        (std.native.Base/def target (std.native.Base/symbol "source") 7 nil)))
                    (std.native.Runtime/ns-name
                      (std.native.Runtime/ns-create (std.native.Base/symbol "hnc.runtime-functional")))])))))
     :expect {:display "true"}}
    {:id :native/printer-capture-and-layout
     :program (= "a1\nb"
                 (std.native.Printer/capture
                   (fn []
                     (std.native.Printer/p "a")
                     (std.native.Printer/println 1)
                     (std.native.Printer/p "b"))))
     :expect {:display "true"}}
    {:id :native/document-construction-and-rendering
     :program (let [text (std.native.Document/text "hello")
                    line (std.native.Document/line)
                    fragment (std.native.Document/fragment text line
                               (std.native.Document/text "world"))]
                (= [true "hello" "hello\nworld" [:p "hello"]
                    [:document/annotate :tag "hello"] [:document/pass "hello"]
                    [:document/escaped "<x>"] [:document/group "hello"]
                    [:document/line] [:document/break] [:document/nest 2 "hello"]
                    [:document/align 2 "hello"] "hello"]
                   [(std.native.Document/valid? text)
                    (std.native.Document/render text)
                    (std.native.Document/render fragment)
                    (std.native.Document/element :p text)
                    (std.native.Document/annotate :tag text)
                    (std.native.Document/pass text)
                    (std.native.Document/escaped "<x>")
                    (std.native.Document/group text)
                    line
                    (std.native.Document/break)
                    (std.native.Document/nest 2 text)
                    (std.native.Document/align 2 text)
                    (std.native.Document/normalize text)]))
     :expect {:display "true"}}
    {:id :native/codec-pretty-and-read-forms-boundaries
     :program (= [{:a 1} "{:a 1}" "{:a 1}" {"a" 1} "{\"a\":1}" "{\n  \"a\": 1\n}"
                  true]
                 [(std.native.Edn/read "{:a 1}")
                  (std.native.Edn/write {:a 1})
                  (std.native.Edn/pretty {:a 1} {})
                  (std.native.Json/read "{\"a\":1}")
                  (std.native.Json/write {"a" 1})
                  (std.native.Json/pretty {"a" 1} {})
                  (try (std.native.Edn/read-forms "fixture.txt") false
                       (catch error true))])
     :expect {:display "true"}}
    {:id :native/instrument-invalid-artifact-boundaries
     :program (= [:std.native.Keyword true true true true true]
                 [(std.native.Base/type
                   (std.protocol.ilookup.ILookup/lookup
                     (std.native.Instrument/provider) :provider/id))
                  (try (std.native.Instrument/validate :hbc (std.native.Base/bytes))
                       false (catch error true))
                  (try (std.native.Instrument/inspect :hbc (std.native.Base/bytes))
                       false (catch error true))
                  (try (std.native.Instrument/disassemble (std.native.Base/bytes))
                       false (catch error true))
                  (try (std.native.Instrument/transform :unknown :unknown "" {})
                       false (catch error true))
                  (try (std.native.Instrument/execute :hbc (std.native.Base/bytes) {})
                       false (catch error true))])
     :expect {:display "true"}}
    {:id :native/command-app-route-lifecycle
     :program (let [app (std.native.Command/create
                         {:id (quote demo/cli) :desc "Demo CLI"})
                    config (std.native.Command/config app)
                    route (std.native.Command/install app
                            {:id :test :path ["test"] :aliases [["t"]] :desc "Run tests"
                             :options [{:id :watch :short "w" :type :boolean}
                                       {:id :namespace :type :string :many? true}]
                             :arguments [{:id :files :required? false :many? true}]
                             :handler (fn [_] {:stdout "ok" :stderr "" :exit 0})})
                    snapshot (std.native.Command/snapshot app)
                    parsed (std.native.Command/parse app
                             {:argv ["t" "-w" "--namespace" "demo.core" "a_test.hal"]
                              :context {:origin :test}})
                    dispatched (std.native.Command/dispatch app parsed)
                    response (std.native.Command/run app {:argv ["test"]})
                    removed (std.native.Command/uninstall app route)
                    absent (std.native.Command/uninstall app route)
                    _ (std.native.Command/restore app snapshot)
                    restored (std.native.Command/routes app)
                    _ (std.native.Command/reset app)
                    reset-routes (std.native.Command/routes app)
                    closed-before (std.native.Command/closed? app)
                    _ (std.native.Command/close app)
                    closed-after (std.native.Command/closed? app)
                    _ (std.native.Command/close app)]
                (= [(= (:id config) (quote demo/cli))
                    (:desc config)
                    (:route/id parsed)
                    (:options parsed)
                    (:arguments parsed)
                    dispatched
                    response
                    removed
                    absent
                    (std.protocol.icount.ICount/count restored)
                    (std.protocol.icount.ICount/count reset-routes)
                    closed-before
                    closed-after]
                   [true "Demo CLI" :test
                    {:watch true :namespace ["demo.core"]}
                    {:files ["a_test.hal"]}
                    {:stdout "ok" :stderr "" :exit 0}
                    {:stdout "ok" :stderr "" :exit 0}
                    true false 1 0 false true]))
     :expect {:display "true"}}
    {:id :native/test-registry-and-result-semantics
     :program (let [config (std.native.Test/config {})
                    context (std.native.Test/context config)
                    equal (std.native.Test/compare 1 1)
                    different (std.native.Test/compare 1 2)
                    passed (std.native.Test/result "pass" 1 1 equal)
                    failed (std.native.Test/result "fail" 1 2 different)
                    checks (std.native.Test/check
                             [{:desc "direct check" :test (fn [] 3) :expected 3}])
                    check-result (std.protocol.inth.INth/nth checks 0)
                    _ (std.native.Test/reset)
                    registered (std.native.Test/register
                                 {:desc "advance increments"
                                  :test (fn [] 3)
                                  :expected 3
                                  :meta {:id (quote advance-increments)}})
                    facts (std.native.Test/facts)
                    got (std.native.Test/get "advance increments")
                    direct-fact (std.native.Test/run-fact "advance increments")
                    aggregate (std.native.Test/summary [direct-fact])
                    removed (std.native.Test/remove "advance increments")
                    _ (std.native.Test/register
                       {:desc "purge me" :test (fn [] 3) :expected 3})
                    purged (std.native.Test/purge)
                    run-summary (std.native.Test/run)]
                (= [:std.native.HashMap :std.native.HashMap :std.native.Pointer
                    :std.native.Vector :std.native.Result true 1 1 0 1
                    :std.native.Vector :std.native.Vector true
                    :std.native.Vector true 1 true true :passed :passed true 1 :passed]
                   [(std.native.Base/type (std.native.Test/catalog))
                    (std.native.Base/type config)
                    (std.native.Base/type context)
                    (std.native.Base/type (std.native.Test/events))
                    (std.native.Base/type equal)
                    (std.native.Test/passed? passed)
                    (std.native.Test/actual passed)
                    (std.native.Test/expected passed)
                    (std.native.Test/failure-count passed)
                    (std.native.Test/failure-count failed)
                    (std.native.Base/type (std.native.Test/failures failed))
                    (std.native.Base/type (std.native.Test/failure-seq failed))
                    (std.native.Test/failure? (std.native.Test/failure failed 0))
                    (std.native.Base/type checks)
                    (std.native.Test/passed? check-result)
                    (std.protocol.icount.ICount/count facts)
                    (= (:desc got) "advance increments")
                    (= (:desc registered) "advance increments")
                    (:status direct-fact)
                    (:status aggregate)
                    (= (:desc removed) "advance increments")
                    (std.protocol.icount.ICount/count purged)
                    (:status run-summary)]))
     :expect {:display "true"}}]}

  {:id :protocol
   :setup nil
   :cases
   [{:id :protocol/assoc
     :program (= {:a 1 :b 2}
                 (std.protocol.iassoc.IAssoc/assoc {:a 1} :b 2))
     :expect {:display "true"}}
    {:id :protocol/lookup
     :program (= 42
                 (std.protocol.ilookup.ILookup/lookup {:answer 42} :answer))
     :expect {:display "true"}}
    {:id :protocol/map-entry
     :program (let [entry (std.protocol.ifind.IFind/find {:answer 42} :answer)]
                (= [:answer 42]
                   [(std.protocol.ipair.IPair/key entry)
                    (std.protocol.ipair.IPair/value entry)]))
     :expect {:display "true"}}
    {:id :protocol/vector
     :program (let [vector [1 2 3]]
                (= [1 2]
                   [(std.protocol.ipeekfirst.IPeekFirst/peek-first vector)
                    (std.protocol.inth.INth/nth vector 1)]))
     :expect {:display "true"}}
    {:id :protocol/coroutine-resume
     :program (let [coroutine
                    (std.native.Coroutine/create
                      (fn [] (std.native.Coroutine/yield 42)))]
                (= 42
                   (std.protocol.icoroutine.ICoroutine/resume coroutine)))
     :expect {:display "true"}}
    {:id :protocol/unsupported-receiver
     :program (try
                (std.protocol.iassoc.IAssoc/assoc 42 :answer 1)
                false
                (catch error true))
     :expect {:display "true"}}
    {:id :protocol/assoc-unsupported-exact
     :program (std.protocol.iassoc.IAssoc/assoc 42 :answer 1)
     :expect {:error :protocol/unsupported-receiver}}
    {:id :protocol/assoc-arity-exact
     :program (std.protocol.iassoc.IAssoc/assoc)
     :expect {:error :protocol/arity}}
    {:id :protocol/native-collection-and-watch-semantics
     :program (let [cell (std.native.Base/atom 1)
                    seen (std.native.Base/atom nil)
                    _ (std.protocol.iwatch.IWatch/watch-add
                        cell :log
                        (fn [key reference old-value new-value]
                          (std.protocol.ireset.IReset/reset
                            seen [key old-value new-value])))
                    _ (std.protocol.ireset.IReset/reset cell 2)]
                (= [2 [1 2] {:a 1} [1 2] [1] [] {:a 1} [2 [:log 1 2]]]
                   [(std.protocol.icount.ICount/count [1 2])
                    (std.protocol.iconj.IConj/conj [1] 2)
                    (std.protocol.idissoc.IDissoc/dissoc {:a 1 :b 2} :b)
                    (std.protocol.ipushlast.IPushLast/push-last [1] 2)
                    (std.protocol.ipoplast.IPopLast/pop-last [1 2])
                    (std.protocol.iempty.IEmpty/empty [1])
                    (std.protocol.iassoc.IAssoc/assoc {} :a 1)
                    [(std.protocol.ideref.IDeref/deref cell)
                     (std.protocol.ideref.IDeref/deref seen)]]))
     :expect {:display "true"}}
    {:id :protocol/extension-replacement-and-parent-dispatch
     :program (let [target (std.native.Base/namespace 'hnc.protocol.lifecycle)
                    immutable (std.native.Base/struct target 'Immutable (std.native.Base/vector 'value))
                    mutable (std.native.Base/mutable target 'Mutable (std.native.Base/vector 'value))
                    read-protocol (std.native.Base/protocol target 'IRead {'read 1} (std.native.Base/vector))
                    coroutine (std.protocol.ideref.IDeref/deref
                                (std.native.Base/resolve 'std.protocol.icoroutine.ICoroutine))
                    close (std.protocol.ideref.IDeref/deref
                            (std.native.Base/resolve 'std.protocol.iclose.IClose))
                    _ (std.native.Base/extend target immutable read-protocol
                        {'read (fn [receiver] 41)})
                    _ (std.native.Base/extend target mutable read-protocol
                        {'read (fn [receiver] (std.native.Base/field receiver :value))})
                    _ (std.native.Base/extend target immutable coroutine
                        {'status (fn [receiver] :ready)
                         'resume (fn [& values] :resumed)})
                    _ (std.native.Base/extend target immutable close
                        {'close (fn [receiver] :closed)})
                    immutable-value ((std.protocol.ideref.IDeref/deref
                                      (std.native.Base/resolve target '->Immutable)) 41)
                    mutable-value ((std.protocol.ideref.IDeref/deref
                                    (std.native.Base/resolve target '->Mutable)) 42)
                    immutable-before ((std.protocol.ideref.IDeref/deref
                                       (std.native.Base/resolve target 'read)) immutable-value)
                    mutable-before ((std.protocol.ideref.IDeref/deref
                                     (std.native.Base/resolve target 'read)) mutable-value)
                    _ (std.native.Base/extend target immutable read-protocol
                        {'read (fn [receiver] 42)})]
                (= [41 42 42 :ready :resumed :closed]
                   [immutable-before
                    mutable-before
                    ((std.protocol.ideref.IDeref/deref
                       (std.native.Base/resolve target 'read)) immutable-value)
                    (std.protocol.icoroutine.ICoroutine/status immutable-value)
                    (std.protocol.icoroutine.ICoroutine/resume immutable-value)
                    (std.protocol.iclose.IClose/close immutable-value)]))
     :expect {:display "true"}}]}]}