lisette-stdlib 0.1.15

Little language inspired by Rust that compiles to Go
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
// Generated by Lisette bindgen
// Source: testing (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.14

import "go:context"
import "go:io"
import "go:time"

/// AllocsPerRun returns the average number of allocations during calls to f.
/// Although the return value has type float64, it will always be an integral value.
/// 
/// To compute the number of allocations, the function will first be run once as
/// a warm-up. The average number of allocations over the specified number of
/// runs will then be measured and returned.
/// 
/// AllocsPerRun sets [runtime.GOMAXPROCS] to 1 during its measurement and will restore
/// it before returning.
pub fn AllocsPerRun(runs: int, f: fn() -> ()) -> float64

pub fn Benchmark(f: fn(Ref<B>) -> ()) -> BenchmarkResult

/// CoverMode reports what the test coverage mode is set to. The
/// values are "set", "count", or "atomic". The return value will be
/// empty if test coverage is not enabled.
pub fn CoverMode() -> string

/// Coverage reports the current code coverage as a fraction in the range [0, 1].
/// If coverage is not enabled, Coverage returns 0.
/// 
/// When running a large set of sequential test cases, checking Coverage after each one
/// can be useful for identifying which test cases exercise new code paths.
/// It is not a replacement for the reports generated by 'go test -cover' and
/// 'go tool cover'.
pub fn Coverage() -> float64

/// Init registers testing flags. These flags are automatically registered by
/// the "go test" command before running test functions, so Init is only needed
/// when calling functions such as Benchmark without using "go test".
/// 
/// Init is not safe to call concurrently. It has no effect if it was already called.
pub fn Init()

/// Main is an internal function, part of the implementation of the "go test" command.
/// It was exported because it is cross-package and predates "internal" packages.
/// It is no longer used by "go test" but preserved, as much as possible, for other
/// systems that simulate "go test" using Main, but Main sometimes cannot be updated as
/// new functionality is added to the testing package.
/// Systems simulating "go test" should be updated to use [MainStart].
pub fn Main(
  matchString: fn(string, string) -> Result<bool, error>,
  tests: Slice<InternalTest>,
  benchmarks: Slice<InternalBenchmark>,
  examples: Slice<InternalExample>,
)

pub fn MainStart(
  deps: Unknown,
  tests: Slice<InternalTest>,
  benchmarks: Slice<InternalBenchmark>,
  fuzzTargets: Slice<InternalFuzzTarget>,
  examples: Slice<InternalExample>,
) -> Ref<M>

/// RegisterCover records the coverage data accumulators for the tests.
/// NOTE: This function is internal to the testing infrastructure and may change.
/// It is not covered (yet) by the Go 1 compatibility guidelines.
pub fn RegisterCover(c: Cover)

/// RunBenchmarks is an internal function but exported because it is cross-package;
/// it is part of the implementation of the "go test" command.
pub fn RunBenchmarks(
  matchString: fn(string, string) -> Result<bool, error>,
  benchmarks: Slice<InternalBenchmark>,
)

/// RunExamples is an internal function but exported because it is cross-package;
/// it is part of the implementation of the "go test" command.
pub fn RunExamples(
  matchString: fn(string, string) -> Result<bool, error>,
  examples: Slice<InternalExample>,
) -> bool

/// RunTests is an internal function but exported because it is cross-package;
/// it is part of the implementation of the "go test" command.
pub fn RunTests(
  matchString: fn(string, string) -> Result<bool, error>,
  tests: Slice<InternalTest>,
) -> bool

/// Short reports whether the -test.short flag is set.
pub fn Short() -> bool

/// Testing reports whether the current code is being run in a test.
/// This will report true in programs created by "go test",
/// false in programs created by "go build".
pub fn Testing() -> bool

/// Verbose reports whether the -test.v flag is set.
pub fn Verbose() -> bool

/// B is a type passed to [Benchmark] functions to manage benchmark
/// timing and control the number of iterations.
/// 
/// A benchmark ends when its Benchmark function returns or calls any of the methods
/// [B.FailNow], [B.Fatal], [B.Fatalf], [B.SkipNow], [B.Skip], or [B.Skipf].
/// Those methods must be called only from the goroutine running the Benchmark function.
/// The other reporting methods, such as the variations of [B.Log] and [B.Error],
/// may be called simultaneously from multiple goroutines.
/// 
/// Like in tests, benchmark logs are accumulated during execution
/// and dumped to standard output when done. Unlike in tests, benchmark logs
/// are always printed, so as not to hide output whose existence may be
/// affecting benchmark results.
pub struct B {
  pub N: int,
}

/// BenchmarkResult contains the results of a benchmark run.
pub struct BenchmarkResult {
  pub N: int,
  pub T: time.Duration,
  pub Bytes: int64,
  pub MemAllocs: uint64,
  pub MemBytes: uint64,
  pub Extra: Map<string, float64>,
}

/// Cover records information about test coverage checking.
/// NOTE: This struct is internal to the testing infrastructure and may change.
/// It is not covered (yet) by the Go 1 compatibility guidelines.
pub struct Cover {
  pub Mode: string,
  pub Counters: Map<string, Slice<uint32>>,
  pub Blocks: Map<string, Slice<CoverBlock>>,
  pub CoveredPackages: string,
}

/// CoverBlock records the coverage data for a single basic block.
/// The fields are 1-indexed, as in an editor: The opening line of
/// the file is number 1, for example. Columns are measured
/// in bytes.
/// NOTE: This struct is internal to the testing infrastructure and may change.
/// It is not covered (yet) by the Go 1 compatibility guidelines.
pub struct CoverBlock {
  pub Line0: uint32,
  pub Col0: uint16,
  pub Line1: uint32,
  pub Col1: uint16,
  pub Stmts: uint16,
}

/// F is a type passed to fuzz tests.
/// 
/// Fuzz tests run generated inputs against a provided fuzz target, which can
/// find and report potential bugs in the code being tested.
/// 
/// A fuzz test runs the seed corpus by default, which includes entries provided
/// by [F.Add] and entries in the testdata/fuzz/<FuzzTestName> directory. After
/// any necessary setup and calls to [F.Add], the fuzz test must then call
/// [F.Fuzz] to provide the fuzz target. See the testing package documentation
/// for an example, and see the [F.Fuzz] and [F.Add] method documentation for
/// details.
/// 
/// *F methods can only be called before [F.Fuzz]. Once the test is
/// executing the fuzz target, only [*T] methods can be used. The only *F methods
/// that are allowed in the [F.Fuzz] function are [F.Failed] and [F.Name].
pub type F

/// InternalBenchmark is an internal type but exported because it is cross-package;
/// it is part of the implementation of the "go test" command.
pub struct InternalBenchmark {
  pub Name: string,
  pub F: fn(Ref<B>) -> (),
}

pub struct InternalExample {
  pub Name: string,
  pub F: fn() -> (),
  pub Output: string,
  pub Unordered: bool,
}

/// InternalFuzzTarget is an internal type but exported because it is
/// cross-package; it is part of the implementation of the "go test" command.
pub struct InternalFuzzTarget {
  pub Name: string,
  pub Fn: fn(Ref<F>) -> (),
}

/// InternalTest is an internal type but exported because it is cross-package;
/// it is part of the implementation of the "go test" command.
pub struct InternalTest {
  pub Name: string,
  pub F: fn(Ref<T>) -> (),
}

/// M is a type passed to a TestMain function to run the actual tests.
pub type M

/// A PB is used by RunParallel for running parallel benchmarks.
pub type PB

/// T is a type passed to Test functions to manage test state and support formatted test logs.
/// 
/// A test ends when its Test function returns or calls any of the methods
/// [T.FailNow], [T.Fatal], [T.Fatalf], [T.SkipNow], [T.Skip], or [T.Skipf]. Those methods, as well as
/// the [T.Parallel] method, must be called only from the goroutine running the
/// Test function.
/// 
/// The other reporting methods, such as the variations of [T.Log] and [T.Error],
/// may be called simultaneously from multiple goroutines.
pub type T

/// TB is the interface common to [T], [B], and [F].
pub interface TB {
  fn Attr(key: string, value: string)
  fn Chdir(dir: string)
  fn Cleanup(arg0: fn() -> ())
  fn Context() -> context.Context
  fn Error(args: Slice<Unknown>)
  fn Errorf(format: string, args: Slice<Unknown>)
  fn Fail()
  fn FailNow()
  fn Failed() -> bool
  fn Fatal(args: Slice<Unknown>)
  fn Fatalf(format: string, args: Slice<Unknown>)
  fn Helper()
  fn Log(args: Slice<Unknown>)
  fn Logf(format: string, args: Slice<Unknown>)
  fn Name() -> string
  fn Output() -> io.Writer
  fn Setenv(key: string, value: string)
  fn Skip(args: Slice<Unknown>)
  fn SkipNow()
  fn Skipf(format: string, args: Slice<Unknown>)
  fn Skipped() -> bool
  fn TempDir() -> string
}

impl B {
  /// Attr emits a test attribute associated with this test.
  /// 
  /// The key must not contain whitespace.
  /// The value must not contain newlines or carriage returns.
  /// 
  /// The meaning of different attribute keys is left up to
  /// continuous integration systems and test frameworks.
  /// 
  /// Test attributes are emitted immediately in the test log,
  /// but they are intended to be treated as unordered.
  fn Attr(self: Ref<B>, key: string, value: string)

  /// Chdir calls [os.Chdir] and uses Cleanup to restore the current
  /// working directory to its original value after the test. On Unix, it
  /// also sets PWD environment variable for the duration of the test.
  /// 
  /// Because Chdir affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Chdir(self: Ref<B>, dir: string)

  /// Cleanup registers a function to be called when the test (or subtest) and all its
  /// subtests complete. Cleanup functions will be called in last added,
  /// first called order.
  fn Cleanup(self: Ref<B>, f: fn() -> ())

  /// Context returns a context that is canceled just before
  /// Cleanup-registered functions are called.
  /// 
  /// Cleanup functions can wait for any resources
  /// that shut down on [context.Context.Done] before the test or benchmark completes.
  fn Context(self: Ref<B>) -> context.Context

  /// Elapsed returns the measured elapsed time of the benchmark.
  /// The duration reported by Elapsed matches the one measured by
  /// [B.StartTimer], [B.StopTimer], and [B.ResetTimer].
  fn Elapsed(self: Ref<B>) -> time.Duration

  /// Error is equivalent to Log followed by Fail.
  fn Error(self: Ref<B>, args: VarArgs<Unknown>)

  /// Errorf is equivalent to Logf followed by Fail.
  fn Errorf(self: Ref<B>, format: string, args: VarArgs<Unknown>)

  /// Fail marks the function as having failed but continues execution.
  fn Fail(self: Ref<B>)

  /// FailNow marks the function as having failed and stops its execution
  /// by calling [runtime.Goexit] (which then runs all deferred calls in the
  /// current goroutine).
  /// Execution will continue at the next test or benchmark.
  /// FailNow must be called from the goroutine running the
  /// test or benchmark function, not from other goroutines
  /// created during the test. Calling FailNow does not stop
  /// those other goroutines.
  fn FailNow(self: Ref<B>)

  /// Failed reports whether the function has failed.
  fn Failed(self: Ref<B>) -> bool

  /// Fatal is equivalent to Log followed by FailNow.
  fn Fatal(self: Ref<B>, args: VarArgs<Unknown>)

  /// Fatalf is equivalent to Logf followed by FailNow.
  fn Fatalf(self: Ref<B>, format: string, args: VarArgs<Unknown>)

  /// Helper marks the calling function as a test helper function.
  /// When printing file and line information, that function will be skipped.
  /// Helper may be called simultaneously from multiple goroutines.
  fn Helper(self: Ref<B>)

  /// Log formats its arguments using default formatting, analogous to [fmt.Println],
  /// and records the text in the error log. For tests, the text will be printed only if
  /// the test fails or the -test.v flag is set. For benchmarks, the text is always
  /// printed to avoid having performance depend on the value of the -test.v flag.
  /// It is an error to call Log after a test or benchmark returns.
  fn Log(self: Ref<B>, args: VarArgs<Unknown>)

  /// Logf formats its arguments according to the format, analogous to [fmt.Printf], and
  /// records the text in the error log. A final newline is added if not provided. For
  /// tests, the text will be printed only if the test fails or the -test.v flag is
  /// set. For benchmarks, the text is always printed to avoid having performance
  /// depend on the value of the -test.v flag.
  /// It is an error to call Logf after a test or benchmark returns.
  fn Logf(self: Ref<B>, format: string, args: VarArgs<Unknown>)

  /// Loop returns true as long as the benchmark should continue running.
  /// 
  /// A typical benchmark is structured like:
  /// 
  /// 	func Benchmark(b *testing.B) {
  /// 		... setup ...
  /// 		for b.Loop() {
  /// 			... code to measure ...
  /// 		}
  /// 		... cleanup ...
  /// 	}
  /// 
  /// Loop resets the benchmark timer the first time it is called in a benchmark,
  /// so any setup performed prior to starting the benchmark loop does not count
  /// toward the benchmark measurement. Likewise, when it returns false, it stops
  /// the timer so cleanup code is not measured.
  /// 
  /// Within the body of a "for b.Loop() { ... }" loop, arguments to and
  /// results from function calls within the loop are kept alive, preventing
  /// the compiler from fully optimizing away the loop body. Currently, this is
  /// implemented by disabling inlining of functions called in a b.Loop loop.
  /// This applies only to calls syntactically between the curly braces of the loop,
  /// and the loop condition must be written exactly as "b.Loop()". Optimizations
  /// are performed as usual in any functions called by the loop.
  /// 
  /// After Loop returns false, b.N contains the total number of iterations that
  /// ran, so the benchmark may use b.N to compute other average metrics.
  /// 
  /// Prior to the introduction of Loop, benchmarks were expected to contain an
  /// explicit loop from 0 to b.N. Benchmarks should either use Loop or contain a
  /// loop to b.N, but not both. Loop offers more automatic management of the
  /// benchmark timer, and runs each benchmark function only once per measurement,
  /// whereas b.N-based benchmarks must run the benchmark function (and any
  /// associated setup and cleanup) several times.
  fn Loop(self: Ref<B>) -> bool

  /// Name returns the name of the running (sub-) test or benchmark.
  /// 
  /// The name will include the name of the test along with the names of
  /// any nested sub-tests. If two sibling sub-tests have the same name,
  /// Name will append a suffix to guarantee the returned name is unique.
  fn Name(self: Ref<B>) -> string

  /// Output returns a Writer that writes to the same test output stream as TB.Log.
  /// The output is indented like TB.Log lines, but Output does not
  /// add source locations or newlines. The output is internally line
  /// buffered, and a call to TB.Log or the end of the test will implicitly
  /// flush the buffer, followed by a newline. After a test function and all its
  /// parents return, neither Output nor the Write method may be called.
  fn Output(self: Ref<B>) -> io.Writer

  /// ReportAllocs enables malloc statistics for this benchmark.
  /// It is equivalent to setting -test.benchmem, but it only affects the
  /// benchmark function that calls ReportAllocs.
  fn ReportAllocs(self: Ref<B>)

  /// ReportMetric adds "n unit" to the reported benchmark results.
  /// If the metric is per-iteration, the caller should divide by b.N,
  /// and by convention units should end in "/op".
  /// ReportMetric overrides any previously reported value for the same unit.
  /// ReportMetric panics if unit is the empty string or if unit contains
  /// any whitespace.
  /// If unit is a unit normally reported by the benchmark framework itself
  /// (such as "allocs/op"), ReportMetric will override that metric.
  /// Setting "ns/op" to 0 will suppress that built-in metric.
  fn ReportMetric(self: Ref<B>, n: float64, unit: string)

  /// ResetTimer zeroes the elapsed benchmark time and memory allocation counters
  /// and deletes user-reported metrics.
  /// It does not affect whether the timer is running.
  fn ResetTimer(self: Ref<B>)

  /// Run benchmarks f as a subbenchmark with the given name. It reports
  /// whether there were any failures.
  /// 
  /// A subbenchmark is like any other benchmark. A benchmark that calls Run at
  /// least once will not be measured itself and will be called once with N=1.
  fn Run(self: Ref<B>, name: string, f: fn(Ref<B>) -> ()) -> bool

  /// RunParallel runs a benchmark in parallel.
  /// It creates multiple goroutines and distributes b.N iterations among them.
  /// The number of goroutines defaults to GOMAXPROCS. To increase parallelism for
  /// non-CPU-bound benchmarks, call [B.SetParallelism] before RunParallel.
  /// RunParallel is usually used with the go test -cpu flag.
  /// 
  /// The body function will be run in each goroutine. It should set up any
  /// goroutine-local state and then iterate until pb.Next returns false.
  /// It should not use the [B.StartTimer], [B.StopTimer], or [B.ResetTimer] functions,
  /// because they have global effect. It should also not call [B.Run].
  /// 
  /// RunParallel reports ns/op values as wall time for the benchmark as a whole,
  /// not the sum of wall time or CPU time over each parallel goroutine.
  fn RunParallel(self: Ref<B>, body: fn(Ref<PB>) -> ())

  /// SetBytes records the number of bytes processed in a single operation.
  /// If this is called, the benchmark will report ns/op and MB/s.
  fn SetBytes(self: Ref<B>, n: int64)

  /// SetParallelism sets the number of goroutines used by [B.RunParallel] to p*GOMAXPROCS.
  /// There is usually no need to call SetParallelism for CPU-bound benchmarks.
  /// If p is less than 1, this call will have no effect.
  fn SetParallelism(self: Ref<B>, p: int)

  /// Setenv calls [os.Setenv] and uses Cleanup to
  /// restore the environment variable to its original value
  /// after the test.
  /// 
  /// Because Setenv affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Setenv(self: Ref<B>, key: string, value: string)

  /// Skip is equivalent to Log followed by SkipNow.
  fn Skip(self: Ref<B>, args: VarArgs<Unknown>)

  /// SkipNow marks the test as having been skipped and stops its execution
  /// by calling [runtime.Goexit].
  /// If a test fails (see Error, Errorf, Fail) and is then skipped,
  /// it is still considered to have failed.
  /// Execution will continue at the next test or benchmark. See also FailNow.
  /// SkipNow must be called from the goroutine running the test, not from
  /// other goroutines created during the test. Calling SkipNow does not stop
  /// those other goroutines.
  fn SkipNow(self: Ref<B>)

  /// Skipf is equivalent to Logf followed by SkipNow.
  fn Skipf(self: Ref<B>, format: string, args: VarArgs<Unknown>)

  /// Skipped reports whether the test was skipped.
  fn Skipped(self: Ref<B>) -> bool

  /// StartTimer starts timing a test. This function is called automatically
  /// before a benchmark starts, but it can also be used to resume timing after
  /// a call to [B.StopTimer].
  fn StartTimer(self: Ref<B>)

  /// StopTimer stops timing a test. This can be used to pause the timer
  /// while performing steps that you don't want to measure.
  fn StopTimer(self: Ref<B>)

  /// TempDir returns a temporary directory for the test to use.
  /// The directory is automatically removed when the test and
  /// all its subtests complete.
  /// Each subsequent call to TempDir returns a unique directory;
  /// if the directory creation fails, TempDir terminates the test by calling Fatal.
  fn TempDir(self: Ref<B>) -> string
}

impl BenchmarkResult {
  /// AllocedBytesPerOp returns the "B/op" metric,
  /// which is calculated as r.MemBytes / r.N.
  fn AllocedBytesPerOp(self) -> int64

  /// AllocsPerOp returns the "allocs/op" metric,
  /// which is calculated as r.MemAllocs / r.N.
  fn AllocsPerOp(self) -> int64

  /// MemString returns r.AllocedBytesPerOp and r.AllocsPerOp in the same format as 'go test'.
  fn MemString(self) -> string

  /// NsPerOp returns the "ns/op" metric.
  fn NsPerOp(self) -> int64

  /// String returns a summary of the benchmark results.
  /// It follows the benchmark result line format from
  /// https://golang.org/design/14313-benchmark-format, not including the
  /// benchmark name.
  /// Extra metrics override built-in metrics of the same name.
  /// String does not include allocs/op or B/op, since those are reported
  /// by [BenchmarkResult.MemString].
  fn String(self) -> string
}

impl F {
  /// Add will add the arguments to the seed corpus for the fuzz test. This will be
  /// a no-op if called after or within the fuzz target, and args must match the
  /// arguments for the fuzz target.
  fn Add(self: Ref<F>, args: VarArgs<Unknown>)

  /// Attr emits a test attribute associated with this test.
  /// 
  /// The key must not contain whitespace.
  /// The value must not contain newlines or carriage returns.
  /// 
  /// The meaning of different attribute keys is left up to
  /// continuous integration systems and test frameworks.
  /// 
  /// Test attributes are emitted immediately in the test log,
  /// but they are intended to be treated as unordered.
  fn Attr(self: Ref<F>, key: string, value: string)

  /// Chdir calls [os.Chdir] and uses Cleanup to restore the current
  /// working directory to its original value after the test. On Unix, it
  /// also sets PWD environment variable for the duration of the test.
  /// 
  /// Because Chdir affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Chdir(self: Ref<F>, dir: string)

  /// Cleanup registers a function to be called when the test (or subtest) and all its
  /// subtests complete. Cleanup functions will be called in last added,
  /// first called order.
  fn Cleanup(self: Ref<F>, f: fn() -> ())

  /// Context returns a context that is canceled just before
  /// Cleanup-registered functions are called.
  /// 
  /// Cleanup functions can wait for any resources
  /// that shut down on [context.Context.Done] before the test or benchmark completes.
  fn Context(self: Ref<F>) -> context.Context

  /// Error is equivalent to Log followed by Fail.
  fn Error(self: Ref<F>, args: VarArgs<Unknown>)

  /// Errorf is equivalent to Logf followed by Fail.
  fn Errorf(self: Ref<F>, format: string, args: VarArgs<Unknown>)

  /// Fail marks the function as having failed but continues execution.
  fn Fail(self: Ref<F>)

  /// FailNow marks the function as having failed and stops its execution
  /// by calling [runtime.Goexit] (which then runs all deferred calls in the
  /// current goroutine).
  /// Execution will continue at the next test or benchmark.
  /// FailNow must be called from the goroutine running the
  /// test or benchmark function, not from other goroutines
  /// created during the test. Calling FailNow does not stop
  /// those other goroutines.
  fn FailNow(self: Ref<F>)

  /// Failed reports whether the function has failed.
  fn Failed(self: Ref<F>) -> bool

  /// Fatal is equivalent to Log followed by FailNow.
  fn Fatal(self: Ref<F>, args: VarArgs<Unknown>)

  /// Fatalf is equivalent to Logf followed by FailNow.
  fn Fatalf(self: Ref<F>, format: string, args: VarArgs<Unknown>)

  /// Fuzz runs the fuzz function, ff, for fuzz testing. If ff fails for a set of
  /// arguments, those arguments will be added to the seed corpus.
  /// 
  /// ff must be a function with no return value whose first argument is [*T] and
  /// whose remaining arguments are the types to be fuzzed.
  /// For example:
  /// 
  /// 	f.Fuzz(func(t *testing.T, b []byte, i int) { ... })
  /// 
  /// The following types are allowed: []byte, string, bool, byte, rune, float32,
  /// float64, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64.
  /// More types may be supported in the future.
  /// 
  /// ff must not call any [*F] methods, e.g. [F.Log], [F.Error], [F.Skip]. Use
  /// the corresponding [*T] method instead. The only [*F] methods that are allowed in
  /// the F.Fuzz function are [F.Failed] and [F.Name].
  /// 
  /// This function should be fast and deterministic, and its behavior should not
  /// depend on shared state. No mutable input arguments, or pointers to them,
  /// should be retained between executions of the fuzz function, as the memory
  /// backing them may be mutated during a subsequent invocation. ff must not
  /// modify the underlying data of the arguments provided by the fuzzing engine.
  /// 
  /// When fuzzing, F.Fuzz does not return until a problem is found, time runs out
  /// (set with -fuzztime), or the test process is interrupted by a signal. F.Fuzz
  /// should be called exactly once, unless [F.Skip] or [F.Fail] is called beforehand.
  fn Fuzz(self: Ref<F>, ff: Unknown)

  /// Helper marks the calling function as a test helper function.
  /// When printing file and line information, that function will be skipped.
  /// Helper may be called simultaneously from multiple goroutines.
  fn Helper(self: Ref<F>)

  /// Log formats its arguments using default formatting, analogous to [fmt.Println],
  /// and records the text in the error log. For tests, the text will be printed only if
  /// the test fails or the -test.v flag is set. For benchmarks, the text is always
  /// printed to avoid having performance depend on the value of the -test.v flag.
  /// It is an error to call Log after a test or benchmark returns.
  fn Log(self: Ref<F>, args: VarArgs<Unknown>)

  /// Logf formats its arguments according to the format, analogous to [fmt.Printf], and
  /// records the text in the error log. A final newline is added if not provided. For
  /// tests, the text will be printed only if the test fails or the -test.v flag is
  /// set. For benchmarks, the text is always printed to avoid having performance
  /// depend on the value of the -test.v flag.
  /// It is an error to call Logf after a test or benchmark returns.
  fn Logf(self: Ref<F>, format: string, args: VarArgs<Unknown>)

  /// Name returns the name of the running (sub-) test or benchmark.
  /// 
  /// The name will include the name of the test along with the names of
  /// any nested sub-tests. If two sibling sub-tests have the same name,
  /// Name will append a suffix to guarantee the returned name is unique.
  fn Name(self: Ref<F>) -> string

  /// Output returns a Writer that writes to the same test output stream as TB.Log.
  /// The output is indented like TB.Log lines, but Output does not
  /// add source locations or newlines. The output is internally line
  /// buffered, and a call to TB.Log or the end of the test will implicitly
  /// flush the buffer, followed by a newline. After a test function and all its
  /// parents return, neither Output nor the Write method may be called.
  fn Output(self: Ref<F>) -> io.Writer

  /// Setenv calls [os.Setenv] and uses Cleanup to
  /// restore the environment variable to its original value
  /// after the test.
  /// 
  /// Because Setenv affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Setenv(self: Ref<F>, key: string, value: string)

  /// Skip is equivalent to Log followed by SkipNow.
  fn Skip(self: Ref<F>, args: VarArgs<Unknown>)

  /// SkipNow marks the test as having been skipped and stops its execution
  /// by calling [runtime.Goexit].
  /// If a test fails (see Error, Errorf, Fail) and is then skipped,
  /// it is still considered to have failed.
  /// Execution will continue at the next test or benchmark. See also FailNow.
  /// SkipNow must be called from the goroutine running the test, not from
  /// other goroutines created during the test. Calling SkipNow does not stop
  /// those other goroutines.
  fn SkipNow(self: Ref<F>)

  /// Skipf is equivalent to Logf followed by SkipNow.
  fn Skipf(self: Ref<F>, format: string, args: VarArgs<Unknown>)

  /// Skipped reports whether the test was skipped.
  fn Skipped(self: Ref<F>) -> bool

  /// TempDir returns a temporary directory for the test to use.
  /// The directory is automatically removed when the test and
  /// all its subtests complete.
  /// Each subsequent call to TempDir returns a unique directory;
  /// if the directory creation fails, TempDir terminates the test by calling Fatal.
  fn TempDir(self: Ref<F>) -> string
}

impl M {
  /// Run runs the tests. It returns an exit code to pass to os.Exit.
  /// The exit code is zero when all tests pass, and non-zero for any kind
  /// of failure. For machine readable test results, parse the output of
  /// 'go test -json'.
  fn Run(self: Ref<M>) -> int
}

impl PB {
  /// Next reports whether there are more iterations to execute.
  fn Next(self: Ref<PB>) -> bool
}

impl T {
  /// Attr emits a test attribute associated with this test.
  /// 
  /// The key must not contain whitespace.
  /// The value must not contain newlines or carriage returns.
  /// 
  /// The meaning of different attribute keys is left up to
  /// continuous integration systems and test frameworks.
  /// 
  /// Test attributes are emitted immediately in the test log,
  /// but they are intended to be treated as unordered.
  fn Attr(self: Ref<T>, key: string, value: string)

  /// Chdir calls [os.Chdir] and uses Cleanup to restore the current
  /// working directory to its original value after the test. On Unix, it
  /// also sets PWD environment variable for the duration of the test.
  /// 
  /// Because Chdir affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Chdir(self: Ref<T>, dir: string)

  /// Cleanup registers a function to be called when the test (or subtest) and all its
  /// subtests complete. Cleanup functions will be called in last added,
  /// first called order.
  fn Cleanup(self: Ref<T>, f: fn() -> ())

  /// Context returns a context that is canceled just before
  /// Cleanup-registered functions are called.
  /// 
  /// Cleanup functions can wait for any resources
  /// that shut down on [context.Context.Done] before the test or benchmark completes.
  fn Context(self: Ref<T>) -> context.Context

  /// Deadline reports the time at which the test binary will have
  /// exceeded the timeout specified by the -timeout flag.
  /// 
  /// The ok result is false if the -timeout flag indicates “no timeout” (0).
  fn Deadline(self: Ref<T>) -> Option<time.Time>

  /// Error is equivalent to Log followed by Fail.
  fn Error(self: Ref<T>, args: VarArgs<Unknown>)

  /// Errorf is equivalent to Logf followed by Fail.
  fn Errorf(self: Ref<T>, format: string, args: VarArgs<Unknown>)

  /// Fail marks the function as having failed but continues execution.
  fn Fail(self: Ref<T>)

  /// FailNow marks the function as having failed and stops its execution
  /// by calling [runtime.Goexit] (which then runs all deferred calls in the
  /// current goroutine).
  /// Execution will continue at the next test or benchmark.
  /// FailNow must be called from the goroutine running the
  /// test or benchmark function, not from other goroutines
  /// created during the test. Calling FailNow does not stop
  /// those other goroutines.
  fn FailNow(self: Ref<T>)

  /// Failed reports whether the function has failed.
  fn Failed(self: Ref<T>) -> bool

  /// Fatal is equivalent to Log followed by FailNow.
  fn Fatal(self: Ref<T>, args: VarArgs<Unknown>)

  /// Fatalf is equivalent to Logf followed by FailNow.
  fn Fatalf(self: Ref<T>, format: string, args: VarArgs<Unknown>)

  /// Helper marks the calling function as a test helper function.
  /// When printing file and line information, that function will be skipped.
  /// Helper may be called simultaneously from multiple goroutines.
  fn Helper(self: Ref<T>)

  /// Log formats its arguments using default formatting, analogous to [fmt.Println],
  /// and records the text in the error log. For tests, the text will be printed only if
  /// the test fails or the -test.v flag is set. For benchmarks, the text is always
  /// printed to avoid having performance depend on the value of the -test.v flag.
  /// It is an error to call Log after a test or benchmark returns.
  fn Log(self: Ref<T>, args: VarArgs<Unknown>)

  /// Logf formats its arguments according to the format, analogous to [fmt.Printf], and
  /// records the text in the error log. A final newline is added if not provided. For
  /// tests, the text will be printed only if the test fails or the -test.v flag is
  /// set. For benchmarks, the text is always printed to avoid having performance
  /// depend on the value of the -test.v flag.
  /// It is an error to call Logf after a test or benchmark returns.
  fn Logf(self: Ref<T>, format: string, args: VarArgs<Unknown>)

  /// Name returns the name of the running (sub-) test or benchmark.
  /// 
  /// The name will include the name of the test along with the names of
  /// any nested sub-tests. If two sibling sub-tests have the same name,
  /// Name will append a suffix to guarantee the returned name is unique.
  fn Name(self: Ref<T>) -> string

  /// Output returns a Writer that writes to the same test output stream as TB.Log.
  /// The output is indented like TB.Log lines, but Output does not
  /// add source locations or newlines. The output is internally line
  /// buffered, and a call to TB.Log or the end of the test will implicitly
  /// flush the buffer, followed by a newline. After a test function and all its
  /// parents return, neither Output nor the Write method may be called.
  fn Output(self: Ref<T>) -> io.Writer

  /// Parallel signals that this test is to be run in parallel with (and only with)
  /// other parallel tests. When a test is run multiple times due to use of
  /// -test.count or -test.cpu, multiple instances of a single test never run in
  /// parallel with each other.
  fn Parallel(self: Ref<T>)

  /// Run runs f as a subtest of t called name. It runs f in a separate goroutine
  /// and blocks until f returns or calls t.Parallel to become a parallel test.
  /// Run reports whether f succeeded (or at least did not fail before calling t.Parallel).
  /// 
  /// Run may be called simultaneously from multiple goroutines, but all such calls
  /// must return before the outer test function for t returns.
  fn Run(self: Ref<T>, name: string, f: fn(Ref<T>) -> ()) -> bool

  /// Setenv calls os.Setenv(key, value) and uses Cleanup to
  /// restore the environment variable to its original value
  /// after the test.
  /// 
  /// Because Setenv affects the whole process, it cannot be used
  /// in parallel tests or tests with parallel ancestors.
  fn Setenv(self: Ref<T>, key: string, value: string)

  /// Skip is equivalent to Log followed by SkipNow.
  fn Skip(self: Ref<T>, args: VarArgs<Unknown>)

  /// SkipNow marks the test as having been skipped and stops its execution
  /// by calling [runtime.Goexit].
  /// If a test fails (see Error, Errorf, Fail) and is then skipped,
  /// it is still considered to have failed.
  /// Execution will continue at the next test or benchmark. See also FailNow.
  /// SkipNow must be called from the goroutine running the test, not from
  /// other goroutines created during the test. Calling SkipNow does not stop
  /// those other goroutines.
  fn SkipNow(self: Ref<T>)

  /// Skipf is equivalent to Logf followed by SkipNow.
  fn Skipf(self: Ref<T>, format: string, args: VarArgs<Unknown>)

  /// Skipped reports whether the test was skipped.
  fn Skipped(self: Ref<T>) -> bool

  /// TempDir returns a temporary directory for the test to use.
  /// The directory is automatically removed when the test and
  /// all its subtests complete.
  /// Each subsequent call to TempDir returns a unique directory;
  /// if the directory creation fails, TempDir terminates the test by calling Fatal.
  fn TempDir(self: Ref<T>) -> string
}