diff options
73 files changed, 664 insertions, 0 deletions
diff --git a/tests/exec/arith2.cpp b/tests/exec/arith2.cpp new file mode 100644 index 0000000..d75bb6b --- /dev/null +++ b/tests/exec/arith2.cpp @@ -0,0 +1,7 @@ +#include <iostream> + +int main() { + std::cout << (1 < 2 && 2 <= 3 || (1 + 3) == (4 + 0)) << "\n"; + std::cout << (2 > 1 && (2 >= 3 || 3 != 3) == ! (3 == 4)) << "\n"; + std::cout << (- 2 * - 5 == 2 && 1 == 2 && 0 == 0) << "\n"; +} diff --git a/tests/exec/arith2.out b/tests/exec/arith2.out new file mode 100644 index 0000000..e224937 --- /dev/null +++ b/tests/exec/arith2.out @@ -0,0 +1,3 @@ +1 +0 +0 diff --git a/tests/exec/arith3.cpp b/tests/exec/arith3.cpp new file mode 100644 index 0000000..1738cd7 --- /dev/null +++ b/tests/exec/arith3.cpp @@ -0,0 +1,12 @@ +#include <iostream> + +int main() { + int expr1 =- 7 + 6 * 5 - 4 / 3 - 2; // 20 + std::cout << expr1 << "\n"; + int expr2 = (7 + 6) * (5 - 4) / 3 - 2; // 2 + std::cout << expr2 << "\n"; + int expr3 = 7 + 6 * (5 - 4 / (3 - 2)); // 13 + std::cout << expr3 << "\n"; + int sum = expr1 % 8 + expr2 + expr3; // 19 + std::cout << sum << "\n"; +} diff --git a/tests/exec/arith3.out b/tests/exec/arith3.out new file mode 100644 index 0000000..f6bb4cd --- /dev/null +++ b/tests/exec/arith3.out @@ -0,0 +1,4 @@ +20 +2 +13 +19 diff --git a/tests/exec/bool.cpp b/tests/exec/bool.cpp new file mode 100644 index 0000000..1f42999 --- /dev/null +++ b/tests/exec/bool.cpp @@ -0,0 +1,6 @@ +#include <iostream> + +int main() { + std::cout << true << "\n"; + std::cout << false << "\n"; +} diff --git a/tests/exec/bool.out b/tests/exec/bool.out new file mode 100644 index 0000000..b261da1 --- /dev/null +++ b/tests/exec/bool.out @@ -0,0 +1,2 @@ +1 +0 diff --git a/tests/exec/bresenham.cpp b/tests/exec/bresenham.cpp new file mode 100644 index 0000000..c92c13f --- /dev/null +++ b/tests/exec/bresenham.cpp @@ -0,0 +1,26 @@ +#include <iostream> + +void plot(int y) { + while (y-- > 0) std::cout << " "; + std::cout << "X\n"; +} + +// suppose 0 <= y2 <= x2 (premier octant) +void bresenham(int x2, int y2) { + int x = 0; + int y = 0; + int e = 2 * y2 - x2; + for (x = 0; x <= x2; x++) { + plot (y); + if (e < 0) + e = e + 2* y2; + else { + y++; + e = e + 2 * (y2 - x2); + } + } +} + +int main() { + bresenham(10, 6); +} diff --git a/tests/exec/bresenham.out b/tests/exec/bresenham.out new file mode 100644 index 0000000..8809969 --- /dev/null +++ b/tests/exec/bresenham.out @@ -0,0 +1,11 @@ +X + X + X + X + X + X + X + X + X + X + X diff --git a/tests/exec/constructor1.cpp b/tests/exec/constructor1.cpp new file mode 100644 index 0000000..b5ed3e7 --- /dev/null +++ b/tests/exec/constructor1.cpp @@ -0,0 +1,16 @@ +#include <iostream> + +class A { +public: + int x; + int y; + A (int x, int y); +}; + +A::A(int x, int y) { this->x = x; this->y =y; } + +int main() { + A a = A(17, 42); + std::cout << a.x << "\n"; + std::cout << a.y << "\n"; +} diff --git a/tests/exec/constructor1.out b/tests/exec/constructor1.out new file mode 100644 index 0000000..c4a9d14 --- /dev/null +++ b/tests/exec/constructor1.out @@ -0,0 +1,2 @@ +17 +42 diff --git a/tests/exec/constructor2.cpp b/tests/exec/constructor2.cpp new file mode 100644 index 0000000..b23c02a --- /dev/null +++ b/tests/exec/constructor2.cpp @@ -0,0 +1,14 @@ +#include <iostream> + +class A { +public: + A(); +}; + +A::A() { + std::cout << "hello world\n"; +} + +int main() { + A a; +} diff --git a/tests/exec/constructor2.out b/tests/exec/constructor2.out new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/tests/exec/constructor2.out @@ -0,0 +1 @@ +hello world diff --git a/tests/exec/constructor3.cpp b/tests/exec/constructor3.cpp new file mode 100644 index 0000000..19b93b6 --- /dev/null +++ b/tests/exec/constructor3.cpp @@ -0,0 +1,15 @@ +#include <iostream> + +class A { +public: + A(); +}; + +A::A() { + std::cout << "hello world\n"; +} + +int main() { + A *a; + std::cout << "no hello world\n"; +} diff --git a/tests/exec/constructor3.out b/tests/exec/constructor3.out new file mode 100644 index 0000000..a333798 --- /dev/null +++ b/tests/exec/constructor3.out @@ -0,0 +1 @@ +no hello world diff --git a/tests/exec/constructor4.cpp b/tests/exec/constructor4.cpp new file mode 100644 index 0000000..221b807 --- /dev/null +++ b/tests/exec/constructor4.cpp @@ -0,0 +1,14 @@ +#include <iostream> + +class A { +public: + A(); +}; + +A::A() { + std::cout << "brand new world\n"; +} + +int main() { + A *a = new A(); +} diff --git a/tests/exec/constructor4.out b/tests/exec/constructor4.out new file mode 100644 index 0000000..86bead9 --- /dev/null +++ b/tests/exec/constructor4.out @@ -0,0 +1 @@ +brand new world diff --git a/tests/exec/fact_loop.cpp b/tests/exec/fact_loop.cpp new file mode 100644 index 0000000..da13f82 --- /dev/null +++ b/tests/exec/fact_loop.cpp @@ -0,0 +1,11 @@ +#include <iostream> + +int fact_loop(int n) { + int r = 1; + while (n > 1) r = r * n--; + return r; +} + +int main() { + std::cout << fact_loop(5) << "\n"; +} diff --git a/tests/exec/fact_loop.out b/tests/exec/fact_loop.out new file mode 100644 index 0000000..52bd8e4 --- /dev/null +++ b/tests/exec/fact_loop.out @@ -0,0 +1 @@ +120 diff --git a/tests/exec/fact_rec.cpp b/tests/exec/fact_rec.cpp new file mode 100644 index 0000000..98bc6d0 --- /dev/null +++ b/tests/exec/fact_rec.cpp @@ -0,0 +1,10 @@ +#include <iostream> + +int fact_rec(int n) { + if (n <= 1) return 1; + return n * fact_rec(n - 1); +} + +int main() { + std::cout << fact_rec(5) << "\n"; +} diff --git a/tests/exec/fact_rec.out b/tests/exec/fact_rec.out new file mode 100644 index 0000000..52bd8e4 --- /dev/null +++ b/tests/exec/fact_rec.out @@ -0,0 +1 @@ +120 diff --git a/tests/exec/fib_iter.cpp b/tests/exec/fib_iter.cpp new file mode 100644 index 0000000..9279927 --- /dev/null +++ b/tests/exec/fib_iter.cpp @@ -0,0 +1,21 @@ +#include <iostream> + +class fib { +public: + int prev, cur; + fib(); + int next(); +}; + +fib::fib() { + prev = 1; cur = 0; +} + +int fib::next() { int i = cur; cur = prev + cur; prev = i; return i; } + +int main() { + fib s; + int f; + while((f = s.next()) <= 100) + std::cout << f << "\n"; +} diff --git a/tests/exec/fib_iter.out b/tests/exec/fib_iter.out new file mode 100644 index 0000000..989b137 --- /dev/null +++ b/tests/exec/fib_iter.out @@ -0,0 +1,12 @@ +0 +1 +1 +2 +3 +5 +8 +13 +21 +34 +55 +89 diff --git a/tests/exec/field1.cpp b/tests/exec/field1.cpp new file mode 100644 index 0000000..09561e1 --- /dev/null +++ b/tests/exec/field1.cpp @@ -0,0 +1,22 @@ +#include <iostream> + +class A { +public: + int x; +}; + +class B : public A { +public: + int x; +}; + +int main() { + A *a = new A(); + a->x = 0; + std::cout << a->x << "\n"; + B *b = new B(); + b->x = 1; + std::cout << b->x << "\n"; + a = b; + std::cout << a->x << "\n"; +} diff --git a/tests/exec/field1.out b/tests/exec/field1.out new file mode 100644 index 0000000..7938dcd --- /dev/null +++ b/tests/exec/field1.out @@ -0,0 +1,3 @@ +0 +1 +0 diff --git a/tests/exec/hello.cpp b/tests/exec/hello.cpp new file mode 100644 index 0000000..5c9f8eb --- /dev/null +++ b/tests/exec/hello.cpp @@ -0,0 +1,5 @@ +#include <iostream> + +int main() { + std::cout << "hello world\n"; +} diff --git a/tests/exec/hello.out b/tests/exec/hello.out new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/tests/exec/hello.out @@ -0,0 +1 @@ +hello world diff --git a/tests/exec/ident1.cpp b/tests/exec/ident1.cpp new file mode 100644 index 0000000..8419bcc --- /dev/null +++ b/tests/exec/ident1.cpp @@ -0,0 +1,8 @@ +#include <iostream> + +int main() { + int ___________ = 1; + int ____1_____023__ = 0; + if (___________ && ____1_____023__ == 0) + std::cout << "non, tous les programmes n'affichent pas hello world\n"; +} diff --git a/tests/exec/ident1.out b/tests/exec/ident1.out new file mode 100644 index 0000000..a024662 --- /dev/null +++ b/tests/exec/ident1.out @@ -0,0 +1 @@ +non, tous les programmes n'affichent pas hello world diff --git a/tests/exec/if1.cpp b/tests/exec/if1.cpp new file mode 100644 index 0000000..67d32fb --- /dev/null +++ b/tests/exec/if1.cpp @@ -0,0 +1,13 @@ +#include <iostream> + +int main() { + if (1) + if (0) + ; + else { + if (1 == 2) + std::cout << (0/0); + else + std::cout << "hello world\n"; + } +} diff --git a/tests/exec/if1.out b/tests/exec/if1.out new file mode 100644 index 0000000..3b18e51 --- /dev/null +++ b/tests/exec/if1.out @@ -0,0 +1 @@ +hello world diff --git a/tests/exec/interval.cpp b/tests/exec/interval.cpp new file mode 100644 index 0000000..81661e3 --- /dev/null +++ b/tests/exec/interval.cpp @@ -0,0 +1,29 @@ +#include <iostream> + +class interval { +public: + int low, hi; + interval(int low, int hi); + void iterate(int& i); + int ok(int& i); + int next(int& i); +}; + +interval::interval(int low, int hi) { + this->low = low; + this->hi = hi; +} + +void interval::iterate(int& i) { i = low; } + +int interval::ok(int& i) { return i <= hi; } + +int interval::next(int& i) { return i++; } + +int main() { + interval s = interval(3, 10); + int i; + s.iterate(i); + while(s.ok(i)) + std::cout << s.next(i) << "\n"; +} diff --git a/tests/exec/interval.out b/tests/exec/interval.out new file mode 100644 index 0000000..aa6896c --- /dev/null +++ b/tests/exec/interval.out @@ -0,0 +1,8 @@ +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/tests/exec/lazy1.cpp b/tests/exec/lazy1.cpp new file mode 100644 index 0000000..7e36aa2 --- /dev/null +++ b/tests/exec/lazy1.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +int main() { + std::cout << (42 || (1/0)) << "\n"; + std::cout << (0 && (2/0)) << "\n"; + int *p = NULL; + if (1 || *p) + std::cout << "ok\n"; +} diff --git a/tests/exec/lazy1.out b/tests/exec/lazy1.out new file mode 100644 index 0000000..de4db88 --- /dev/null +++ b/tests/exec/lazy1.out @@ -0,0 +1,3 @@ +1 +0 +ok diff --git a/tests/exec/list.cpp b/tests/exec/list.cpp new file mode 100644 index 0000000..f1aadcb --- /dev/null +++ b/tests/exec/list.cpp @@ -0,0 +1,48 @@ +#include <iostream> + +// liste simplement chaînée + +class cell { +public: + int v; + cell *next; + cell(int v, cell* next); +}; + +cell::cell(int v, cell* next) { + this->v = v; + this->next = next; +} + +// liste chaînée de size éléments, avec accès à l'élément i (en temps O(i)) + +class list { +public: + cell *head; + list(int size); + int& get(int i); +}; + +list::list(int size) { + this->head = NULL; + while (size-- > 0) this->head = new cell(0, this->head); +} + +int& list::get(int i) { + cell *c = this->head; + while (i-- > 0) c = c->next; + return c->v; +} + +// on s'en sert comme un tableau pour calculer les premiers nombres +// de Fibonacci (en temps quadratique, donc) + +int main() { + list l = list(11); + l.get(1) = 1; + int i; + for (i = 2; i < 11; i++) { + l.get(i) = l.get(i-2) + l.get(i-1); + std::cout << "F(" << i << ") = " << l.get(i) << "\n"; + } +} diff --git a/tests/exec/list.out b/tests/exec/list.out new file mode 100644 index 0000000..125dd43 --- /dev/null +++ b/tests/exec/list.out @@ -0,0 +1,9 @@ +F(2) = 1 +F(3) = 2 +F(4) = 3 +F(5) = 5 +F(6) = 8 +F(7) = 13 +F(8) = 21 +F(9) = 34 +F(10) = 55 diff --git a/tests/exec/lvalue1.cpp b/tests/exec/lvalue1.cpp new file mode 100644 index 0000000..adef3b5 --- /dev/null +++ b/tests/exec/lvalue1.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +int main() { + int x; + int y; + int z; + x = y = z = 1; + std::cout << x << " " << y << " " << z << "\n"; +} diff --git a/tests/exec/lvalue1.out b/tests/exec/lvalue1.out new file mode 100644 index 0000000..cc37590 --- /dev/null +++ b/tests/exec/lvalue1.out @@ -0,0 +1 @@ +1 1 1 diff --git a/tests/exec/null.cpp b/tests/exec/null.cpp new file mode 100644 index 0000000..5eeb3cd --- /dev/null +++ b/tests/exec/null.cpp @@ -0,0 +1,12 @@ +#include <iostream> + +class A { public: }; + +int main() { + int *p = NULL; + std::cout << (p == NULL) << "\n"; + int x = 1; + std::cout << (&x == NULL) << "\n"; + A a; + std::cout << (&a == NULL) << "\n"; +} diff --git a/tests/exec/null.out b/tests/exec/null.out new file mode 100644 index 0000000..e224937 --- /dev/null +++ b/tests/exec/null.out @@ -0,0 +1,3 @@ +1 +0 +0 diff --git a/tests/exec/overload1.cpp b/tests/exec/overload1.cpp new file mode 100644 index 0000000..0fb8654 --- /dev/null +++ b/tests/exec/overload1.cpp @@ -0,0 +1,25 @@ +#include <iostream> + +class A { +public: + int a; + A(); + void set_a(); + void set_a(int a); +}; + +A::A() { } +void A::set_a() { a = 1; } +void A::set_a(int a) { this->a = a; } + +int main() { + A a; + int b; + a.set_a(); + b = a.a == 1; + a.set_a(2); + b = b && a.a == 2; + if (b) + std::cout << "ok\n"; +} + diff --git a/tests/exec/overload1.out b/tests/exec/overload1.out new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/tests/exec/overload1.out @@ -0,0 +1 @@ +ok diff --git a/tests/exec/overload2.cpp b/tests/exec/overload2.cpp new file mode 100644 index 0000000..d7ea8e8 --- /dev/null +++ b/tests/exec/overload2.cpp @@ -0,0 +1,16 @@ +#include <iostream> + +class A { +public: + int a; + A(); + A(int a_param); +}; + +A::A() { a = 1; } +A::A(int a_param) { a = a_param; } + +int main() { + if ((new A())->a == 1 && (new A(2))->a == 2) + std::cout << "ok\n"; +} diff --git a/tests/exec/overload2.out b/tests/exec/overload2.out new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/tests/exec/overload2.out @@ -0,0 +1 @@ +ok diff --git a/tests/exec/pow_loop.cpp b/tests/exec/pow_loop.cpp new file mode 100644 index 0000000..1af5861 --- /dev/null +++ b/tests/exec/pow_loop.cpp @@ -0,0 +1,23 @@ +#include <iostream> + +class Puiss { +public: + int pow(int a, int n); +}; + +int Puiss::pow(int a, int n) { + int r = 1; + int i; + for(i = 0; i < n / 2; i++) + r = r * a; + r = r * r; + if (n % 2 != 0) + r = r * a; + return r; +} + +int main() { + Puiss p; + std::cout << p.pow(2, 4) << "\n"; + std::cout << p.pow(6, 3) << "\n"; +} diff --git a/tests/exec/pow_loop.out b/tests/exec/pow_loop.out new file mode 100644 index 0000000..9326ad6 --- /dev/null +++ b/tests/exec/pow_loop.out @@ -0,0 +1,2 @@ +16 +216 diff --git a/tests/exec/pow_rec.cpp b/tests/exec/pow_rec.cpp new file mode 100644 index 0000000..5016246 --- /dev/null +++ b/tests/exec/pow_rec.cpp @@ -0,0 +1,22 @@ +#include <iostream> + +class Puiss { +public: + int pow(int a, int n); +}; + +int Puiss::pow(int a, int n) { + if (n <= 0) + return 1; + int r = pow(a, n / 2); + r = r * r; + if (n % 2 == 0) + return r; + return r * a; +} + +int main() { + Puiss p; + std::cout << p.pow(2, 4) << "\n"; + std::cout << p.pow(6, 3) << "\n"; +} diff --git a/tests/exec/pow_rec.out b/tests/exec/pow_rec.out new file mode 100644 index 0000000..9326ad6 --- /dev/null +++ b/tests/exec/pow_rec.out @@ -0,0 +1,2 @@ +16 +216 diff --git a/tests/exec/prepost2.cpp b/tests/exec/prepost2.cpp new file mode 100644 index 0000000..dcc0181 --- /dev/null +++ b/tests/exec/prepost2.cpp @@ -0,0 +1,11 @@ +#include <iostream> + +int main() { + int x = 41; + std::cout << "x = " << x << "\n"; + std::cout << "x = " << x++ << "\n"; + std::cout << "x = " << ++x << "\n"; + std::cout << "x = " << x-- << "\n"; + std::cout << "x = " << --x << "\n"; + std::cout << "x = " << x << "\n"; +} diff --git a/tests/exec/prepost2.out b/tests/exec/prepost2.out new file mode 100644 index 0000000..8459a5e --- /dev/null +++ b/tests/exec/prepost2.out @@ -0,0 +1,6 @@ +x = 41 +x = 41 +x = 43 +x = 43 +x = 41 +x = 41 diff --git a/tests/exec/redef1.cpp b/tests/exec/redef1.cpp new file mode 100644 index 0000000..4823765 --- /dev/null +++ b/tests/exec/redef1.cpp @@ -0,0 +1,24 @@ +#include <iostream> + +class A { +public: + virtual int f(int x); +}; + +int A::f(int x) { return x; } + +class B : public A { +public: + virtual int f(int x); +}; + +int B::f(int x) { return 2*x; } + +int main() { + A *a = new A(); + std::cout << a->f(1) << "\n"; + B *b = new B(); + std::cout << b->f(1) << "\n"; + a = b; + std::cout << a->f(1) << "\n"; // c'est B::f qui est appelée +} diff --git a/tests/exec/redef1.out b/tests/exec/redef1.out new file mode 100644 index 0000000..2ca3cd5 --- /dev/null +++ b/tests/exec/redef1.out @@ -0,0 +1,3 @@ +1 +2 +2 diff --git a/tests/exec/redef2.cpp b/tests/exec/redef2.cpp new file mode 100644 index 0000000..49b06e2 --- /dev/null +++ b/tests/exec/redef2.cpp @@ -0,0 +1,34 @@ +#include <iostream> + +class A { +public: + virtual int f(int x); +}; + +int A::f(int x) { return x; } + +class B : public A { +public: +}; + +class C : public B { +public: + virtual int f(int x); +}; + +int C::f(int x) { return 3*x; } + +int main() { + A *a = new A(); + std::cout << a->f(1) << "\n"; + B *b = new B(); + std::cout << b->f(1) << "\n"; + C *c = new C(); + std::cout << c->f(1) << "\n"; + a = b; + std::cout << a->f(1) << "\n"; + a = c; + std::cout << a->f(1) << "\n"; + b = c; + std::cout << b->f(1) << "\n"; +} diff --git a/tests/exec/redef2.out b/tests/exec/redef2.out new file mode 100644 index 0000000..016d2b9 --- /dev/null +++ b/tests/exec/redef2.out @@ -0,0 +1,6 @@ +1 +1 +3 +1 +3 +3 diff --git a/tests/exec/scope1.cpp b/tests/exec/scope1.cpp new file mode 100644 index 0000000..08cd575 --- /dev/null +++ b/tests/exec/scope1.cpp @@ -0,0 +1,22 @@ +#include <iostream> + +class A { +public: + int x; + int f(); + int g(int x); +}; + +int A::f() { int x = 0; x++; return x; } + +int A::g(int x) { x++; return x; } + +int main() { + A a; + a.x = 0; + std::cout << a.x << "\n"; + std::cout << a.f() << "\n"; + std::cout << a.x << "\n"; + std::cout << a.g(1) << "\n"; + std::cout << a.x << "\n"; +} diff --git a/tests/exec/scope1.out b/tests/exec/scope1.out new file mode 100644 index 0000000..0f67cef --- /dev/null +++ b/tests/exec/scope1.out @@ -0,0 +1,5 @@ +0 +1 +0 +2 +0 diff --git a/tests/exec/scope2.cpp b/tests/exec/scope2.cpp new file mode 100644 index 0000000..9b15638 --- /dev/null +++ b/tests/exec/scope2.cpp @@ -0,0 +1,14 @@ +#include <iostream> + +int main() { + int i = 42; + std::cout << i << "\n"; + if (1) { + int j = 1; + std::cout << j << "\n"; + } else { + int j = 2; + std::cout << j << "\n"; + } + std::cout << i << "\n"; +} diff --git a/tests/exec/scope2.out b/tests/exec/scope2.out new file mode 100644 index 0000000..9e43f08 --- /dev/null +++ b/tests/exec/scope2.out @@ -0,0 +1,3 @@ +42 +1 +42 diff --git a/tests/exec/while.cpp b/tests/exec/while.cpp new file mode 100644 index 0000000..d69002b --- /dev/null +++ b/tests/exec/while.cpp @@ -0,0 +1,17 @@ +#include <iostream> + +int main() { + int i = 0; + int cpt = 0; + for( ; i < 10; ) { + int j; + j = 10; + for ( ; j > 0; ) { + ++cpt; + --j; + } + i++; + } + if (cpt == 100) + std::cout << "ok\n"; +} diff --git a/tests/exec/while.out b/tests/exec/while.out new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/tests/exec/while.out @@ -0,0 +1 @@ +ok diff --git a/tests/syntax/good/testfile-lexer_hack-1.cpp b/tests/syntax/good/testfile-lexer_hack-1.cpp new file mode 100644 index 0000000..e21953b --- /dev/null +++ b/tests/syntax/good/testfile-lexer_hack-1.cpp @@ -0,0 +1,2 @@ +class +S { public: int a; }; diff --git a/tests/syntax/good/testfile-lexer_hack-2.cpp b/tests/syntax/good/testfile-lexer_hack-2.cpp new file mode 100644 index 0000000..c1c271a --- /dev/null +++ b/tests/syntax/good/testfile-lexer_hack-2.cpp @@ -0,0 +1,3 @@ + +class /* oups */ S { public: int a; }; + diff --git a/tests/typing/bad/testfile-constructor-1.cpp b/tests/typing/bad/testfile-constructor-1.cpp new file mode 100644 index 0000000..2f6a3ac --- /dev/null +++ b/tests/typing/bad/testfile-constructor-1.cpp @@ -0,0 +1,4 @@ +class A { public: }; +class B { public: A(); }; +int main() {} + diff --git a/tests/typing/bad/testfile-extra_qualification-1.cpp b/tests/typing/bad/testfile-extra_qualification-1.cpp new file mode 100644 index 0000000..35e4a56 --- /dev/null +++ b/tests/typing/bad/testfile-extra_qualification-1.cpp @@ -0,0 +1,6 @@ +class A { +public: + void A::f(); +}; +int main() {} + diff --git a/tests/typing/bad/testfile-incomplete_type-1.cpp b/tests/typing/bad/testfile-incomplete_type-1.cpp new file mode 100644 index 0000000..cb763ef --- /dev/null +++ b/tests/typing/bad/testfile-incomplete_type-1.cpp @@ -0,0 +1,3 @@ +class A { public: A a; }; +int main() {} + diff --git a/tests/typing/bad/testfile-overload-1.cpp b/tests/typing/bad/testfile-overload-1.cpp new file mode 100644 index 0000000..bee85bb --- /dev/null +++ b/tests/typing/bad/testfile-overload-1.cpp @@ -0,0 +1,7 @@ +class A { +public: + void A::f(); + void A::f(); +}; +int main() {} + diff --git a/tests/typing/bad/testfile-reference_type-1.cpp b/tests/typing/bad/testfile-reference_type-1.cpp new file mode 100644 index 0000000..a80e0af --- /dev/null +++ b/tests/typing/bad/testfile-reference_type-1.cpp @@ -0,0 +1,2 @@ +int& f() { return 0; } +int main() {} diff --git a/tests/typing/bad/testfile-reference_type-2.cpp b/tests/typing/bad/testfile-reference_type-2.cpp new file mode 100644 index 0000000..3356776 --- /dev/null +++ b/tests/typing/bad/testfile-reference_type-2.cpp @@ -0,0 +1,3 @@ + +int main() { int &y = 42; } + diff --git a/tests/typing/bad/testfile-subtyping-1.cpp b/tests/typing/bad/testfile-subtyping-1.cpp new file mode 100644 index 0000000..63fd309 --- /dev/null +++ b/tests/typing/bad/testfile-subtyping-1.cpp @@ -0,0 +1,5 @@ +class A { public: }; +class B : public A { public: }; + +int main() { B *x = new A(); } + diff --git a/tests/typing/bad/testfile-this-1.cpp b/tests/typing/bad/testfile-this-1.cpp new file mode 100644 index 0000000..abb3cb5 --- /dev/null +++ b/tests/typing/bad/testfile-this-1.cpp @@ -0,0 +1,3 @@ +void f() { std::cout << this << "\n"; } +int main() {} + diff --git a/tests/typing/good/testfile-not_incomplete_type-1.cpp b/tests/typing/good/testfile-not_incomplete_type-1.cpp new file mode 100644 index 0000000..de16671 --- /dev/null +++ b/tests/typing/good/testfile-not_incomplete_type-1.cpp @@ -0,0 +1,2 @@ +class A { public: A *a; }; +int main() {} diff --git a/tests/typing/good/testfile-subtype-2.cpp b/tests/typing/good/testfile-subtype-2.cpp new file mode 100644 index 0000000..d65ebc0 --- /dev/null +++ b/tests/typing/good/testfile-subtype-2.cpp @@ -0,0 +1,5 @@ + +#include <iostream> +class A { public: }; +int main() { A *x = NULL; } + diff --git a/tests/typing/good/testfile-subtype-3.cpp b/tests/typing/good/testfile-subtype-3.cpp new file mode 100644 index 0000000..e240ef6 --- /dev/null +++ b/tests/typing/good/testfile-subtype-3.cpp @@ -0,0 +1,5 @@ + +class A { public: }; +class B : public A { public: }; +int main() { A *x = new B(); } + |