-
Notifications
You must be signed in to change notification settings - Fork 200
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
C# enable the runtime numbers test #718
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dadf8ab
add c# runtime test for numbers
yowl 6f69b9e
Update .github/workflows/main.yml
yowl 8aa3196
Update .github/workflows/main.yml
yowl 3ea60b8
newline
yowl 74c56db
Merge branch 'csharp-runtime-numbers' of https://github.com/yowl/witx…
yowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Diagnostics; | ||
using wit_numbers.Wit.imports.test.numbers.Test; | ||
|
||
namespace wit_numbers; | ||
|
||
public class NumbersWorldImpl : NumbersWorld | ||
{ | ||
public static void TestImports() | ||
{ | ||
Debug.Assert(TestInterop.RoundtripU8(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripU8(0) == 0); | ||
Debug.Assert(TestInterop.RoundtripU8(Byte.MaxValue) == Byte.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripS8(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripS8(SByte.MinValue) == SByte.MinValue); | ||
Debug.Assert(TestInterop.RoundtripS8(SByte.MaxValue) == SByte.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripU16(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripU16(0) == 0); | ||
Debug.Assert(TestInterop.RoundtripU16(UInt16.MaxValue) == UInt16.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripS16(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripS16(Int16.MinValue) == Int16.MinValue); | ||
Debug.Assert(TestInterop.RoundtripS16(Int16.MaxValue) == Int16.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripU32(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripU32(0) == 0); | ||
Debug.Assert(TestInterop.RoundtripU32(UInt32.MaxValue) == UInt32.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripS32(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripS32(Int32.MinValue) == Int32.MinValue); | ||
Debug.Assert(TestInterop.RoundtripS32(Int32.MaxValue) == Int32.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripU64(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripU64(0) == 0); | ||
Debug.Assert(TestInterop.RoundtripU64(UInt64.MaxValue) == UInt64.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripS64(1) == 1); | ||
Debug.Assert(TestInterop.RoundtripS64(Int64.MinValue) == Int64.MinValue); | ||
Debug.Assert(TestInterop.RoundtripS64(Int64.MaxValue) == Int64.MaxValue); | ||
|
||
Debug.Assert(TestInterop.RoundtripFloat32(1.0f) == 1.0f); | ||
Debug.Assert(TestInterop.RoundtripFloat32(Single.PositiveInfinity) == Single.PositiveInfinity); | ||
Debug.Assert(TestInterop.RoundtripFloat32(Single.NegativeInfinity) == Single.NegativeInfinity); | ||
Debug.Assert(float.IsNaN(TestInterop.RoundtripFloat32(Single.NaN))); | ||
|
||
Debug.Assert(TestInterop.RoundtripFloat64(1.0) == 1.0); | ||
Debug.Assert(TestInterop.RoundtripFloat64(Double.PositiveInfinity) == Double.PositiveInfinity); | ||
Debug.Assert(TestInterop.RoundtripFloat64(Double.NegativeInfinity) == Double.NegativeInfinity); | ||
Debug.Assert(double.IsNaN(TestInterop.RoundtripFloat64(Double.NaN))); | ||
|
||
Debug.Assert(TestInterop.RoundtripChar('a') == 'a'); | ||
Debug.Assert(TestInterop.RoundtripChar(' ') == ' '); | ||
Debug.Assert(Char.ConvertFromUtf32((int)TestInterop.RoundtripChar((uint)Char.ConvertToUtf32("🚩", 0))) == "🚩"); // This is 2 chars long as it contains a surrogate pair | ||
|
||
TestInterop.SetScalar(2); | ||
Debug.Assert(TestInterop.GetScalar() == 2); | ||
TestInterop.SetScalar(4); | ||
Debug.Assert(TestInterop.GetScalar() == 4); | ||
} | ||
} | ||
|
||
public class TestImpl : wit_numbers.Wit.exports.test.numbers.Test.Test | ||
{ | ||
static uint SCALAR = 0; | ||
|
||
public static byte RoundtripU8(byte p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static sbyte RoundtripS8(sbyte p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static ushort RoundtripU16(ushort p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static short RoundtripS16(short p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static uint RoundtripU32(uint p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static int RoundtripS32(int p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static ulong RoundtripU64(ulong p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static long RoundtripS64(long p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static float RoundtripFloat32(float p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static double RoundtripFloat64(double p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static uint RoundtripChar(uint p0) | ||
{ | ||
return p0; | ||
} | ||
|
||
public static void SetScalar(uint p0) | ||
{ | ||
SCALAR = p0; | ||
} | ||
|
||
public static uint GetScalar() | ||
{ | ||
return SCALAR; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: When mono is added we will want to still add this for the linux case? Since we aren't running the tests on linux right now, is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is the yml matrix in
build.yml
tries to run all the OSes and if it creates the c# files then it will fail to compile them. Agree we will have to revisit this for Mono, not sure about MacOS, but for Linux we will want it.