This repository has been archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2262ade
commit bbed2fd
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters