Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(tests) Add full type coverage for % operator #324

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions release-notes/v0.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Add full type coverage for `<` and `<=` operators [[#321][321]]
- Add full type coverage for `>` and `>=` operators [[#322][322]]
- Add full type coverage for `**` operator [[#323][323]]
- Add full type coverage for `%` operator [[#324][324]]

[300]: https://github.com/perlang-org/perlang/pull/300
[302]: https://github.com/perlang-org/perlang/issues/302
Expand All @@ -30,3 +31,4 @@
[321]: https://github.com/perlang-org/perlang/pull/321
[322]: https://github.com/perlang-org/perlang/pull/322
[323]: https://github.com/perlang-org/perlang/pull/323
[324]: https://github.com/perlang-org/perlang/pull/324
Original file line number Diff line number Diff line change
Expand Up @@ -790,14 +790,20 @@ public static class BinaryOperatorData
new List<object[]>
{
new object[] { "5", "3", "2" },
new object[] { "2", "18446744073709551616", "2" },
new object[] { "9", "2.0", "1" },
new object[] { "9.0", "2.0", "1" },
new object[] { "2147483647", "2", "1" },
new object[] { "-2147483648", "2", "0" },
new object[] { "18446744073709551616", "3", "1" }
new object[] { "9223372036854775807", "9223372036854775807", "0" },
new object[] { "9223372036854775807", "18446744073709551616", "9223372036854775807" },
new object[] { "9223372036854775807", "12.0", "8" }, // TODO: We should consider making this unsupported, since it may cause loss of precision.
new object[] { "18446744073709551616", "3", "1" },
new object[] { "18446744073709551616", "9223372036854775807", "2" },
new object[] { "18446744073709551616", "18446744073709551616", "0" }
};

public static IEnumerable<object[]> Percent_type =>
public static IEnumerable<object[]> Modulo_type =>
new List<object[]>
{
new object[] { "5", "3", "System.Int32" },
Expand All @@ -811,10 +817,32 @@ public static class BinaryOperatorData
public static IEnumerable<object[]> Modulo_unsupported_types =>
new List<object[]>
{
new object[] { "9.0", "2", "Operands must be numbers, not double and int" },
new object[] { "2", "4294967295", "Operands must be numbers, not int and System.UInt32" },
new object[] { "2", "9223372036854775807", "Operands must be numbers, not int and long" },
new object[] { "2", "18446744073709551615", "Operands must be numbers, not int and System.UInt64" },
new object[] { "4294967295", "2", "Operands must be numbers, not System.UInt32 and int" },
new object[] { "4294967295", "4294967295", "Operands must be numbers, not System.UInt32 and System.UInt32" },
new object[] { "4294967295", "9223372036854775807", "Operands must be numbers, not System.UInt32 and long" },
new object[] { "4294967295", "18446744073709551615", "Operands must be numbers, not System.UInt32 and System.UInt64" },
new object[] { "4294967295", "18446744073709551616", "Operands must be numbers, not System.UInt32 and bigint" },
new object[] { "4294967295", "12.0", "Operands must be numbers, not System.UInt32 and double" },
new object[] { "9223372036854775807", "2", "Operands must be numbers, not long and int" },
new object[] { "9223372036854775807", "4294967295", "Operands must be numbers, not long and System.UInt32" },
new object[] { "9223372036854775807", "18446744073709551615", "Operands must be numbers, not long and System.UInt64" },
new object[] { "18446744073709551615", "2", "Operands must be numbers, not System.UInt64 and int" },
new object[] { "18446744073709551615", "4294967295", "Operands must be numbers, not System.UInt64 and System.UInt32" },
new object[] { "18446744073709551615", "9223372036854775807", "Operands must be numbers, not System.UInt64 and long" },
new object[] { "18446744073709551615", "18446744073709551615", "Operands must be numbers, not System.UInt64 and System.UInt64" },
new object[] { "18446744073709551615", "18446744073709551616", "Operands must be numbers, not System.UInt64 and bigint" },
new object[] { "18446744073709551615", "12.0", "Operands must be numbers, not System.UInt64 and double" },
new object[] { "18446744073709551616", "4294967295", "Operands must be numbers, not bigint and System.UInt32" },
new object[] { "18446744073709551616", "18446744073709551615", "Operands must be numbers, not bigint and System.UInt64" },
new object[] { "18446744073709551616", "12.0", "Operands must be numbers, not bigint and double" },
new object[] { "9.0", "2", "Operands must be numbers, not double and int" },
new object[] { "-12.0", "4294967295", "Operands must be numbers, not double and System.UInt32" },
new object[] { "-12.0", "9223372036854775807", "Operands must be numbers, not double and long" },
new object[] { "-12.0", "18446744073709551615", "Operands must be numbers, not double and System.UInt64" },
new object[] { "-12.0", "18446744073709551616", "Operands must be numbers, not double and bigint" },
};

public static IEnumerable<object[]> ShiftLeft_result =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void returns_remainder_of_division(string i, string j, string expectedRes
}

[Theory]
[MemberData(nameof(BinaryOperatorData.Percent_type), MemberType = typeof(BinaryOperatorData))]
[MemberData(nameof(BinaryOperatorData.Modulo_type), MemberType = typeof(BinaryOperatorData))]
public void with_supported_types_returns_expected_type(string i, string j, string expectedResult)
{
string source = $@"
Expand Down