Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some tests for class

  • Loading branch information...
commit 95760c032c43873ee6adddc8cb4666c49ab43aa5 1 parent 9cc45bc
NotFound authored
Showing with 85 additions and 1 deletion.
  1. +4 −1 Makefile
  2. +81 −0 t/base/03class.t
5 Makefile
View
@@ -109,7 +109,10 @@ winxedxc.pbc: winxedxc.pir
#-----------------------------------------------------------------------
-TESTS = t/base/00test.t t/base/02opadd.t t/base/02opmul.t t/base/03pmc.t t/base/features.t
+TESTS = t/base/00test.t \
+ t/base/02opadd.t t/base/02opmul.t \
+ t/base/03pmc.t t/base/03class.t \
+ t/base/features.t
test: winxedxx.pbc $(FRONTEND) winxedxx.h $(LIB)
prove -v -e "$(WINXED) t/runtests.winxed" $(TESTS)
81 t/base/03class.t
View
@@ -0,0 +1,81 @@
+#! winxed
+
+// winxedxx base tests
+// class
+
+using extern Test.More plan, is;
+
+class Foo
+{
+ var value;
+ function Foo(int i)
+ {
+ self.value = i;
+ }
+ function get()
+ {
+ if (self.value != null)
+ return self.value;
+ else
+ return 27;
+ }
+}
+
+namespace Bar
+{
+
+class FooBar
+{
+ var n;
+ function FooBar(int i)
+ {
+ self.n = i * 10;
+ }
+ function get()
+ {
+ int i;
+ if (self.n != null)
+ i = self.n;
+ else
+ i = 7;
+ return i;
+ }
+}
+
+class Parent { }
+
+class Foo : Parent
+{
+ function Foo()
+ {
+ }
+ function get()
+ {
+ return 3;
+ }
+}
+
+} // namespace Bar
+
+function main [main] (var args)
+{
+ plan(5);
+
+ var foo = new Foo(42);
+ int i = foo.get();
+ is(i, 42, "new simple with argument");
+ foo = new Foo;
+ i = foo.get();
+ is(i, 27, "new simple without constructor call");
+ foo = new Bar.FooBar(42);
+ i = foo.get();
+ is(i, 420, "new qualified new with argument");
+ foo = new Bar.FooBar;
+ i = foo.get();
+ is(i, 7, "new qualified without constructor call");
+ foo = new Bar.Foo();
+ i = foo.get();
+ is(i, 3, "class with same name in other namespace");
+}
+
+// End
Please sign in to comment.
Something went wrong with that request. Please try again.