Skip to content

Commit

Permalink
testing for member class/initializer annotations
Browse files Browse the repository at this point in the history
Part of #750
  • Loading branch information
tombentley committed Oct 9, 2015
1 parent 339395f commit 7877883
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions test/metamodel/bug750.ceylon
Expand Up @@ -117,11 +117,18 @@ class Bug750Outer() {
class Bug750NoDefault<T> {
shared new other(String s) {}
}

"doc"
shared
throws(`class Exception`, "Always")
deprecated()
class Bug750Anno() {
throw Exception();
}
shared void bug750() {
ClassWithInitializerDeclaration bug750Init = `class Bug750Init`;
ClassWithConstructorsDeclaration bug750Ctors= `class Bug750Ctors`;
ClassWithConstructorsDeclaration bug750NoDefault= `class Bug750NoDefault`;
ClassWithInitializerDeclaration bug750Anno = `class Bug750Anno`;
CallableConstructorDeclaration ctor = `new Bug750Ctors`;
CallableConstructorDeclaration init = bug750Init.defaultConstructor;

Expand Down Expand Up @@ -153,13 +160,16 @@ class Bug750Outer() {
assert(!init.formal);
assert(init.shared);
assert(!init.toplevel);
// XXX What are the semantics fo this? In Ceylon-land a ClassWithInitiaizer
// I guess it should return all those annotations which are permitted on a constructor?
//assert(!init.annotated<SharedAnnotation>());
//assert(init.annotated<DocAnnotation>());
//assert(!init.annotated<FormalAnnotation>());
//assert(init.annotations<SharedAnnotation>().empty);
//assert(!init.annotations<DocAnnotation>().empty);
//annotations
value annos = bug750Anno.constructorDeclarations();
assert(annos == bug750Anno.annotatedConstructorDeclarations<SharedAnnotation>());
assert(annos == bug750Anno.annotatedConstructorDeclarations<DeprecationAnnotation>());
assert(annos == bug750Anno.annotatedConstructorDeclarations<ThrownExceptionAnnotation>());
assert(bug750Anno.annotatedConstructorDeclarations<DocAnnotation>().empty);
assert(bug750Anno.defaultConstructor.annotated<SharedAnnotation>());
assert(bug750Anno.defaultConstructor.annotated<DeprecationAnnotation>());
assert(bug750Anno.defaultConstructor.annotated<ThrownExceptionAnnotation>());
assert(!bug750Anno.defaultConstructor.annotated<DocAnnotation>());

// apply
try {
Expand All @@ -173,7 +183,7 @@ class Bug750Outer() {
assert(bug750Init == init.container);

// invoke
assert(is Bug750Init<String> inst= init.memberInvoke(this, [`String`], ""));
// TODO assert(is Bug750Init<String> inst= init.memberInvoke(this, [`String`], ""));
try {
init.invoke([`String`], "");
assert(false);
Expand Down

0 comments on commit 7877883

Please sign in to comment.