Skip to content

Commit

Permalink
add unit test 01-Basic/253-scope-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Jun 21, 2024
1 parent c56efce commit 90f966c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/test/01-Basic/253-scope-cleanup.ck
Original file line number Diff line number Diff line change
@@ -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, "" >>>;
9 changes: 9 additions & 0 deletions src/test/01-Basic/253-scope-cleanup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
1
2
destructor: -2
3
destructor: -1
4
5
destructor: 0
6

0 comments on commit 90f966c

Please sign in to comment.