Skip to content

Commit

Permalink
(tests) Rewrite DictionaryIndexing tests to use raw strings
Browse files Browse the repository at this point in the history
...and fixed the indentation of raw strings in existing tests where they
were indented one step to much.

https://gitlab.perlang.org/perlang/perlang/-/merge_requests/549
  • Loading branch information
perlun committed Nov 5, 2024
1 parent eb91fc7 commit 3c43138
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 142 deletions.
2 changes: 2 additions & 0 deletions release-notes/v0.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- Use `string[] arguments` parameter in `EvalHelper` [[!541][541]]
- Include test method name in generated `.per`/`.cc` files [[!542][542]]
- Rewrite `cctest`-based tests with Catch2 [[!543][543]]
- Rewrite `DictionaryIndexing` tests to use raw strings [[!549][549]]

### Docs and Website
- stdlib: Fix `github.com` blob/file references [[!500][500]]
Expand Down Expand Up @@ -133,6 +134,7 @@
[546]: https://gitlab.perlang.org/perlang/perlang/merge_requests/546
[547]: https://gitlab.perlang.org/perlang/perlang/merge_requests/547
[548]: https://gitlab.perlang.org/perlang/perlang/merge_requests/548
[549]: https://gitlab.perlang.org/perlang/perlang/merge_requests/549
[550]: https://gitlab.perlang.org/perlang/perlang/merge_requests/550
[551]: https://gitlab.perlang.org/perlang/perlang/merge_requests/551
[552]: https://gitlab.perlang.org/perlang/perlang/merge_requests/552
Expand Down
34 changes: 17 additions & 17 deletions src/Perlang.Tests.Integration/Arrays/IntArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class IntArrayTests
public void explicitly_typed_int_array_can_be_indexed()
{
string source = """
var a: int[] = [1, 2, 3];
var a: int[] = [1, 2, 3];

print a[0];
print a[1];
print a[2];
""";
print a[0];
print a[1];
print a[2];
""";

var output = EvalReturningOutput(source);

Expand All @@ -31,12 +31,12 @@ public void explicitly_typed_int_array_can_be_indexed()
public void implicitly_typed_int_array_can_be_indexed()
{
string source = """
var a = [1, 2, 3];
var a = [1, 2, 3];

print a[0];
print a[1];
print a[2];
""";
print a[0];
print a[1];
print a[2];
""";

var output = EvalReturningOutput(source);

Expand All @@ -52,10 +52,10 @@ public void implicitly_typed_int_array_can_be_indexed()
public void indexing_int_array_with_negative_index_produces_expected_error()
{
string source = """
var a = [1, 2, 3];
var a = [1, 2, 3];

print a[-1];
""";
print a[-1];
""";

var result = EvalWithRuntimeErrorCatch(source);

Expand All @@ -72,11 +72,11 @@ public void indexing_int_array_with_negative_index_produces_expected_error()
public void indexing_int_array_outside_of_boundaries_produces_expected_error()
{
string source = """
var a = [1, 2, 3];
var a = [1, 2, 3];

// a[2] is the last element of the array
print a[3];
""";
// a[2] is the last element of the array
print a[3];
""";

var result = EvalWithRuntimeErrorCatch(source);

Expand Down
56 changes: 28 additions & 28 deletions src/Perlang.Tests.Integration/Arrays/StringArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ public class StringArrayTests
public void string_array_with_ascii_content_can_be_indexed()
{
string source = """
var a: string[] = ["a", "b", "c"];
var a: string[] = ["a", "b", "c"];

print a[0];
print a[1];
print a[2];
""";
print a[0];
print a[1];
print a[2];
""";

var output = EvalReturningOutput(source);

Expand All @@ -31,13 +31,13 @@ public void string_array_with_ascii_content_can_be_indexed()
public void string_array_with_utf8_content_can_be_indexed()
{
string source = """
var a: string[] = ["å", "ä", "ö", "ü", "ÿ", "Ÿ", "す", "し"];
var a: string[] = ["å", "ä", "ö", "ü", "ÿ", "Ÿ", "す", "し"];

print a[0];
print a[1];
print a[2];
print a[7];
""";
print a[0];
print a[1];
print a[2];
print a[7];
""";

var output = EvalReturningOutput(source);

Expand All @@ -54,12 +54,12 @@ public void string_array_with_utf8_content_can_be_indexed()
public void implicitly_typed_string_array_with_ascii_content_can_be_indexed()
{
string source = """
var a = ["a", "b", "c"];
var a = ["a", "b", "c"];

print a[0];
print a[1];
print a[2];
""";
print a[0];
print a[1];
print a[2];
""";

var output = EvalReturningOutput(source);

Expand All @@ -75,13 +75,13 @@ public void implicitly_typed_string_array_with_ascii_content_can_be_indexed()
public void implicitly_typed_string_array_with_utf8_content_can_be_indexed()
{
string source = """
var a = ["å", "ä", "ö", "ü", "ÿ", "Ÿ", "す", "し"];
var a = ["å", "ä", "ö", "ü", "ÿ", "Ÿ", "す", "し"];

print a[0];
print a[1];
print a[2];
print a[7];
""";
print a[0];
print a[1];
print a[2];
print a[7];
""";

var output = EvalReturningOutput(source);

Expand All @@ -98,10 +98,10 @@ public void implicitly_typed_string_array_with_utf8_content_can_be_indexed()
public void string_array_length_property_returns_expected_value()
{
string source = """
var a: string[] = ["a", "b", "c"];
var a: string[] = ["a", "b", "c"];

print a.length;
""";
print a.length;
""";

var output = EvalReturningOutput(source);

Expand All @@ -115,10 +115,10 @@ public void string_array_length_property_returns_expected_value()
public void string_array_nonexistent_property_raises_expected_error()
{
string source = """
var a: string[] = ["a", "b", "c"];
var a: string[] = ["a", "b", "c"];

print a.non_existent_property;
""";
print a.non_existent_property;
""";

var result = EvalWithValidationErrorCatch(source);

Expand Down
24 changes: 12 additions & 12 deletions src/Perlang.Tests.Integration/IndexOperator/DictionaryIndexing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public class DictionaryIndexing
[SkippableFact]
public void dictionary_with_string_key_can_be_indexed_by_string()
{
string source = @$"
string source = $"""
var env = Libc.environ();
print env[""{PathKey}""];
";
print env["{PathKey}"];
""";

var output = EvalReturningOutputString(source);

Expand All @@ -35,10 +35,10 @@ public void dictionary_with_string_key_can_be_indexed_by_string()
[SkippableFact]
public void dictionary_with_string_key_can_be_indexed_multiple_times()
{
string source = @$"
string source = $"""
var env = Libc.environ();
print env[""{PathKey}""][0];
";
print env["{PathKey}"][0];
""";

var output = EvalReturningOutputString(source);

Expand All @@ -56,10 +56,10 @@ public void dictionary_with_string_key_throws_expected_error_when_indexed_by_not
{
Skip.If(PerlangMode.ExperimentalCompilation, "Not supported in compiled mode");

string source = @"
string source = """
var env = Libc.environ();
print env[""NOT_PRESENT_DICTIONARY_KEY""];
";
""";

var result = EvalWithRuntimeErrorCatch(source);

Expand All @@ -73,10 +73,10 @@ public void dictionary_with_string_key_throws_expected_error_when_indexed_by_not
[Fact]
public void dictionary_with_string_key_throws_expected_error_when_indexed_by_null()
{
string source = @"
string source = """
var env = Libc.environ();
print env[null];
";
""";

var result = EvalWithValidationErrorCatch(source);

Expand All @@ -88,10 +88,10 @@ public void dictionary_with_string_key_throws_expected_error_when_indexed_by_nul
[Fact]
public void dictionary_with_string_key_throws_expected_error_when_indexed_by_integer()
{
string source = @"
string source = """
var env = Libc.environ();
print env[123];
";
""";

var result = EvalWithValidationErrorCatch(source);

Expand Down
Loading

0 comments on commit 3c43138

Please sign in to comment.