Add test for bitops and fix a bug in >>>
authorDavid Anderson <dvander@alliedmods.net>
Sat Nov 17 20:23:36 2012 -0800 (2012-11-17)
changeset 20704ce04a54936
parent 206 3a896e9b57e2
child 208 7c5be05296e3
Add test for bitops and fix a bug in >>>
src/Interpreter.cpp
tests/basic/bitops.out
tests/basic/bitops.sp
tests/prototype/bitops.sp
     1.1 --- a/src/Interpreter.cpp	Sat Nov 17 20:11:05 2012 -0800
     1.2 +++ b/src/Interpreter.cpp	Sat Nov 17 20:23:36 2012 -0800
     1.3 @@ -636,7 +636,7 @@
     1.4  
     1.5  case OP_USHR:
     1.6  {
     1.7 -    top.sp[-2].i32 = unsigned(top.sp[-2].i32) << unsigned(top.sp[-1].i32);
     1.8 +    top.sp[-2].i32 = unsigned(top.sp[-2].i32) >> unsigned(top.sp[-1].i32);
     1.9      top.sp--;
    1.10      break;
    1.11  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tests/basic/bitops.out	Sat Nov 17 20:23:36 2012 -0800
     2.3 @@ -0,0 +1,1 @@
     2.4 +35503
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tests/basic/bitops.sp	Sat Nov 17 20:23:36 2012 -0800
     3.3 @@ -0,0 +1,16 @@
     3.4 +native PrintNum(num);
     3.5 +
     3.6 +main()
     3.7 +{
     3.8 +    new result = 5192342;
     3.9 +    for (new i = 0; i < 1000; i = i + 1) {
    3.10 +        result = result | i;
    3.11 +        result = result & 9129345;
    3.12 +        result = result ^ (i * 73);
    3.13 +
    3.14 +        new bit = result & 1;
    3.15 +        result = (result >>> 1) | (bit << 31);
    3.16 +        result = result | (i >> 6);
    3.17 +    }
    3.18 +    PrintNum(result);
    3.19 +}
     4.1 --- a/tests/prototype/bitops.sp	Sat Nov 17 20:11:05 2012 -0800
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,14 +0,0 @@
     4.4 -main()
     4.5 -{
     4.6 -    new result = 5192342;
     4.7 -    for (new i = 0; i < 100000; i = i + 1) {
     4.8 -        result = result | i;
     4.9 -        result = result & 9129345;
    4.10 -        result = result ^ (i * 73);
    4.11 -
    4.12 -        new bit = result & 1;
    4.13 -        result = (result >>> 1) | (bit << 31);
    4.14 -        result = result | (i >> 6);
    4.15 -    }
    4.16 -    return result;
    4.17 -}