1 module tests.pass.attributes; 2 3 import unit_threaded; 4 5 enum myEnumNum = "foo.bar"; //there was a bug that made this not compile 6 enum myOtherEnumNum; 7 8 @UnitTest 9 void funcAttributes() { 10 //tests that using the @UnitTest UDA adds this function 11 //to the list of tests despite its name 12 1.shouldEqual(1); 13 } 14 15 //won't be tested due to attribute 16 @DontTest 17 void testThatWontRun() { 18 1.shouldEqual(2); //doesn't matter, won't run anyway 19 } 20 21 @DontTest 22 class TestThatWontRun: TestCase { 23 override void test() { 24 null.shouldNotBeNull; //doesn't matter, won't run anyway 25 } 26 } 27 28 @HiddenTest("Bug id #54321") 29 class MyHiddenTest: TestCase { 30 override void test() { 31 null.shouldNotBeNull; //hidden by default, fails if explicitly run 32 } 33 } 34 35 @HiddenTest 36 void testHidden() { 37 null.shouldNotBeNull; //hidden by default, fails if explicitly run 38 } 39 40 41 @ShouldFail("Bug id 12345") 42 void testShouldFail() { 43 3.shouldEqual(4); 44 } 45 46 47 @ShouldFail("Bug id 12345") 48 void testShouldFailWithOtherException() { 49 throw new Exception("This should not be seen"); 50 } 51 52 @Name("first_unit_test") 53 unittest { 54 writelnUt("First unit test block\n"); 55 assert(true); //unit test block that always passes 56 } 57 58 @Name("second_unit_test") 59 unittest { 60 writelnUt("Second unit test block\n"); 61 assert(true); //unit test block that always passes 62 } 63 64 @("third_unit_test") 65 unittest { 66 3.shouldEqual(3); 67 } 68 69 @ShouldFail 70 unittest { 71 3.shouldEqual(5); 72 } 73 74 @(42, 2) 75 void testValues(int i) { 76 (i % 2 == 0).shouldBeTrue; 77 }