| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + using System; | ||
| 2 | + | ||
| 3 | + namespace Python.Test | ||
| 4 | + { | ||
| 5 | + public class BaseClass | ||
| 6 | + { | ||
| 7 | + public bool IsBase() => true; | ||
| 8 | + } | ||
| 9 | + | ||
| 10 | + public class DerivedClass : BaseClass | ||
| 11 | + { | ||
| 12 | + public new bool IsBase() => false; | ||
| 13 | + } | ||
| 14 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - <?xml version="1.0" encoding="utf-8"?> | ||
| 1 | + <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | 2 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | |
| 3 | 3 | <PropertyGroup> | |
| 4 | 4 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |
@@ -83,6 +83,7 @@ | |||
| 83 | 83 | <Compile Include="generictest.cs" /> | |
| 84 | 84 | <Compile Include="globaltest.cs" /> | |
| 85 | 85 | <Compile Include="indexertest.cs" /> | |
| 86 | + <Compile Include="InheritanceTest.cs" /> | ||
| 86 | 87 | <Compile Include="interfacetest.cs" /> | |
| 87 | 88 | <Compile Include="methodtest.cs" /> | |
| 88 | 89 | <Compile Include="moduletest.cs" /> | |
@@ -110,4 +111,4 @@ | |||
| 110 | 111 | <Copy SourceFiles="$(TargetAssembly)" DestinationFolder="$(SolutionDir)\src\tests\fixtures" /> | |
| 111 | 112 | <!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /--> | |
| 112 | 113 | </Target> | |
| 113 | - </Project> | ||
| 114 | + </Project> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -281,3 +281,14 @@ def PyCallback(self, self2): | |||
| 281 | 281 | testobj.DoCallback() | |
| 282 | 282 | assert testobj.PyCallbackWasCalled | |
| 283 | 283 | assert testobj.SameReference | |
| 284 | + | ||
| 285 | + | ||
| 286 | + def test_method_inheritance(): | ||
| 287 | + """Ensure that we call the overridden method instead of the one provided in | ||
| 288 | + the base class.""" | ||
| 289 | + | ||
| 290 | + base = Test.BaseClass() | ||
| 291 | + derived = Test.DerivedClass() | ||
| 292 | + | ||
| 293 | + assert base.IsBase() == True | ||
| 294 | + assert derived.IsBase() == False | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments