main.mx raw

   1  // testing.T.Fatal/Skip must abort the rest of the test body, and the run must
   2  // continue with the next test.
   3  //
   4  // Two stage4 defects met here. First, stage4 never emitted the per-call defer
   5  // checkpoint: call lines are written in fragments ("  " then "call ..."), and
   6  // the w() sniffer keyed on a whole-line prefix, so every frame's JumpPC stayed
   7  // 0 and a moxie_longjmp jumped to 0. Second, explicit panic("const") was
   8  // lowered to the abort-only runtime._panicstr while legacy used the
   9  // recoverable runtime._panic. The recover handler is a plain function so the
  10  // deferred call needs no method thunk.
  11  package main
  12  
  13  import "testing"
  14  
  15  func TestStopsAtFatal(t *testing.T) {
  16  	t.Fatal("fatal worked")
  17  	t.Error("unreachable after Fatal")
  18  }
  19  
  20  func TestStillRuns(t *testing.T) {
  21  	println("second-ran")
  22  }
  23  
  24  func TestStopsAtSkip(t *testing.T) {
  25  	t.Skip("skip worked")
  26  	t.Error("unreachable after Skip")
  27  }
  28  
  29  func main() {
  30  	testing.Main([]testing.InternalTest{
  31  		{Name: "TestStopsAtFatal", F: TestStopsAtFatal},
  32  		{Name: "TestStillRuns", F: TestStillRuns},
  33  		{Name: "TestStopsAtSkip", F: TestStopsAtSkip},
  34  	})
  35  }
  36