Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen committed Jan 18, 2025
1 parent 4adfbef commit 9749420
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/libponyc/badpony.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,9 +1306,42 @@ TEST_F(BadPonyTest, NotSafeToWrite)
const char* errs[] =
{"not safe to write right side to left side", NULL};
const char* frame1[] = {
"right side type: Foo ref^",
"right side type: Foo ref^",
"left side type: X iso", NULL};
const char** frames[] = {frame1, NULL};
DO(test_expected_error_frames(src, "badpony", errs, frames));
}
}

TEST_F(BadPonyTest, MatchIsoFieldWithoutConsume)
{
// From issue #4579
const char* src =
"class Bad\n"
" var _s: String iso\n"

" new iso create(s: String iso) =>\n"
" _s = consume s\n"

" fun ref take(): String iso^ =>\n"
" match _s\n"
" | let s': String iso => consume s'\n"
" end";

TEST_ERRORS_1(src, "this capture violates capabilities");
}

TEST_F(BadPonyTest, MatchIsoLetWithoutConsume)
{
// From issue #4579
const char* src =
"class Bad\n"
" fun bad() =>\n"
" let a: String iso = recover iso String end\n"

" match a\n"
" | let a': String => None\n"
" end";

TEST_ERRORS_1(src, "this capture violates capabilities");
}

0 comments on commit 9749420

Please sign in to comment.