diff --git a/src/test/01-Basic/253-scope-cleanup.ck b/src/test/01-Basic/253-scope-cleanup.ck new file mode 100644 index 000000000..3ce41a1e3 --- /dev/null +++ b/src/test/01-Basic/253-scope-cleanup.ck @@ -0,0 +1,41 @@ +// (non-control structure) local scope Object cleanup +// 1.5.2.5 (ge) added + +// a class +class Foo +{ + int val; + + fun @construct( int x ) + { x => val; } + + fun @destruct() + { <<< "destructor:", val >>>; } +} + +// control structure scope +if( true ) +{ + // nested scope + { + Foo foo(-1); + <<< 1, "" >>>; + + // nested nested scope + { + Foo bar(-2); + <<< 2, "" >>>; + } + <<< 3, "" >>>; + + } + <<< 4, "" >>>; + +} +<<< 5, "" >>>; + +// top-level scope +{ + Foo foo(0); +} +<<< 6, "" >>>; diff --git a/src/test/01-Basic/253-scope-cleanup.txt b/src/test/01-Basic/253-scope-cleanup.txt new file mode 100644 index 000000000..784c13e65 --- /dev/null +++ b/src/test/01-Basic/253-scope-cleanup.txt @@ -0,0 +1,9 @@ +1 +2 +destructor: -2 +3 +destructor: -1 +4 +5 +destructor: 0 +6