Skip to content

Commit

Permalink
metamodel: added test for things that throw for ceylon/ceylon.languag…
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Sep 5, 2013
1 parent d189b10 commit 40746c4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Expand Up @@ -62,6 +62,14 @@ void checkConstructors(){
value privateClassType = `PrivateClass`;
value privateClassInstance = privateClassType();
assert(privateClassInstance.string == "d");

// constructor that throws
try {
`Throws`(true);
assert(false);
}catch(Exception x){
assert(x.cause is MyException);
}
}

void checkMemberAttributes(){
Expand Down Expand Up @@ -130,6 +138,21 @@ void checkMemberAttributes(){
obj2Bound.set(3);
assert(obj2Bound.get() == 3);
assert(noParamsInstance.obj2 == 3);

// getter that throws
Throws t = Throws(false);
try {
`Throws.getter`(t).get();
assert(false);
}catch(Exception x){
assert(x.cause is MyException);
}
try {
`Throws.getter`(t).set(1);
assert(false);
}catch(Exception x){
assert(x.cause is MyException);
}
}

void checkMemberFunctions(){
Expand Down Expand Up @@ -162,6 +185,16 @@ void checkMemberFunctions(){
assert(f7(noParamsInstance)() == 'a');
assert(exists f8 = noParamsType.getMethod<NoParams, Boolean, []>("getBoolean"));
assert(f8(noParamsInstance)() == true);

// method that throws
Throws t = Throws(false);
try {
`Throws.method`(t)();
assert(false);
}catch(Exception x){
assert(x.cause is MyException);
}

}

void checkMemberTypes(){
Expand Down
Expand Up @@ -236,3 +236,20 @@ shared abstract class Modifiers(){
shared formal Boolean method();
shared actual default String string = "yup";
}

shared class MyException() extends Exception("Hello!"){}

shared class Throws(Boolean t){
if(t){
throw MyException();
}
shared Integer getter {
throw MyException();
}
assign getter {
throw MyException();
}
shared Integer method() {
throw MyException();
}
}

0 comments on commit 40746c4

Please sign in to comment.