Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Issue #3544: language module test
Browse files Browse the repository at this point in the history
  • Loading branch information
tombentley committed Jan 24, 2017
1 parent 2262ade commit bbed2fd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions language/test/memoized.ceylon
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class Memoized() {
variable value i = 0;
shared late Integer memoized = ++i;
}
variable Integer memoized_i = 0;
shared late Integer memoized_1 = ++memoized_i;
shared late Integer memoized_2 = ++memoized_i;

@test
shared void memoized() {
variable value m = Memoized();
check(1 == m.memoized);
check(1 == m.memoized);
try {
m.memoized = -100;
throw;
} catch (InitializationError e) {}

m = Memoized();
m.memoized = -100;
check(-100 == m.memoized);
check(-100 == m.memoized);
try {
m.memoized = -200;
throw;
} catch (InitializationError e) {}

check(1 == memoized_1);
check(1 == memoized_1);
try {
memoized_1 = -100;
throw;
} catch (InitializationError e) {}

memoized_2 = -100;
check(-100 == memoized_2);
check(-100 == memoized_2);
try {
memoized_2 = -200;
throw;
} catch (InitializationError e) {}
}
2 changes: 2 additions & 0 deletions language/test/run.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void runTests() {
characters();
print("Strings");
strings();
print("Memoized");
memoized();
print("Lists");
lists();
print("Sequences");
Expand Down

0 comments on commit bbed2fd

Please sign in to comment.