Skip to content

Fix decimal default parameters #1773

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

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add test for Decimal default parameter
  • Loading branch information
filmor committed Apr 26, 2022
commit 8329cdbe396d6cfa0061cedac2e6fa65744cd8c1
1 change: 1 addition & 0 deletions src/testing/Python.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AssemblyOriginatorKeyFile>..\pythonnet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<NoWarn>IDE0051;IDE0060</NoWarn>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\runtime\Python.Runtime.csproj" />
Expand Down
5 changes: 5 additions & 0 deletions src/testing/methodtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ public static int TestSingleDefaultParam(int i = 5)
return i;
}

public static decimal TestDecimalDefaultParam(decimal n = 1m)
{
return n;
}

public static int TestTwoDefaultParam(int i = 5, int j = 6)
{
return i + j;
Expand Down
6 changes: 6 additions & 0 deletions tests/test_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,12 @@ def test_single_default_param():
assert result == 5


def test_decimal_default_param():
"""Test that decimal default parameters work."""
result = MethodTest.TestDecimalDefaultParam()
assert result == System.Decimal(1)


def test_one_arg_and_two_default_param():
"""Test void method with single ref-parameter."""
result = MethodTest.TestOneArgAndTwoDefaultParam(11)
Expand Down