1 // RUN: %llvmgcc -S %s -o - | FileCheck %s
2 // <rdar://problem/9402870>
3 typedef struct __TestResult TestResult;
4 typedef struct __TestResult* TestResultRef;
6 typedef struct __TestImplement TestImplement;
7 typedef struct __TestImplement* TestImplementRef;
9 typedef char*(*TestNameFunction)(void*);
10 typedef void(*TestRunFunction)(void*,TestResult*);
11 typedef int(*TestCountTestCasesFunction)(void*);
13 struct __TestImplement {
14 TestNameFunction name;
16 TestCountTestCasesFunction countTestCases;
19 typedef struct __Test Test;
20 typedef struct __Test* TestRef;
26 typedef struct __TestCase TestCase;
27 typedef struct __TestCase* TestCaseRef;
33 void(*tearDown)(void);
37 extern const TestImplement TestCaseImplement;
39 typedef struct __TestFixture TestFixture;
40 typedef struct __TestFixture* TestFixtureRef;
42 struct __TestFixture {
47 typedef struct __TestCaller TestCaller;
48 typedef struct __TestCaller* TestCallerRef;
54 void(*tearDown)(void);
56 TestFixture *fixtuers;
59 extern const TestImplement TestCallerImplement;
61 void PassToFunction(const TestImplement*);
63 const char* TestCaller_name(TestCaller* self) {
67 void TestCaller_run(TestCaller* self,TestResult* result) {
68 TestCase cs = { (TestImplement*)&TestCaseImplement, 0, 0, 0, 0, };
70 cs.setUp = self->setUp;
71 cs.tearDown = self->tearDown;
72 for (i=0; i<self->numberOfFixtuers; i++) {
73 cs.name = self->fixtuers[i].name;
74 cs.runTest = self->fixtuers[i].test;
75 ((Test*)(void *)&cs)->isa->run((void *)&cs,result);
79 int TestCaller_countTestCases(TestCaller* self) {
80 PassToFunction(&TestCallerImplement);
81 return self->numberOfFixtuers;
84 // CHECK: @C.0.1526 = internal unnamed_addr constant
85 // CHECK-NOT: @TestCaseImplement = external unnamed_addr constant %struct.TestImplement
86 // CHECK: @TestCaseImplement = external constant %struct.TestImplement
87 const TestImplement TestCallerImplement = {
88 (TestNameFunction)TestCaller_name,
89 (TestRunFunction)TestCaller_run,
90 (TestCountTestCasesFunction)TestCaller_countTestCases,