diff options
author | Jeremy Koritzinsky <jkoritzinsky@gmail.com> | 2017-10-15 07:12:29 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2017-10-15 07:12:29 +0300 |
commit | 18f3c7773c6aebab639311481cad6ebf550bdead (patch) | |
tree | 20b66915c9786df7ba66c1207198bd49876edb08 /tests | |
parent | ea81a1844f860d5b0548be2c4163c7216670c3bd (diff) |
Implement Shift Opcodes for WebAssembly (#4721)
* Implement shift opcodes
* Fix HelloWasm test.
* FIx HelloWasm test program.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/Simple/HelloWasm/Program.cs | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/tests/src/Simple/HelloWasm/Program.cs b/tests/src/Simple/HelloWasm/Program.cs index 4c3015816..57eb439ef 100644 --- a/tests/src/Simple/HelloWasm/Program.cs +++ b/tests/src/Simple/HelloWasm/Program.cs @@ -10,13 +10,14 @@ internal static class Program private static unsafe void Main(string[] args) { Add(1, 2); - int tempInt = 0; - (*(&tempInt)) = 9; - - TwoByteStr str = new TwoByteStr() { first = 1, second = 2 }; - TwoByteStr str2 = new TwoByteStr() { first = 3, second = 4 };; - *(&str) = str2; - str2 = *(&str); + + int tempInt = 0; + (*(&tempInt)) = 9; + + TwoByteStr str = new TwoByteStr() { first = 1, second = 2 }; + TwoByteStr str2 = new TwoByteStr() { first = 3, second = 4 };; + *(&str) = str2; + str2 = *(&str); if(tempInt == 9) { @@ -37,6 +38,26 @@ internal static class Program PrintString("\n", 1); PrintString("negInt test: Ok.", 16); } + + var shiftLeft = ShiftLeft(1, 2) == 4; + if(shiftLeft) + { + PrintString("\n", 1); + PrintString("shiftLeft test: Ok.", 19); + } + + var shiftRight = ShiftRight(4, 2) == 1; + if(shiftRight) + { + PrintString("\n", 1); + PrintString("shiftRight test: Ok.", 20); + } + var unsignedShift = UnsignedShift(0xFFFFFFFFu, 4) == 0x0FFFFFFFu; + if(unsignedShift) + { + PrintString("\n", 1); + PrintString("unsignedShift test: Ok.", 23); + } } private static unsafe void PrintString(string s, int length) @@ -67,6 +88,21 @@ internal static class Program return -a; } + private static int ShiftLeft(int a, int b) + { + return a << b; + } + + private static int ShiftRight(int a, int b) + { + return a >> b; + } + + private static uint UnsignedShift(uint a, int b) + { + return a >> b; + } + [DllImport("*")] private static unsafe extern int printf(byte* str, byte* unused); } |