-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Really always call finalisers for embedded fields
This fixes a case overlooked in 087ebc7. In that commit, the finaliser of an embedded field was only called if the parent object (or actor) had an explicit finaliser. This change adds implicit finalisers to objects that must finalise an embedded field, including recursively.
- Loading branch information
Benoit Vey
committed
Mar 3, 2017
1 parent
b7299f6
commit 501b27f
Showing
4 changed files
with
199 additions
and
26 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
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
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
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,106 @@ | ||
#include <gtest/gtest.h> | ||
#include <platform.h> | ||
|
||
#include "util.h" | ||
|
||
#define TEST_COMPILE(src) DO(test_compile(src, "ir")) | ||
|
||
|
||
class CodegenFinalTest : public PassTest | ||
{}; | ||
|
||
|
||
TEST_F(CodegenFinalTest, PrimitiveInit) | ||
{ | ||
const char* src = | ||
"primitive PrimitiveInit\n" | ||
" fun _init() =>\n" | ||
" @pony_exitcode[None](I32(1))\n" | ||
|
||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" None"; | ||
|
||
TEST_COMPILE(src); | ||
|
||
int exit_code = 0; | ||
ASSERT_TRUE(run_program(&exit_code)); | ||
ASSERT_EQ(exit_code, 1); | ||
} | ||
|
||
|
||
TEST_F(CodegenFinalTest, PrimitiveFinal) | ||
{ | ||
const char* src = | ||
"primitive PrimitiveFinal\n" | ||
" fun _final() =>\n" | ||
" @pony_exitcode[None](I32(1))\n" | ||
|
||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" None"; | ||
|
||
TEST_COMPILE(src); | ||
|
||
int exit_code = 0; | ||
ASSERT_TRUE(run_program(&exit_code)); | ||
ASSERT_EQ(exit_code, 1); | ||
} | ||
|
||
|
||
TEST_F(CodegenFinalTest, ClassFinal) | ||
{ | ||
const char* src = | ||
"class ClassFinal\n" | ||
" fun _final() =>\n" | ||
" @pony_exitcode[None](I32(1))\n" | ||
|
||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" ClassFinal"; | ||
|
||
TEST_COMPILE(src); | ||
|
||
int exit_code = 0; | ||
ASSERT_TRUE(run_program(&exit_code)); | ||
ASSERT_EQ(exit_code, 1); | ||
} | ||
|
||
|
||
TEST_F(CodegenFinalTest, EmbedFinal) | ||
{ | ||
const char* src = | ||
"class EmbedFinal\n" | ||
" fun _final() =>\n" | ||
" @pony_exitcode[None](I32(1))\n" | ||
|
||
"actor Main\n" | ||
" embed c: EmbedFinal = EmbedFinal\n" | ||
|
||
" new create(env: Env) =>\n" | ||
" None"; | ||
|
||
TEST_COMPILE(src); | ||
|
||
int exit_code = 0; | ||
ASSERT_TRUE(run_program(&exit_code)); | ||
ASSERT_EQ(exit_code, 1); | ||
} | ||
|
||
|
||
TEST_F(CodegenFinalTest, ActorFinal) | ||
{ | ||
const char* src = | ||
"actor Main\n" | ||
" new create(env: Env) =>\n" | ||
" None\n" | ||
|
||
" fun _final() =>\n" | ||
" @pony_exitcode[None](I32(1))"; | ||
|
||
TEST_COMPILE(src); | ||
|
||
int exit_code = 0; | ||
ASSERT_TRUE(run_program(&exit_code)); | ||
ASSERT_EQ(exit_code, 1); | ||
} |