tests.ternaryExpression = function() {
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x < 3 ? 4 : 5;
}
- int bar(int x)
+ test int bar(int x)
{
int y = 1;
int z = 2;
(x < 3 ? y : z) = 7;
return y;
}
- int baz(int x)
+ test int baz(int x)
{
return x < 10 ? 11 : x < 12 ? 14 : 15;
}
- int quux(int x)
+ test int quux(int x)
{
return 3 < 4 ? x : 5;
}
}
tests.literalBool = function() {
- let program = doPrep("bool foo() { return true; }");
+ let program = doPrep("test bool foo() { return true; }");
checkBool(program, callFunction(program, "foo", []), true);
}
tests.identityBool = function() {
- let program = doPrep("bool foo(bool x) { return x; }");
+ let program = doPrep("test bool foo(bool x) { return x; }");
checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), true);
checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), false);
}
tests.intSimpleMath = function() {
- let program = doPrep("int foo(int x, int y) { return x + y; }");
+ let program = doPrep("test int foo(int x, int y) { return x + y; }");
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 12);
- program = doPrep("int foo(int x, int y) { return x - y; }");
+ program = doPrep("test int foo(int x, int y) { return x - y; }");
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 2);
checkInt(program, callFunction(program, "foo", [makeInt(program, 5), makeInt(program, 7)]), -2);
- program = doPrep("int foo(int x, int y) { return x * y; }");
+ program = doPrep("test int foo(int x, int y) { return x * y; }");
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), 35);
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, -5)]), -35);
- program = doPrep("int foo(int x, int y) { return x / y; }");
+ program = doPrep("test int foo(int x, int y) { return x / y; }");
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 2)]), 3);
checkInt(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, -2)]), -3);
}
tests.uintSimpleMath = function() {
- let program = doPrep("uint foo(uint x, uint y) { return x + y; }");
+ let program = doPrep("test uint foo(uint x, uint y) { return x + y; }");
checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 12);
- program = doPrep("uint foo(uint x, uint y) { return x - y; }");
+ program = doPrep("test uint foo(uint x, uint y) { return x - y; }");
checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 2);
checkUint(program, callFunction(program, "foo", [makeUint(program, 5), makeUint(program, 7)]), 4294967294);
- program = doPrep("uint foo(uint x, uint y) { return x * y; }");
+ program = doPrep("test uint foo(uint x, uint y) { return x * y; }");
checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), 35);
- program = doPrep("uint foo(uint x, uint y) { return x / y; }");
+ program = doPrep("test uint foo(uint x, uint y) { return x / y; }");
checkUint(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 2)]), 3);
}
tests.ucharSimpleMath = function() {
- let program = doPrep("uchar foo(uchar x, uchar y) { return x + y; }");
+ let program = doPrep("test uchar foo(uchar x, uchar y) { return x + y; }");
checkUchar(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 5)]), 12);
- program = doPrep("uchar foo(uchar x, uchar y) { return x - y; }");
+ program = doPrep("test uchar foo(uchar x, uchar y) { return x - y; }");
checkUchar(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 5)]), 2);
checkUchar(program, callFunction(program, "foo", [makeUchar(program, 5), makeUchar(program, 7)]), 254);
- program = doPrep("uchar foo(uchar x, uchar y) { return x * y; }");
+ program = doPrep("test uchar foo(uchar x, uchar y) { return x * y; }");
checkUchar(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 5)]), 35);
- program = doPrep("uchar foo(uchar x, uchar y) { return x / y; }");
+ program = doPrep("test uchar foo(uchar x, uchar y) { return x / y; }");
checkUchar(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 2)]), 3);
}
tests.equality = function() {
- let program = doPrep("bool foo(uint x, uint y) { return x == y; }");
+ let program = doPrep("test bool foo(uint x, uint y) { return x == y; }");
checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), false);
checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 7)]), true);
- program = doPrep("bool foo(uchar x, uchar y) { return x == y; }");
+ program = doPrep("test bool foo(uchar x, uchar y) { return x == y; }");
checkBool(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 5)]), false);
checkBool(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 7)]), true);
- program = doPrep("bool foo(int x, int y) { return x == y; }");
+ program = doPrep("test bool foo(int x, int y) { return x == y; }");
checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), false);
checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 7)]), true);
- program = doPrep("bool foo(bool x, bool y) { return x == y; }");
+ program = doPrep("test bool foo(bool x, bool y) { return x == y; }");
checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), false);
checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), false);
checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), true);
tests.logicalNegation = function()
{
- let program = doPrep("bool foo(bool x) { return !x; }");
+ let program = doPrep("test bool foo(bool x) { return !x; }");
checkBool(program, callFunction(program, "foo", [makeBool(program, true)]), false);
checkBool(program, callFunction(program, "foo", [makeBool(program, false)]), true);
}
tests.notEquality = function() {
- let program = doPrep("bool foo(uint x, uint y) { return x != y; }");
+ let program = doPrep("test bool foo(uint x, uint y) { return x != y; }");
checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 5)]), true);
checkBool(program, callFunction(program, "foo", [makeUint(program, 7), makeUint(program, 7)]), false);
- program = doPrep("bool foo(uchar x, uchar y) { return x != y; }");
+ program = doPrep("test bool foo(uchar x, uchar y) { return x != y; }");
checkBool(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 5)]), true);
checkBool(program, callFunction(program, "foo", [makeUchar(program, 7), makeUchar(program, 7)]), false);
- program = doPrep("bool foo(int x, int y) { return x != y; }");
+ program = doPrep("test bool foo(int x, int y) { return x != y; }");
checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 5)]), true);
checkBool(program, callFunction(program, "foo", [makeInt(program, 7), makeInt(program, 7)]), false);
- program = doPrep("bool foo(bool x, bool y) { return x != y; }");
+ program = doPrep("test bool foo(bool x, bool y) { return x != y; }");
checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, true)]), true);
checkBool(program, callFunction(program, "foo", [makeBool(program, true), makeBool(program, false)]), true);
checkBool(program, callFunction(program, "foo", [makeBool(program, false), makeBool(program, false)]), false);
tests.equalityTypeFailure = function()
{
checkFail(
- () => doPrep("bool foo(int x, uint y) { return x == y; }"),
+ () => doPrep("test bool foo(int x, uint y) { return x == y; }"),
(e) => e instanceof WTypeError && e.message.indexOf("/internal/test:1") != -1);
}
tests.generalNegation = function()
{
- let program = doPrep("bool foo(int x) { return !x; }");
+ let program = doPrep("test bool foo(int x) { return !x; }");
checkBool(program, callFunction(program, "foo", [makeInt(program, 7)]), false);
checkBool(program, callFunction(program, "foo", [makeInt(program, 0)]), true);
}
tests.add1 = function() {
- let program = doPrep("int foo(int x) { return x + 1; }");
+ let program = doPrep("test int foo(int x) { return x + 1; }");
checkInt(program, callFunction(program, "foo", [makeInt(program, 42)]), 43);
}
tests.simpleVariable = function()
{
let program = doPrep(`
- int foo(int p)
+ test int foo(int p)
{
int result = p;
return result;
tests.simpleAssignment = function()
{
let program = doPrep(`
- int foo(int p)
+ test int foo(int p)
{
int result;
result = p;
tests.simpleDefault = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int result;
return result;
tests.simpleDereference = function()
{
let program = doPrep(`
- int foo(device int* p)
+ test int foo(device int* p)
{
return *p;
}
tests.dereferenceStore = function()
{
let program = doPrep(`
- void foo(device int* p)
+ test void foo(device int* p)
{
*p = 52;
}
tests.simpleMakePtr = function()
{
let program = doPrep(`
- thread int* foo()
+ test thread int* foo()
{
int x = 42;
return &x;
tests.threadArrayLoad = function()
{
let program = doPrep(`
- int foo(thread int[] array)
+ test int foo(thread int[] array)
{
return array[0u];
}
tests.threadArrayLoadIntLiteral = function()
{
let program = doPrep(`
- int foo(thread int[] array)
+ test int foo(thread int[] array)
{
return array[0];
}
tests.deviceArrayLoad = function()
{
let program = doPrep(`
- int foo(device int[] array)
+ test int foo(device int[] array)
{
return array[0u];
}
tests.threadArrayStore = function()
{
let program = doPrep(`
- void foo(thread int[] array, int value)
+ test void foo(thread int[] array, int value)
{
array[0u] = value;
}
tests.deviceArrayStore = function()
{
let program = doPrep(`
- void foo(device int[] array, int value)
+ test void foo(device int[] array, int value)
{
array[0u] = value;
}
tests.deviceArrayStoreIntLiteral = function()
{
let program = doPrep(`
- void foo(device int[] array, int value)
+ test void foo(device int[] array, int value)
{
array[0] = value;
}
int x;
int y;
}
- Foo foo(Foo foo)
+ test Foo foo(Foo foo)
{
Foo result;
result.x = foo.y;
tests.returnNull = function()
{
let program = doPrep(`
- thread int* foo() { return null; }
+ test thread int* foo() { return null; }
`);
let result = callFunction(program, "foo", []);
if (!result.type.isPtr)
tests.dereferenceDefaultNull = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
thread int* p;
return *p;
tests.defaultInitializedNull = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
thread int* p = null;;
return *p;
{
return *ptr;
}
- int bar()
+ test int bar()
{
return foo(null);
}
tests.returnNullArrayRef = function()
{
let program = doPrep(`
- thread int[] foo() { return null; }
+ test thread int[] foo() { return null; }
`);
let result = callFunction(program, "foo", []);
if (!result.type.isArrayRef)
tests.dereferenceDefaultNullArrayRef = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
thread int[] p;
return p[0u];
tests.defaultInitializedNullArrayRef = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
thread int[] p = null;
return p[0u];
tests.defaultInitializedNullArrayRefIntLiteral = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
thread int[] p = null;
return p[0];
{
return ptr[0u];
}
- int bar()
+ test int bar()
{
return foo(null);
}
tests.returnIntLiteralUint = function()
{
- let program = doPrep("uint foo() { return 42; }");
+ let program = doPrep("test uint foo() { return 42; }");
checkNumber(program, callFunction(program, "foo", []), 42);
}
tests.returnIntLiteralFloat = function()
{
- let program = doPrep("float foo() { return 42; }");
+ let program = doPrep("test float foo() { return 42; }");
checkNumber(program, callFunction(program, "foo", []), 42);
}
tests.doubleNot = function()
{
let program = doPrep(`
- bool foo(bool x)
+ test bool foo(bool x)
{
return !!x;
}
tests.variableShadowing = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int y;
int x = 7;
`);
checkInt(program, callFunction(program, "foo", []), 8);
program = doPrep(`
- int foo()
+ test int foo()
{
int y;
int x = 7;
tests.ifStatement = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
tests.ifElseStatement = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
tests.ifElseIfStatement = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
tests.ifElseIfElseStatement = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
`),
(e) => e instanceof WTypeError);
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
`),
(e) => e instanceof WTypeError);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7) {
`),
(e) => e instanceof WTypeError);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 6;
if (x == 7)
tests.simpleWhile = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (x < 13)
x = x * 2;
int foo(int) { return 1; }
int foo(uint) { return 2; }
int foo(float) { return 3; }
- int bar() { return foo(42); }
+ test int bar() { return foo(42); }
`);
checkInt(program, callFunction(program, "bar", []), 1);
}
int foo(float) { return 3; }
int foo(uint) { return 2; }
int foo(int) { return 1; }
- int bar() { return foo(42); }
+ test int bar() { return foo(42); }
`);
checkInt(program, callFunction(program, "bar", []), 1);
}
tests.break = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (true) {
x = x * 2;
checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8);
checkInt(program, callFunction(program, "foo", [makeInt(program, 10)]), 20);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (true) {
while (true) {
`),
(e) => e instanceof WTypeError);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (true) {
if (x == 7) {
`);
checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 7);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (true) {
break;
`);
checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 1);
program = doPrep(`
- int foo()
+ test int foo()
{
while (true) {
return 7;
checkInt(program, callFunction(program, "foo", []), 7);
checkFail(
() => doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while(true) {
break;
tests.continue = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
while (x < 10) {
if (x == 8) {
tests.doWhile = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 7;
do {
checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8);
checkInt(program, callFunction(program, "foo", [makeInt(program, 11)]), 8);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int y = 7;
do {
`);
checkInt(program, callFunction(program, "foo", [makeInt(program, 1)]), 8);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
do {
tests.forLoop = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
int i;
checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6);
checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
for (int i = 0; i < x; i = i + 1) {
checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6);
checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
int i = 100;
checkInt(program, callFunction(program, "foo", [makeInt(program, 4)]), 6);
checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 10);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
for (int i = 0; i < x; i = i + 1) {
checkInt(program, callFunction(program, "foo", [makeInt(program, 5)]), 6);
checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 11);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
for (int i = 0; i < x; i = i + 1) {
checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 10);
checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 10);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
for (int i = 0; ; i = i + 1) {
checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 15);
checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 21);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
int i = 0;
checkInt(program, callFunction(program, "foo", [makeInt(program, 6)]), 15);
checkInt(program, callFunction(program, "foo", [makeInt(program, 7)]), 21);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int sum = 0;
int i = 0;
`),
(e) => e instanceof WTypeError);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
for ( ; ; ) {
return 7;
`),
(e) => e instanceof WTypeError);
program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
for ( ; true; ) {
return 7;
tests.prefixPlusPlus = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
++x;
return x;
tests.prefixPlusPlusResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return ++x;
}
tests.postfixPlusPlus = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x++;
return x;
tests.postfixPlusPlusResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x++;
}
tests.prefixMinusMinus = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
--x;
return x;
tests.prefixMinusMinusResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return --x;
}
tests.postfixMinusMinus = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x--;
return x;
tests.postfixMinusMinusResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x--;
}
tests.plusEquals = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x += 42;
return x;
tests.plusEqualsResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x += 42;
}
tests.minusEquals = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x -= 42;
return x;
tests.minusEqualsResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x -= 42;
}
tests.timesEquals = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x *= 42;
return x;
tests.timesEqualsResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x *= 42;
}
tests.divideEquals = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
x /= 42;
return x;
tests.divideEqualsResult = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
return x /= 42;
}
tests.twoIntLiterals = function()
{
let program = doPrep(`
- bool foo()
+ test bool foo()
{
return 42 == 42;
}
tests.buildArrayThenSumIt = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int[42] array;
for (uint i = 0; i < 42; i = i + 1)
result = result + array[i];
return result;
}
- int foo()
+ test int foo()
{
int[42] array;
return bar(@array);
return &foo->y;
return null;
}
- int foo()
+ test int foo()
{
Foo foo;
foo.x = 498;
return &foo->y;
return null;
}
- int foo()
+ test int foo()
{
Foo foo;
foo[0] = 498;
{
return (*foo)[0] + (*foo)[1];
}
- int foo()
+ test int foo()
{
Foo foo;
foo.x = 498;
{
return ref[0];
}
- int foo()
+ test int foo()
{
int x = 48;
return bar(@x);
{
return bar(@ptr);
}
- int foo()
+ test int foo()
{
int x = 48;
return baz(&x);
tests.simpleLength = function()
{
let program = doPrep(`
- uint foo()
+ test uint foo()
{
float[754] array;
return (@array).length;
tests.nonArrayRefArrayLengthSucceed = function()
{
let program = doPrep(`
- uint foo()
+ test uint foo()
{
float[754] array;
return array.length;
}
- uint bar()
+ test uint bar()
{
int[754] array;
return array.length;
{
return foo.x;
}
- int foo()
+ test int foo()
{
Foo foo;
foo.x = 7804;
foo.x = value;
return foo;
}
- int foo()
+ test int foo()
{
Foo foo;
foo.y = 7804;
}
}
}
- int testSetValuesAndSum()
+ test int testSetValuesAndSum()
{
Baz baz;
setValues(&baz);
return sum(baz);
}
- int testSetValuesMutateValuesAndSum()
+ test int testSetValuesMutateValuesAndSum()
{
Baz baz;
setValues(&baz);
tests.operatorBool = function()
{
let program = doPrep(`
- bool boolFromUcharFalse() { return bool(uchar(0)); }
- bool boolFromUcharTrue() { return bool(uchar(1)); }
+ test bool boolFromUcharFalse() { return bool(uchar(0)); }
+ test bool boolFromUcharTrue() { return bool(uchar(1)); }
- bool boolFromUintFalse() { return bool(uint(0)); }
- bool boolFromUintTrue() { return bool(uint(1)); }
+ test bool boolFromUintFalse() { return bool(uint(0)); }
+ test bool boolFromUintTrue() { return bool(uint(1)); }
- bool boolFromIntFalse() { return bool(int(0)); }
- bool boolFromIntTrue() { return bool(int(1)); }
+ test bool boolFromIntFalse() { return bool(int(0)); }
+ test bool boolFromIntTrue() { return bool(int(1)); }
- bool boolFromFloatFalse() { return bool(float(0)); }
- bool boolFromFloatTrue() { return bool(float(1)); }
+ test bool boolFromFloatFalse() { return bool(float(0)); }
+ test bool boolFromFloatTrue() { return bool(float(1)); }
`);
checkBool(program, callFunction(program, "boolFromUcharFalse", []), false);
tests.boolBitAnd = function()
{
let program = doPrep(`
- bool foo(bool a, bool b)
+ test bool foo(bool a, bool b)
{
return a & b;
}
tests.boolBitOr = function()
{
let program = doPrep(`
- bool foo(bool a, bool b)
+ test bool foo(bool a, bool b)
{
return a | b;
}
tests.boolBitXor = function()
{
let program = doPrep(`
- bool foo(bool a, bool b)
+ test bool foo(bool a, bool b)
{
return a ^ b;
}
tests.boolBitNot = function()
{
let program = doPrep(`
- bool foo(bool a)
+ test bool foo(bool a)
{
return ~a;
}
tests.intBitAnd = function()
{
let program = doPrep(`
- int foo(int a, int b)
+ test int foo(int a, int b)
{
return a & b;
}
tests.intBitOr = function()
{
let program = doPrep(`
- int foo(int a, int b)
+ test int foo(int a, int b)
{
return a | b;
}
tests.intBitXor = function()
{
let program = doPrep(`
- int foo(int a, int b)
+ test int foo(int a, int b)
{
return a ^ b;
}
tests.intBitNot = function()
{
let program = doPrep(`
- int foo(int a)
+ test int foo(int a)
{
return ~a;
}
tests.intLShift = function()
{
let program = doPrep(`
- int foo(int a, uint b)
+ test int foo(int a, uint b)
{
return a << b;
}
tests.intRShift = function()
{
let program = doPrep(`
- int foo(int a, uint b)
+ test int foo(int a, uint b)
{
return a >> b;
}
tests.uintBitAnd = function()
{
let program = doPrep(`
- uint foo(uint a, uint b)
+ test uint foo(uint a, uint b)
{
return a & b;
}
tests.uintBitOr = function()
{
let program = doPrep(`
- uint foo(uint a, uint b)
+ test uint foo(uint a, uint b)
{
return a | b;
}
tests.uintBitXor = function()
{
let program = doPrep(`
- uint foo(uint a, uint b)
+ test uint foo(uint a, uint b)
{
return a ^ b;
}
tests.uintBitNot = function()
{
let program = doPrep(`
- uint foo(uint a)
+ test uint foo(uint a)
{
return ~a;
}
tests.uintLShift = function()
{
let program = doPrep(`
- uint foo(uint a, uint b)
+ test uint foo(uint a, uint b)
{
return a << b;
}
tests.uintRShift = function()
{
let program = doPrep(`
- uint foo(uint a, uint b)
+ test uint foo(uint a, uint b)
{
return a >> b;
}
tests.ucharBitAnd = function()
{
let program = doPrep(`
- uchar foo(uchar a, uchar b)
+ test uchar foo(uchar a, uchar b)
{
return a & b;
}
tests.ucharBitOr = function()
{
let program = doPrep(`
- uchar foo(uchar a, uchar b)
+ test uchar foo(uchar a, uchar b)
{
return a | b;
}
tests.ucharBitXor = function()
{
let program = doPrep(`
- uchar foo(uchar a, uchar b)
+ test uchar foo(uchar a, uchar b)
{
return a ^ b;
}
tests.ucharBitNot = function()
{
let program = doPrep(`
- uchar foo(uchar a)
+ test uchar foo(uchar a)
{
return ~a;
}
tests.ucharLShift = function()
{
let program = doPrep(`
- uchar foo(uchar a, uint b)
+ test uchar foo(uchar a, uint b)
{
return a << b;
}
tests.ucharRShift = function()
{
let program = doPrep(`
- uchar foo(uchar a, uint b)
+ test uchar foo(uchar a, uint b)
{
return a >> b;
}
tests.floatMath = function()
{
let program = doPrep(`
- bool foo()
+ test bool foo()
{
return 42.5 == 42.5;
}
- bool foo2()
+ test bool foo2()
{
return 42.5f == 42.5;
}
- bool foo3()
+ test bool foo3()
{
return 42.5 == 42.5f;
}
- bool foo4()
+ test bool foo4()
{
return 42.5f == 42.5f;
}
- bool foo5()
+ test bool foo5()
{
return 42.5f == 42.5f;
}
{
return x;
}
- float foo6()
+ test float foo6()
{
return bar(7.5);
}
- float foo7()
+ test float foo7()
{
return bar(7.5f);
}
- float foo9()
+ test float foo9()
{
return float(7.5);
}
- float foo10()
+ test float foo10()
{
return float(7.5f);
}
- float foo12()
+ test float foo12()
{
return float(7);
}
- float foo13()
+ test float foo13()
{
float x = 7.5f;
return float(x);
tests.booleanMath = function()
{
let program = doPrep(`
- bool foo()
+ test bool foo()
{
return true && true;
}
- bool foo2()
+ test bool foo2()
{
return true && false;
}
- bool foo3()
+ test bool foo3()
{
return false && true;
}
- bool foo4()
+ test bool foo4()
{
return false && false;
}
- bool foo5()
+ test bool foo5()
{
return true || true;
}
- bool foo6()
+ test bool foo6()
{
return true || false;
}
- bool foo7()
+ test bool foo7()
{
return false || true;
}
- bool foo8()
+ test bool foo8()
{
return false || false;
}
return retValue;
}
- int andTrue()
+ test int andTrue()
{
int x;
bool y = set(&x, 1, true) && set(&x, 2, false);
return x;
}
- int andFalse()
+ test int andFalse()
{
int x;
bool y = set(&x, 1, false) && set(&x, 2, false);
return x;
}
- int orTrue()
+ test int orTrue()
{
int x;
bool y = set(&x, 1, true) || set(&x, 2, false);
return x;
}
- int orFalse()
+ test int orFalse()
{
int x;
bool y = set(&x, 1, false) || set(&x, 2, false);
{
let program = doPrep(`
typedef ArrayTypedef = int[2];
- int foo()
+ test int foo()
{
ArrayTypedef arrayTypedef;
return arrayTypedef[0];
tests.vectorTypeSyntax = function()
{
let program = doPrep(`
- int foo2()
+ test int foo2()
{
int2 x;
vector<int, 2> z = int2(3, 4);
return x.y;
}
- int foo3()
+ test int foo3()
{
int3 x;
vector<int, 3> z = int3(3, 4, 5);
return x.z;
}
- int foo4()
+ test int foo4()
{
int4 x;
vector<int,4> z = int4(3, 4, 5, 6);
return x.w;
}
- bool vec2OperatorCast()
+ test bool vec2OperatorCast()
{
int2 x = vector<int,2>(1, 2);
vector<int, 2> y = int2(1, 2);
program = doPrep(`
typedef i = int;
- int foo2()
+ test int foo2()
{
int2 x;
vector<i, 2> z = int2(3, 4);
return x.y;
}
- bool vec2OperatorCast()
+ test bool vec2OperatorCast()
{
int2 x = vector<i,2>(1, 2);
vector<i, 2> y = int2(1, 2);
tests.builtinVectors = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int2 a = int2(3, 4);
return a[0];
}
- int foo2()
+ test int foo2()
{
int2 a = int2(3, 4);
int3 b = int3(a, 5);
return b[1];
}
- int foo3()
+ test int foo3()
{
int3 a = int3(3, 4, 5);
int4 b = int4(6, a);
return b[1];
}
- int foo4()
+ test int foo4()
{
int2 a = int2(3, 4);
int2 b = int2(5, 6);
int4 c = int4(a, b);
return c[2];
}
- bool foo5()
+ test bool foo5()
{
int4 a = int4(3, 4, 5, 6);
int2 b = int2(4, 5);
int4 c = int4(3, b, 6);
return a == c;
}
- bool foo6()
+ test bool foo6()
{
int2 a = int2(4, 5);
int3 b = int3(3, a);
int3 c = int3(3, 4, 6);
return b == c;
}
- uint foou()
+ test uint foou()
{
uint2 a = uint2(3, 4);
return a[0];
}
- uint foou2()
+ test uint foou2()
{
uint2 a = uint2(3, 4);
uint3 b = uint3(a, 5);
return b[1];
}
- uint foou3()
+ test uint foou3()
{
uint3 a = uint3(3, 4, 5);
uint4 b = uint4(6, a);
return b[1];
}
- uint foou4()
+ test uint foou4()
{
uint2 a = uint2(3, 4);
uint2 b = uint2(5, 6);
uint4 c = uint4(a, b);
return c[2];
}
- bool foou5()
+ test bool foou5()
{
uint4 a = uint4(3, 4, 5, 6);
uint2 b = uint2(4, 5);
uint4 c = uint4(3, b, 6);
return a == c;
}
- bool foou6()
+ test bool foou6()
{
uint2 a = uint2(4, 5);
uint3 b = uint3(3, a);
uint3 c = uint3(3, 4, 6);
return b == c;
}
- float foof()
+ test float foof()
{
float2 a = float2(3., 4.);
return a[0];
}
- float foof2()
+ test float foof2()
{
float2 a = float2(3., 4.);
float3 b = float3(a, 5.);
return b[1];
}
- float foof3()
+ test float foof3()
{
float3 a = float3(3., 4., 5.);
float4 b = float4(6., a);
return b[1];
}
- float foof4()
+ test float foof4()
{
float2 a = float2(3., 4.);
float2 b = float2(5., 6.);
float4 c = float4(a, b);
return c[2];
}
- bool foof5()
+ test bool foof5()
{
float4 a = float4(3., 4., 5., 6.);
float2 b = float2(4., 5.);
float4 c = float4(3., b, 6.);
return a == c;
}
- bool foof6()
+ test bool foof6()
{
float2 a = float2(4., 5.);
float3 b = float3(3., a);
for (let size of sizes) {
for (let i = 0; i < size; i++) {
const functionName = `${typeName}${size}${elements[i]}`;
- src += `${typeName} ${functionName}()
+ src += `test ${typeName} ${functionName}()
{
${typeName}${size} x = ${typeName}${size}(${initializerList.slice(0, size).join(", ")});
return x.${elements[i]};
for (let size of sizes) {
for (let i = 0; i < size; i++) {
const functionName = `${typeName}${size}${elements[i]}`;
- src += `${typeName} ${functionName}()
+ src += `test ${typeName} ${functionName}()
{
${typeName}${size} x = ${typeName}${size}(${initializerList.slice(0, size).join(", ")});
x.${elements[i]} = 34;
for (let size of sizes) {
for (let i = 0; i < size; i++) {
const functionName = `${typeName}${size}${elements[i]}`;
- src += `${typeName} ${functionName}()
+ src += `test ${typeName} ${functionName}()
{
${typeName}${size} x = ${typeName}${size}(${initializerList.slice(0, size).join(", ")});
x[${i}] = 34;
Pestilence,
Death
}
- Foo war()
+
+ Foo _war()
{
return Foo.War;
}
- Foo famine()
+
+ test Foo war()
+ {
+ return _war();
+ }
+
+ Foo _famine()
{
return Foo.Famine;
}
- Foo pestilence()
+
+ test Foo famine()
+ {
+ return _famine();
+ }
+
+ Foo _pestilence()
{
return Foo.Pestilence;
}
- Foo death()
+
+ test Foo pestilence()
+ {
+ return _pestilence();
+ }
+
+ Foo _death()
{
return Foo.Death;
}
- bool equals(Foo a, Foo b)
+
+ test Foo death()
+ {
+ return _death();
+ }
+
+ bool _equals(Foo a, Foo b)
{
return a == b;
}
- bool notEquals(Foo a, Foo b)
+
+ bool _notEquals(Foo a, Foo b)
{
return a != b;
}
- bool testSimpleEqual()
+
+ test bool testSimpleEqual()
+ {
+ return _equals(Foo.War, Foo.War);
+ }
+
+ test bool testAnotherEqual()
{
- return equals(Foo.War, Foo.War);
+ return _equals(Foo.Pestilence, Foo.Pestilence);
}
- bool testAnotherEqual()
+
+ test bool testNotEqual()
{
- return equals(Foo.Pestilence, Foo.Pestilence);
+ return _equals(Foo.Famine, Foo.Death);
}
- bool testNotEqual()
+
+ test bool testSimpleNotEqual()
{
- return equals(Foo.Famine, Foo.Death);
+ return _notEquals(Foo.War, Foo.War);
}
- bool testSimpleNotEqual()
+
+ test bool testAnotherNotEqual()
{
- return notEquals(Foo.War, Foo.War);
+ return _notEquals(Foo.Pestilence, Foo.Pestilence);
}
- bool testAnotherNotEqual()
+
+ test bool testNotNotEqual()
{
- return notEquals(Foo.Pestilence, Foo.Pestilence);
+ return _notEquals(Foo.Famine, Foo.Death);
}
- bool testNotNotEqual()
+
+ int _intWar()
{
- return notEquals(Foo.Famine, Foo.Death);
+ return int(_war());
}
- int intWar()
+
+ test int intWar()
{
- return int(war());
+ return _intWar();
}
- int intFamine()
+
+ int _intFamine()
{
- return int(famine());
+ return int(_famine());
}
- int intPestilence()
+
+ test int intFamine()
{
- return int(pestilence());
+ return _intFamine();
}
- int intDeath()
+
+ int _intPestilence()
{
- return int(death());
+ return int(_pestilence());
}
- int warValue()
+
+ test int intPestilence()
{
- return war().value;
+ return _intPestilence();
}
- int famineValue()
+
+ int _intDeath()
{
- return famine().value;
+ return int(_death());
}
- int pestilenceValue()
+
+ test int intDeath()
{
- return pestilence().value;
+ return _intDeath();
}
- int deathValue()
+
+ test int warValue()
{
- return death().value;
+ return _war().value;
}
- int warValueLiteral()
+
+ test int famineValue()
+ {
+ return _famine().value;
+ }
+
+ test int pestilenceValue()
+ {
+ return _pestilence().value;
+ }
+
+ test int deathValue()
+ {
+ return _death().value;
+ }
+
+ test int warValueLiteral()
{
return Foo.War.value;
}
- int famineValueLiteral()
+
+ test int famineValueLiteral()
{
return Foo.Famine.value;
}
- int pestilenceValueLiteral()
+
+ test int pestilenceValueLiteral()
{
return Foo.Pestilence.value;
}
- int deathValueLiteral()
+
+ test int deathValueLiteral()
{
return Foo.Death.value;
}
- Foo intWarBackwards()
+
+ test Foo intWarBackwards()
{
- return Foo(intWar());
+ return Foo(_intWar());
}
- Foo intFamineBackwards()
+
+ test Foo intFamineBackwards()
{
- return Foo(intFamine());
+ return Foo(_intFamine());
}
- Foo intPestilenceBackwards()
+
+ test Foo intPestilenceBackwards()
{
- return Foo(intPestilence());
+ return Foo(_intPestilence());
}
- Foo intDeathBackwards()
+
+ test Foo intDeathBackwards()
{
- return Foo(intDeath());
+ return Foo(_intDeath());
}
`);
checkEnum(program, callFunction(program, "war", []), 0);
Pestilence = 23,
Death = -42
}
- Foo war()
+ test Foo war()
{
return Foo.War;
}
- Foo famine()
+ test Foo famine()
{
return Foo.Famine;
}
- Foo pestilence()
+ test Foo pestilence()
{
return Foo.Pestilence;
}
- Foo death()
+ test Foo death()
{
return Foo.Death;
}
Pestilence = 0,
Death
}
- Foo war()
+ test Foo war()
{
return Foo.War;
}
- Foo famine()
+ test Foo famine()
{
return Foo.Famine;
}
- Foo pestilence()
+ test Foo pestilence()
{
return Foo.Pestilence;
}
- Foo death()
+ test Foo death()
{
return Foo.Death;
}
tests.trap = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
trap;
}
- int foo2(int x)
+ test int foo2(int x)
{
if (x == 3)
trap;
int3 x;
float y;
}
- Bar foo3()
+ test Bar foo3()
{
trap;
}
Pestilence,
Death
}
- Foo war()
+
+ Foo _war()
{
return Foo.War;
}
- Foo famine()
+
+ test Foo war()
+ {
+ return _war();
+ }
+
+ Foo _famine()
{
return Foo.Famine;
}
- Foo pestilence()
+
+ test Foo famine()
+ {
+ return _famine();
+ }
+
+ Foo _pestilence()
{
return Foo.Pestilence;
}
- Foo death()
+
+ test Foo pestilence()
+ {
+ return _pestilence();
+ }
+
+ Foo _death()
{
return Foo.Death;
}
- bool equals(Foo a, Foo b)
+
+ test Foo death()
+ {
+ return _death();
+ }
+
+ bool _equals(Foo a, Foo b)
{
return a == b;
}
- bool notEquals(Foo a, Foo b)
+
+ bool _notEquals(Foo a, Foo b)
{
return a != b;
}
- bool testSimpleEqual()
+
+ test bool testSimpleEqual()
+ {
+ return _equals(Foo.War, Foo.War);
+ }
+
+ test bool testAnotherEqual()
+ {
+ return _equals(Foo.Pestilence, Foo.Pestilence);
+ }
+
+ test bool testNotEqual()
+ {
+ return _equals(Foo.Famine, Foo.Death);
+ }
+
+ test bool testSimpleNotEqual()
{
- return equals(Foo.War, Foo.War);
+ return _notEquals(Foo.War, Foo.War);
}
- bool testAnotherEqual()
+
+ test bool testAnotherNotEqual()
{
- return equals(Foo.Pestilence, Foo.Pestilence);
+ return _notEquals(Foo.Pestilence, Foo.Pestilence);
}
- bool testNotEqual()
+
+ test bool testNotNotEqual()
{
- return equals(Foo.Famine, Foo.Death);
+ return _notEquals(Foo.Famine, Foo.Death);
}
- bool testSimpleNotEqual()
+
+ int _intWar()
{
- return notEquals(Foo.War, Foo.War);
+ return int(_war());
}
- bool testAnotherNotEqual()
+
+ test int intWar()
{
- return notEquals(Foo.Pestilence, Foo.Pestilence);
+ return _intWar();
}
- bool testNotNotEqual()
+
+ int _intFamine()
{
- return notEquals(Foo.Famine, Foo.Death);
+ return int(_famine());
}
- int intWar()
+
+ test int intFamine()
{
- return int(war());
+ return _intFamine();
}
- int intFamine()
+
+ int _intPestilence()
{
- return int(famine());
+ return int(_pestilence());
}
- int intPestilence()
+
+ test int intPestilence()
{
- return int(pestilence());
+ return _intPestilence();
}
- int intDeath()
+
+ int _intDeath()
{
- return int(death());
+ return int(_death());
}
- int warValue()
+
+ test int intDeath()
+ {
+ return _intDeath();
+ }
+
+ test int warValue()
{
- return war().value;
+ return _war().value;
}
- int famineValue()
+
+ test int famineValue()
{
- return famine().value;
+ return _famine().value;
}
- int pestilenceValue()
+
+ test int pestilenceValue()
{
- return pestilence().value;
+ return _pestilence().value;
}
- int deathValue()
+
+ test int deathValue()
{
- return death().value;
+ return _death().value;
}
- int warValueLiteral()
+
+ test int warValueLiteral()
{
return Foo.War.value;
}
- int famineValueLiteral()
+
+ test int famineValueLiteral()
{
return Foo.Famine.value;
}
- int pestilenceValueLiteral()
+
+ test int pestilenceValueLiteral()
{
return Foo.Pestilence.value;
}
- int deathValueLiteral()
+
+ test int deathValueLiteral()
{
return Foo.Death.value;
}
- Foo intWarBackwards()
+
+ test Foo intWarBackwards()
{
- return Foo(intWar());
+ return Foo(_intWar());
}
- Foo intFamineBackwards()
+
+ test Foo intFamineBackwards()
{
- return Foo(intFamine());
+ return Foo(_intFamine());
}
- Foo intPestilenceBackwards()
+
+ test Foo intPestilenceBackwards()
{
- return Foo(intPestilence());
+ return Foo(_intPestilence());
}
- Foo intDeathBackwards()
+
+ test Foo intDeathBackwards()
{
- return Foo(intDeath());
+ return Foo(_intDeath());
}
`);
checkEnum(program, callFunction(program, "war", []), 0);
Pestilence,
Death
}
- Foo war()
+
+ Foo _war()
{
return Foo.War;
}
- Foo famine()
+
+ test Foo war()
+ {
+ return _war();
+ }
+
+ Foo _famine()
{
return Foo.Famine;
}
- Foo pestilence()
+
+ test Foo famine()
+ {
+ return _famine();
+ }
+
+ Foo _pestilence()
{
return Foo.Pestilence;
}
- Foo death()
+
+ test Foo pestilence()
+ {
+ return _pestilence();
+ }
+
+ Foo _death()
{
return Foo.Death;
}
- bool equals(Foo a, Foo b)
+
+ test Foo death()
+ {
+ return _death();
+ }
+
+ bool _equals(Foo a, Foo b)
{
return a == b;
}
- bool notEquals(Foo a, Foo b)
+
+ bool _notEquals(Foo a, Foo b)
{
return a != b;
}
- bool testSimpleEqual()
+
+ test bool testSimpleEqual()
+ {
+ return _equals(Foo.War, Foo.War);
+ }
+
+ test bool testAnotherEqual()
+ {
+ return _equals(Foo.Pestilence, Foo.Pestilence);
+ }
+
+ test bool testNotEqual()
+ {
+ return _equals(Foo.Famine, Foo.Death);
+ }
+
+ test bool testSimpleNotEqual()
+ {
+ return _notEquals(Foo.War, Foo.War);
+ }
+
+ test bool testAnotherNotEqual()
{
- return equals(Foo.War, Foo.War);
+ return _notEquals(Foo.Pestilence, Foo.Pestilence);
}
- bool testAnotherEqual()
+
+ test bool testNotNotEqual()
{
- return equals(Foo.Pestilence, Foo.Pestilence);
+ return _notEquals(Foo.Famine, Foo.Death);
}
- bool testNotEqual()
+
+ uint _uintWar()
{
- return equals(Foo.Famine, Foo.Death);
+ return uint(_war());
}
- bool testSimpleNotEqual()
+
+ test uint uintWar()
{
- return notEquals(Foo.War, Foo.War);
+ return _uintWar();
}
- bool testAnotherNotEqual()
+
+ uint _uintFamine()
{
- return notEquals(Foo.Pestilence, Foo.Pestilence);
+ return uint(_famine());
}
- bool testNotNotEqual()
+
+ test uint uintFamine()
{
- return notEquals(Foo.Famine, Foo.Death);
+ return _uintFamine();
}
- uint uintWar()
+
+ uint _uintPestilence()
{
- return uint(war());
+ return uint(_pestilence());
}
- uint uintFamine()
+
+ test uint uintPestilence()
{
- return uint(famine());
+ return _uintPestilence();
}
- uint uintPestilence()
+
+ uint _uintDeath()
{
- return uint(pestilence());
+ return uint(_death());
}
- uint uintDeath()
+
+ test uint uintDeath()
{
- return uint(death());
+ return _uintDeath();
}
- uint warValue()
+
+ test uint warValue()
{
- return war().value;
+ return _war().value;
}
- uint famineValue()
+
+ test uint famineValue()
{
- return famine().value;
+ return _famine().value;
}
- uint pestilenceValue()
+
+ test uint pestilenceValue()
{
- return pestilence().value;
+ return _pestilence().value;
}
- uint deathValue()
+
+ test uint deathValue()
{
- return death().value;
+ return _death().value;
}
- uint warValueLiteral()
+
+ test uint warValueLiteral()
{
return Foo.War.value;
}
- uint famineValueLiteral()
+
+ test uint famineValueLiteral()
{
return Foo.Famine.value;
}
- uint pestilenceValueLiteral()
+
+ test uint pestilenceValueLiteral()
{
return Foo.Pestilence.value;
}
- uint deathValueLiteral()
+
+ test uint deathValueLiteral()
{
return Foo.Death.value;
}
- Foo uintWarBackwards()
+
+ test Foo uintWarBackwards()
{
- return Foo(uintWar());
+ return Foo(_uintWar());
}
- Foo uintFamineBackwards()
+
+ test Foo uintFamineBackwards()
{
- return Foo(uintFamine());
+ return Foo(_uintFamine());
}
- Foo uintPestilenceBackwards()
+
+ test Foo uintPestilenceBackwards()
{
- return Foo(uintPestilence());
+ return Foo(_uintPestilence());
}
- Foo uintDeathBackwards()
+
+ test Foo uintDeathBackwards()
{
- return Foo(uintDeath());
+ return Foo(_uintDeath());
}
`);
checkEnum(program, callFunction(program, "war", []), 0);
{
let program = doPrep(`
struct Thingy { }
- int foo()
+ test int foo()
{
Thingy thingy;
return 46;
tests.simpleSwitch = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
switch (x) {
case 767:
tests.exhaustiveUcharSwitch = function()
{
- let text = "float foo(uchar x) { switch (uchar(x)) {"
+ let text = "test float foo(uchar x) { switch (uchar(x)) {"
for (let i = 0; i <= 0xff; ++i)
text += "case " + i + ": return " + i * 1.5 + ";";
text += "} }";
tests.notQuiteExhaustiveUcharSwitch = function()
{
- let text = "float foo(uchar x) { switch (uchar(x)) {"
+ let text = "test float foo(uchar x) { switch (uchar(x)) {"
for (let i = 0; i <= 0xfe; ++i)
text += "case " + i + ": return " + i * 1.5 + ";";
text += "} }";
tests.notQuiteExhaustiveUcharSwitchWithDefault = function()
{
- let text = "float foo(uchar x) { switch (uchar(x)) {"
+ let text = "test float foo(uchar x) { switch (uchar(x)) {"
for (let i = 0; i <= 0xfe; ++i)
text += "case " + i + ": return " + i * 1.5 + ";";
text += "default: return " + 0xff * 1.5 + ";";
// FIXME: This might become an error in future versions.
// https://bugs.webkit.org/show_bug.cgi?id=177172
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int result = 0;
switch (x) {
tests.switchBreak = function()
{
let program = doPrep(`
- int foo(int x)
+ test int foo(int x)
{
int result = 0;
switch (x) {
enum Foo {
A, B, C
}
- int foo(Foo x)
+ test int foo(Foo x)
{
int result = 0;
switch (x) {
enum Foo {
A, B, C
}
- int foo(Foo x)
+ test int foo(Foo x)
{
int result = 0;
switch (x) {
thread Foo* foo;
int bar;
}
- int foo()
+ test int foo()
{
Foo foo;
Bar bar;
thread Foo* foo;
int bar;
}
- int foo()
+ test int foo()
{
Foo foo;
Bar bar;
thread Node* next;
int value;
}
- int foo()
+ test int foo()
{
Node x, y, z;
x.next = &y;
tests.pointerToPointer = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int x;
thread int* p = &x;
tests.arrayRefToArrayRef = function()
{
let program = doPrep(`
- int foo()
+ test int foo()
{
int x;
thread int[] p = @x;
result.x = a.x + b.x;
return result;
}
- int foo()
+ test int foo()
{
Foo a;
a.x = 645;
{
return &foo->x;
}
- int foo()
+ test int foo()
{
Foo x;
x.x = 13;
{
return &foo[0].x;
}
- int foo()
+ test int foo()
{
Foo x;
x.x = 13;
{
return &foo->x;
}
- int foo()
+ test int foo()
{
Foo x;
x.x = 13;
{
return &array[uint(index + 1)].x;
}
- int foo()
+ test int foo()
{
Foo x;
x.x = 13;
x[5] = 354;
return @x;
}
- int foo()
+ test int foo()
{
thread int* ptr = &getArray()[5];
return *ptr;
b.y = foo.x + 7;
return b;
}
- int baz(int z) {
+ test int baz(int z) {
Foo foo;
foo.x = z;
Bar b = Bar(foo);
b.y = (*foo).x + 8;
return &b;
}
- int baz(int z) {
+ test int baz(int z) {
Foo foo;
foo.x = z;
thread Bar* b = thread Bar*(&foo);
tests.builtinMatrices = function()
{
let program = doPrep(`
- float foo()
+ test float foo()
{
float2x2 a;
a[0][0] = 1;
a[1][1] = 4;
return a[0][0];
}
- float foo2()
+ test float foo2()
{
float2x3 a;
a[0][0] = 1;
a[1][2] = 6;
return a[1][2];
}
- float foo3()
+ test float foo3()
{
float2x2 a;
return a[0][0];
}
- bool foo4()
+ test bool foo4()
{
float2x2 a;
a[0][0] = 1;
}
return a == b;
}
- bool foo5()
+ test bool foo5()
{
float2x2 a;
a[0] = float2(1, 2);
b[1][1] = 4;
return a == b;
}
- bool foo6()
+ test bool foo6()
{
float2x2 a;
a[0][0] = 1;
a[1] *= 6;
return a == b;
}
- float foo7()
+ test float foo7()
{
float2x3 a = float2x3(float3(3, 4, 5), float3(6, 7, 8));
return a[0][2];
}
tests.halfSimpleMath = function() {
- let program = doPrep("half foo(half x, half y) { return x + y; }");
+ let program = doPrep("test half foo(half x, half y) { return x + y; }");
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, 5)]), 12);
- program = doPrep("half foo(half x, half y) { return x - y; }");
+ program = doPrep("test half foo(half x, half y) { return x - y; }");
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, 5)]), 2);
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 5), makeHalf(program, 7)]), -2);
- program = doPrep("half foo(half x, half y) { return x * y; }");
+ program = doPrep("test half foo(half x, half y) { return x * y; }");
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, 5)]), 35);
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, -5)]), -35);
- program = doPrep("half foo(half x, half y) { return x / y; }");
+ program = doPrep("test half foo(half x, half y) { return x / y; }");
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, 2)]), 3.5);
checkHalf(program, callFunction(program, "foo", [makeHalf(program, 7), makeHalf(program, -2)]), -3.5);
}
y[2][3] = 61;
return y;
}
- float foo00() {
+ test float foo00() {
return multiply(matrix1(), matrix2())[0][0];
}
- float foo01() {
+ test float foo01() {
return multiply(matrix1(), matrix2())[0][1];
}
- float foo02() {
+ test float foo02() {
return multiply(matrix1(), matrix2())[0][2];
}
- float foo03() {
+ test float foo03() {
return multiply(matrix1(), matrix2())[0][3];
}
- float foo10() {
+ test float foo10() {
return multiply(matrix1(), matrix2())[1][0];
}
- float foo11() {
+ test float foo11() {
return multiply(matrix1(), matrix2())[1][1];
}
- float foo12() {
+ test float foo12() {
return multiply(matrix1(), matrix2())[1][2];
}
- float foo13() {
+ test float foo13() {
return multiply(matrix1(), matrix2())[1][3];
}
`);
tests.arrayIndex = function() {
let program = doPrep(`
- uint innerArrayLength() {
+ test uint innerArrayLength() {
int[2][3] array;
return array[0].length;
}
- uint outerArrayLength() {
+ test uint outerArrayLength() {
int[2][3] array;
return array.length;
}
- int arrayIndexing(uint i, uint j) {
+ test int arrayIndexing(uint i, uint j) {
int[2][3] array;
array[0][0] = 1;
array[0][1] = 2;
tests.textureDimensions = function() {
let program = doPrep(`
- uint foo1(Texture1D<float> texture) {
+ test uint foo1(Texture1D<float> texture) {
uint width;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &numberOfLevels);
return width;
}
- uint foo2(Texture1D<float> texture) {
+ test uint foo2(Texture1D<float> texture) {
uint width;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &numberOfLevels);
return numberOfLevels;
}
- uint foo3(Texture1DArray<float> texture) {
+ test uint foo3(Texture1DArray<float> texture) {
uint width;
uint elements;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &elements, &numberOfLevels);
return width;
}
- uint foo4(Texture1DArray<float> texture) {
+ test uint foo4(Texture1DArray<float> texture) {
uint width;
uint elements;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &elements, &numberOfLevels);
return elements;
}
- uint foo5(Texture1DArray<float> texture) {
+ test uint foo5(Texture1DArray<float> texture) {
uint width;
uint elements;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &elements, &numberOfLevels);
return numberOfLevels;
}
- uint foo6(Texture2D<float> texture) {
+ test uint foo6(Texture2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return width;
}
- uint foo7(Texture2D<float> texture) {
+ test uint foo7(Texture2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return height;
}
- uint foo8(Texture2D<float> texture) {
+ test uint foo8(Texture2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return numberOfLevels;
}
- uint foo9(Texture2DArray<float> texture) {
+ test uint foo9(Texture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return width;
}
- uint foo10(Texture2DArray<float> texture) {
+ test uint foo10(Texture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return height;
}
- uint foo11(Texture2DArray<float> texture) {
+ test uint foo11(Texture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return elements;
}
- uint foo12(Texture2DArray<float> texture) {
+ test uint foo12(Texture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return numberOfLevels;
}
- uint foo13(Texture3D<float> texture) {
+ test uint foo13(Texture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, 0, &width, &height, &depth, &numberOfLevels);
return width;
}
- uint foo14(Texture3D<float> texture) {
+ test uint foo14(Texture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, 0, &width, &height, &depth, &numberOfLevels);
return height;
}
- uint foo15(Texture3D<float> texture) {
+ test uint foo15(Texture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, 0, &width, &height, &depth, &numberOfLevels);
return depth;
}
- uint foo16(Texture3D<float> texture) {
+ test uint foo16(Texture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, 0, &width, &height, &depth, &numberOfLevels);
return numberOfLevels;
}
- uint foo17(TextureCube<float> texture) {
+ test uint foo17(TextureCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return width;
}
- uint foo18(TextureCube<float> texture) {
+ test uint foo18(TextureCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return height;
}
- uint foo19(TextureCube<float> texture) {
+ test uint foo19(TextureCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return numberOfLevels;
}
- uint foo20(RWTexture1D<float> texture) {
+ test uint foo20(RWTexture1D<float> texture) {
uint width;
GetDimensions(texture, &width);
return width;
}
- uint foo21(RWTexture1DArray<float> texture) {
+ test uint foo21(RWTexture1DArray<float> texture) {
uint width;
uint elements;
GetDimensions(texture, &width, &elements);
return width;
}
- uint foo22(RWTexture1DArray<float> texture) {
+ test uint foo22(RWTexture1DArray<float> texture) {
uint width;
uint elements;
GetDimensions(texture, &width, &elements);
return elements;
}
- uint foo23(RWTexture2D<float> texture) {
+ test uint foo23(RWTexture2D<float> texture) {
uint width;
uint height;
GetDimensions(texture, &width, &height);
return width;
}
- uint foo24(RWTexture2D<float> texture) {
+ test uint foo24(RWTexture2D<float> texture) {
uint width;
uint height;
GetDimensions(texture, &width, &height);
return height;
}
- uint foo25(RWTexture2DArray<float> texture) {
+ test uint foo25(RWTexture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, &width, &height, &elements);
return width;
}
- uint foo26(RWTexture2DArray<float> texture) {
+ test uint foo26(RWTexture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, &width, &height, &elements);
return height;
}
- uint foo27(RWTexture2DArray<float> texture) {
+ test uint foo27(RWTexture2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, &width, &height, &elements);
return elements;
}
- uint foo28(RWTexture3D<float> texture) {
+ test uint foo28(RWTexture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, &width, &height, &depth);
return width;
}
- uint foo29(RWTexture3D<float> texture) {
+ test uint foo29(RWTexture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, &width, &height, &depth);
return height;
}
- uint foo30(RWTexture3D<float> texture) {
+ test uint foo30(RWTexture3D<float> texture) {
uint width;
uint height;
uint depth;
GetDimensions(texture, &width, &height, &depth);
return depth;
}
- uint foo31(TextureDepth2D<float> texture) {
+ test uint foo31(TextureDepth2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return width;
}
- uint foo32(TextureDepth2D<float> texture) {
+ test uint foo32(TextureDepth2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return height;
}
- uint foo33(TextureDepth2D<float> texture) {
+ test uint foo33(TextureDepth2D<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return numberOfLevels;
}
- uint foo34(TextureDepth2DArray<float> texture) {
+ test uint foo34(TextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return width;
}
- uint foo35(TextureDepth2DArray<float> texture) {
+ test uint foo35(TextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return height;
}
- uint foo36(TextureDepth2DArray<float> texture) {
+ test uint foo36(TextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return elements;
}
- uint foo37(TextureDepth2DArray<float> texture) {
+ test uint foo37(TextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, 0, &width, &height, &elements, &numberOfLevels);
return numberOfLevels;
}
- uint foo38(TextureDepthCube<float> texture) {
+ test uint foo38(TextureDepthCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return width;
}
- uint foo39(TextureDepthCube<float> texture) {
+ test uint foo39(TextureDepthCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return height;
}
- uint foo40(TextureDepthCube<float> texture) {
+ test uint foo40(TextureDepthCube<float> texture) {
uint width;
uint height;
uint numberOfLevels;
GetDimensions(texture, 0, &width, &height, &numberOfLevels);
return numberOfLevels;
}
- uint foo41(RWTextureDepth2D<float> texture) {
+ test uint foo41(RWTextureDepth2D<float> texture) {
uint width;
uint height;
GetDimensions(texture, &width, &height);
return width;
}
- uint foo42(RWTextureDepth2D<float> texture) {
+ test uint foo42(RWTextureDepth2D<float> texture) {
uint width;
uint height;
GetDimensions(texture, &width, &height);
return height;
}
- uint foo43(RWTextureDepth2DArray<float> texture) {
+ test uint foo43(RWTextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, &width, &height, &elements);
return width;
}
- uint foo44(RWTextureDepth2DArray<float> texture) {
+ test uint foo44(RWTextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
GetDimensions(texture, &width, &height, &elements);
return height;
}
- uint foo45(RWTextureDepth2DArray<float> texture) {
+ test uint foo45(RWTextureDepth2DArray<float> texture) {
uint width;
uint height;
uint elements;
tests.textureLoad = function() {
let program = doPrep(`
- float foo1(Texture1D<float> texture, int location, int mipmap) {
+ test float foo1(Texture1D<float> texture, int location, int mipmap) {
return Load(texture, int2(location, mipmap));
}
- float foo2(Texture1D<float> texture, int location, int mipmap, int offset) {
+ test float foo2(Texture1D<float> texture, int location, int mipmap, int offset) {
return Load(texture, int2(location, mipmap), offset);
}
- float foo3(Texture1DArray<float> texture, int location, int mipmap, int layer) {
+ test float foo3(Texture1DArray<float> texture, int location, int mipmap, int layer) {
return Load(texture, int3(location, mipmap, layer));
}
- float foo4(Texture1DArray<float> texture, int location, int mipmap, int layer, int offset) {
+ test float foo4(Texture1DArray<float> texture, int location, int mipmap, int layer, int offset) {
return Load(texture, int3(location, mipmap, layer), offset);
}
- float foo5(Texture2D<float> texture, int x, int y, int mipmap) {
+ test float foo5(Texture2D<float> texture, int x, int y, int mipmap) {
return Load(texture, int3(x, y, mipmap));
}
- float foo6(Texture2D<float> texture, int x, int y, int mipmap, int offsetX, int offsetY) {
+ test float foo6(Texture2D<float> texture, int x, int y, int mipmap, int offsetX, int offsetY) {
return Load(texture, int3(x, y, mipmap), int2(offsetX, offsetY));
}
- float foo7(Texture2DArray<float> texture, int x, int y, int mipmap, int layer) {
+ test float foo7(Texture2DArray<float> texture, int x, int y, int mipmap, int layer) {
return Load(texture, int4(x, y, mipmap, layer));
}
- float foo8(Texture2DArray<float> texture, int x, int y, int mipmap, int layer, int offsetX, int offsetY) {
+ test float foo8(Texture2DArray<float> texture, int x, int y, int mipmap, int layer, int offsetX, int offsetY) {
return Load(texture, int4(x, y, mipmap, layer), int2(offsetX, offsetY));
}
- float foo9(Texture3D<float> texture, int x, int y, int z, int mipmap) {
+ test float foo9(Texture3D<float> texture, int x, int y, int z, int mipmap) {
return Load(texture, int4(x, y, z, mipmap));
}
- float foo10(Texture3D<float> texture, int x, int y, int z, int mipmap, int offsetX, int offsetY, int offsetZ) {
+ test float foo10(Texture3D<float> texture, int x, int y, int z, int mipmap, int offsetX, int offsetY, int offsetZ) {
return Load(texture, int4(x, y, z, mipmap), int3(offsetX, offsetY, offsetZ));
}
- float foo11(RWTexture1D<float> texture, int location) {
+ test float foo11(RWTexture1D<float> texture, int location) {
return Load(texture, location);
}
- float foo12(RWTexture1DArray<float> texture, int location, int layer) {
+ test float foo12(RWTexture1DArray<float> texture, int location, int layer) {
return Load(texture, int2(location, layer));
}
- float foo13(RWTexture2D<float> texture, int x, int y) {
+ test float foo13(RWTexture2D<float> texture, int x, int y) {
return Load(texture, int2(x, y));
}
- float foo14(RWTexture2DArray<float> texture, int x, int y, int layer) {
+ test float foo14(RWTexture2DArray<float> texture, int x, int y, int layer) {
return Load(texture, int3(x, y, layer));
}
- float foo15(RWTexture3D<float> texture, int x, int y, int z) {
+ test float foo15(RWTexture3D<float> texture, int x, int y, int z) {
return Load(texture, int3(x, y, z));
}
- float foo16(TextureDepth2D<float> texture, int x, int y, int mipmap) {
+ test float foo16(TextureDepth2D<float> texture, int x, int y, int mipmap) {
return Load(texture, int3(x, y, mipmap));
}
- float foo17(TextureDepth2D<float> texture, int x, int y, int mipmap, int offsetX, int offsetY) {
+ test float foo17(TextureDepth2D<float> texture, int x, int y, int mipmap, int offsetX, int offsetY) {
return Load(texture, int3(x, y, mipmap), int2(offsetX, offsetY));
}
- float foo18(TextureDepth2DArray<float> texture, int x, int y, int mipmap, int layer) {
+ test float foo18(TextureDepth2DArray<float> texture, int x, int y, int mipmap, int layer) {
return Load(texture, int4(x, y, mipmap, layer));
}
- float foo19(TextureDepth2DArray<float> texture, int x, int y, int mipmap, int layer, int offsetX, int offsetY) {
+ test float foo19(TextureDepth2DArray<float> texture, int x, int y, int mipmap, int layer, int offsetX, int offsetY) {
return Load(texture, int4(x, y, mipmap, layer), int2(offsetX, offsetY));
}
- float foo20(RWTextureDepth2D<float> texture, int x, int y) {
+ test float foo20(RWTextureDepth2D<float> texture, int x, int y) {
return Load(texture, int2(x, y));
}
- float foo21(RWTextureDepth2DArray<float> texture, int x, int y, int layer) {
+ test float foo21(RWTextureDepth2DArray<float> texture, int x, int y, int layer) {
return Load(texture, int3(x, y, layer));
}
`);
tests.textureStore = function() {
let program = doPrep(`
- float foo1(RWTexture1D<float> texture, uint location, float value) {
+ test float foo1(RWTexture1D<float> texture, uint location, float value) {
Store(texture, value, location);
return Load(texture, int(location));
}
- float foo2(RWTexture1DArray<float> texture, uint location, uint layer, float value) {
+ test float foo2(RWTexture1DArray<float> texture, uint location, uint layer, float value) {
Store(texture, value, uint2(location, layer));
return Load(texture, int2(int(location), int(layer)));
}
- float foo3(RWTexture2D<float> texture, uint x, uint y, float value) {
+ test float foo3(RWTexture2D<float> texture, uint x, uint y, float value) {
Store(texture, value, uint2(x, y));
return Load(texture, int2(int(x), int(y)));
}
- float foo4(RWTexture2DArray<float> texture, uint x, uint y, uint layer, float value) {
+ test float foo4(RWTexture2DArray<float> texture, uint x, uint y, uint layer, float value) {
Store(texture, value, uint3(x, y, layer));
return Load(texture, int3(int(x), int(y), int(layer)));
}
- float foo5(RWTexture3D<float> texture, uint x, uint y, uint z, float value) {
+ test float foo5(RWTexture3D<float> texture, uint x, uint y, uint z, float value) {
Store(texture, value, uint3(x, y, z));
return Load(texture, int3(int(x), int(y), int(z)));
}
- float foo6(RWTextureDepth2D<float> texture, uint x, uint y, float value) {
+ test float foo6(RWTextureDepth2D<float> texture, uint x, uint y, float value) {
Store(texture, value, uint2(x, y));
return Load(texture, int2(int(x), int(y)));
}
- float foo7(RWTextureDepth2DArray<float> texture, uint x, uint y, uint layer, float value) {
+ test float foo7(RWTextureDepth2DArray<float> texture, uint x, uint y, uint layer, float value) {
Store(texture, value, uint3(x, y, layer));
return Load(texture, int3(int(x), int(y), int(layer)));
}
tests.textureSample = function() {
let program = doPrep(`
- float foo1(Texture1D<float> texture, sampler s, float location) {
+ test float foo1(Texture1D<float> texture, sampler s, float location) {
return Sample(texture, s, location);
}
- float foo2(Texture1D<float> texture, sampler s, float location, int offset) {
+ test float foo2(Texture1D<float> texture, sampler s, float location, int offset) {
return Sample(texture, s, location, offset);
}
- float foo3(Texture1DArray<float> texture, sampler s, float x, float layer) {
+ test float foo3(Texture1DArray<float> texture, sampler s, float x, float layer) {
return Sample(texture, s, float2(x, layer));
}
- float foo4(Texture1DArray<float> texture, sampler s, float x, float layer, int offset) {
+ test float foo4(Texture1DArray<float> texture, sampler s, float x, float layer, int offset) {
return Sample(texture, s, float2(x, layer), offset);
}
- float foo5(Texture2D<float> texture, sampler s, float x, float y) {
+ test float foo5(Texture2D<float> texture, sampler s, float x, float y) {
return Sample(texture, s, float2(x, y));
}
- float foo6(Texture2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
+ test float foo6(Texture2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
return Sample(texture, s, float2(x, y), int2(offsetX, offsetY));
}
- float foo7(Texture2DArray<float> texture, sampler s, float x, float y, float layer) {
+ test float foo7(Texture2DArray<float> texture, sampler s, float x, float y, float layer) {
return Sample(texture, s, float3(x, y, layer));
}
- float foo8(Texture2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
+ test float foo8(Texture2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
return Sample(texture, s, float3(x, y, layer), int2(offsetX, offsetY));
}
- float foo9(Texture3D<float> texture, sampler s, float x, float y, float z) {
+ test float foo9(Texture3D<float> texture, sampler s, float x, float y, float z) {
return Sample(texture, s, float3(x, y, z));
}
- float foo10(Texture3D<float> texture, sampler s, float x, float y, float z, int offsetX, int offsetY, int offsetZ) {
+ test float foo10(Texture3D<float> texture, sampler s, float x, float y, float z, int offsetX, int offsetY, int offsetZ) {
return Sample(texture, s, float3(x, y, z), int3(offsetX, offsetY, offsetZ));
}
- float foo11(TextureCube<float> texture, sampler s, float x, float y, float z) {
+ test float foo11(TextureCube<float> texture, sampler s, float x, float y, float z) {
return Sample(texture, s, float3(x, y, z));
}
- float foo12(Texture2D<float> texture, sampler s, float x, float y, float Bias) {
+ test float foo12(Texture2D<float> texture, sampler s, float x, float y, float Bias) {
return SampleBias(texture, s, float2(x, y), Bias);
}
- float foo13(Texture2D<float> texture, sampler s, float x, float y, float Bias, int offsetX, int offsetY) {
+ test float foo13(Texture2D<float> texture, sampler s, float x, float y, float Bias, int offsetX, int offsetY) {
return SampleBias(texture, s, float2(x, y), Bias, int2(offsetX, offsetY));
}
- float foo14(Texture2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1) {
+ test float foo14(Texture2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1) {
return SampleGrad(texture, s, float2(x, y), float2(ddx0, ddx1), float2(ddy0, ddy1));
}
- float foo15(Texture2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
+ test float foo15(Texture2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
return SampleGrad(texture, s, float2(x, y), float2(ddx0, ddx1), float2(ddy0, ddy1), int2(offsetX, offsetY));
}
- float foo16(Texture2D<float> texture, sampler s, float x, float y, float LOD) {
+ test float foo16(Texture2D<float> texture, sampler s, float x, float y, float LOD) {
return SampleLevel(texture, s, float2(x, y), LOD);
}
- float foo17(Texture2D<float> texture, sampler s, float x, float y, float LOD, int offsetX, int offsetY) {
+ test float foo17(Texture2D<float> texture, sampler s, float x, float y, float LOD, int offsetX, int offsetY) {
return SampleLevel(texture, s, float2(x, y), LOD, int2(offsetX, offsetY));
}
- float foo18(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float Bias) {
+ test float foo18(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float Bias) {
return SampleBias(texture, s, float3(x, y, layer), Bias);
}
- float foo19(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float Bias, int offsetX, int offsetY) {
+ test float foo19(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float Bias, int offsetX, int offsetY) {
return SampleBias(texture, s, float3(x, y, layer), Bias, int2(offsetX, offsetY));
}
- float foo20(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1) {
+ test float foo20(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1) {
return SampleGrad(texture, s, float3(x, y, layer), float2(ddx0, ddx1), float2(ddy0, ddy1));
}
- float foo21(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
+ test float foo21(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
return SampleGrad(texture, s, float3(x, y, layer), float2(ddx0, ddx1), float2(ddy0, ddy1), int2(offsetX, offsetY));
}
- float foo22(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float LOD) {
+ test float foo22(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float LOD) {
return SampleLevel(texture, s, float3(x, y, layer), LOD);
}
- float foo23(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float LOD, int offsetX, int offsetY) {
+ test float foo23(Texture2DArray<float> texture, sampler s, float x, float y, float layer, float LOD, int offsetX, int offsetY) {
return SampleLevel(texture, s, float3(x, y, layer), LOD, int2(offsetX, offsetY));
}
- int foo24(Texture1D<int4> texture, sampler s, float location) {
+ test int foo24(Texture1D<int4> texture, sampler s, float location) {
return Sample(texture, s, location).x;
}
- int foo25(Texture1D<int4> texture, sampler s, float location) {
+ test int foo25(Texture1D<int4> texture, sampler s, float location) {
return Sample(texture, s, location).y;
}
- int foo26(Texture1D<int4> texture, sampler s, float location) {
+ test int foo26(Texture1D<int4> texture, sampler s, float location) {
return Sample(texture, s, location).z;
}
- int foo27(Texture1D<int4> texture, sampler s, float location) {
+ test int foo27(Texture1D<int4> texture, sampler s, float location) {
return Sample(texture, s, location).w;
}
- float foo28(TextureDepth2D<float> texture, sampler s, float x, float y) {
+ test float foo28(TextureDepth2D<float> texture, sampler s, float x, float y) {
return Sample(texture, s, float2(x, y));
}
- float foo29(TextureDepth2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
+ test float foo29(TextureDepth2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
return Sample(texture, s, float2(x, y), int2(offsetX, offsetY));
}
- float foo30(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer) {
+ test float foo30(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer) {
return Sample(texture, s, float3(x, y, layer));
}
- float foo31(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
+ test float foo31(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
return Sample(texture, s, float3(x, y, layer), int2(offsetX, offsetY));
}
- float foo32(TextureDepthCube<float> texture, sampler s, float x, float y, float z) {
+ test float foo32(TextureDepthCube<float> texture, sampler s, float x, float y, float z) {
return Sample(texture, s, float3(x, y, z));
}
- float foo33(TextureDepth2D<float> texture, sampler s, float x, float y, float Bias) {
+ test float foo33(TextureDepth2D<float> texture, sampler s, float x, float y, float Bias) {
return SampleBias(texture, s, float2(x, y), Bias);
}
- float foo34(TextureDepth2D<float> texture, sampler s, float x, float y, float Bias, int offsetX, int offsetY) {
+ test float foo34(TextureDepth2D<float> texture, sampler s, float x, float y, float Bias, int offsetX, int offsetY) {
return SampleBias(texture, s, float2(x, y), Bias, int2(offsetX, offsetY));
}
- float foo35(TextureDepth2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1) {
+ test float foo35(TextureDepth2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1) {
return SampleGrad(texture, s, float2(x, y), float2(ddx0, ddx1), float2(ddy0, ddy1));
}
- float foo36(TextureDepth2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
+ test float foo36(TextureDepth2D<float> texture, sampler s, float x, float y, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
return SampleGrad(texture, s, float2(x, y), float2(ddx0, ddx1), float2(ddy0, ddy1), int2(offsetX, offsetY));
}
- float foo37(TextureDepth2D<float> texture, sampler s, float x, float y, float LOD) {
+ test float foo37(TextureDepth2D<float> texture, sampler s, float x, float y, float LOD) {
return SampleLevel(texture, s, float2(x, y), LOD);
}
- float foo38(TextureDepth2D<float> texture, sampler s, float x, float y, float LOD, int offsetX, int offsetY) {
+ test float foo38(TextureDepth2D<float> texture, sampler s, float x, float y, float LOD, int offsetX, int offsetY) {
return SampleLevel(texture, s, float2(x, y), LOD, int2(offsetX, offsetY));
}
- float foo39(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float Bias) {
+ test float foo39(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float Bias) {
return SampleBias(texture, s, float3(x, y, layer), Bias);
}
- float foo40(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float Bias, int offsetX, int offsetY) {
+ test float foo40(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float Bias, int offsetX, int offsetY) {
return SampleBias(texture, s, float3(x, y, layer), Bias, int2(offsetX, offsetY));
}
- float foo41(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1) {
+ test float foo41(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1) {
return SampleGrad(texture, s, float3(x, y, layer), float2(ddx0, ddx1), float2(ddy0, ddy1));
}
- float foo42(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
+ test float foo42(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float ddx0, float ddx1, float ddy0, float ddy1, int offsetX, int offsetY) {
return SampleGrad(texture, s, float3(x, y, layer), float2(ddx0, ddx1), float2(ddy0, ddy1), int2(offsetX, offsetY));
}
- float foo43(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float LOD) {
+ test float foo43(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float LOD) {
return SampleLevel(texture, s, float3(x, y, layer), LOD);
}
- float foo44(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float LOD, int offsetX, int offsetY) {
+ test float foo44(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float LOD, int offsetX, int offsetY) {
return SampleLevel(texture, s, float3(x, y, layer), LOD, int2(offsetX, offsetY));
}
- float foo45(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
+ test float foo45(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
return SampleCmp(texture, s, float2(x, y), compareValue);
}
- float foo46(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
+ test float foo46(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
return SampleCmp(texture, s, float2(x, y), compareValue, int2(offsetX, offsetY));
}
- float foo47(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
+ test float foo47(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
return SampleCmp(texture, s, float3(x, y, layer), compareValue);
}
- float foo48(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
+ test float foo48(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
return SampleCmp(texture, s, float3(x, y, layer), compareValue, int2(offsetX, offsetY));
}
- float foo49(TextureCube<float> texture, sampler s, float x, float y, float z, float bias) {
+ test float foo49(TextureCube<float> texture, sampler s, float x, float y, float z, float bias) {
return SampleBias(texture, s, float3(x, y, z), bias);
}
- float foo50(TextureCube<float> texture, sampler s, float x, float y, float z, float ddx0, float ddx1, float ddx2, float ddy0, float ddy1, float ddy2) {
+ test float foo50(TextureCube<float> texture, sampler s, float x, float y, float z, float ddx0, float ddx1, float ddx2, float ddy0, float ddy1, float ddy2) {
return SampleGrad(texture, s, float3(x, y, z), float3(ddx0, ddx1, ddx2), float3(ddy0, ddy1, ddy2));
}
- float foo51(TextureCube<float> texture, sampler s, float x, float y, float z, float lod) {
+ test float foo51(TextureCube<float> texture, sampler s, float x, float y, float z, float lod) {
return SampleLevel(texture, s, float3(x, y, z), lod);
}
- float foo52(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float bias) {
+ test float foo52(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float bias) {
return SampleBias(texture, s, float3(x, y, z), bias);
}
- float foo53(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float ddx0, float ddx1, float ddx2, float ddy0, float ddy1, float ddy2) {
+ test float foo53(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float ddx0, float ddx1, float ddx2, float ddy0, float ddy1, float ddy2) {
return SampleGrad(texture, s, float3(x, y, z), float3(ddx0, ddx1, ddx2), float3(ddy0, ddy1, ddy2));
}
- float foo54(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float lod) {
+ test float foo54(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float lod) {
return SampleLevel(texture, s, float3(x, y, z), lod);
}
- float foo55(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
+ test float foo55(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
return SampleCmpLevelZero(texture, s, float2(x, y), compareValue);
}
- float foo56(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
+ test float foo56(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
return SampleCmpLevelZero(texture, s, float2(x, y), compareValue, int2(offsetX, offsetY));
}
- float foo57(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
+ test float foo57(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
return SampleCmpLevelZero(texture, s, float3(x, y, layer), compareValue);
}
- float foo58(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
+ test float foo58(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
return SampleCmpLevelZero(texture, s, float3(x, y, layer), compareValue, int2(offsetX, offsetY));
}
- float foo59(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float compareValue) {
+ test float foo59(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float compareValue) {
return SampleCmp(texture, s, float3(x, y, z), compareValue);
}
- float foo60(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float compareValue) {
+ test float foo60(TextureDepthCube<float> texture, sampler s, float x, float y, float z, float compareValue) {
return SampleCmpLevelZero(texture, s, float3(x, y, z), compareValue);
}
`);
tests.textureGather = function() {
let program = doPrep(`
- float4 foo1(Texture2D<float> texture, sampler s, float x, float y) {
+ test float4 foo1(Texture2D<float> texture, sampler s, float x, float y) {
return Gather(texture, s, float2(x, y));
}
- float4 foo2(Texture2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
+ test float4 foo2(Texture2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
return Gather(texture, s, float2(x, y), int2(offsetX, offsetY));
}
- float4 foo3(Texture2DArray<float> texture, sampler s, float x, float y, float layer) {
+ test float4 foo3(Texture2DArray<float> texture, sampler s, float x, float y, float layer) {
return Gather(texture, s, float3(x, y, layer));
}
- float4 foo4(Texture2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
+ test float4 foo4(Texture2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
return Gather(texture, s, float3(x, y, layer), int2(offsetX, offsetY));
}
- float4 foo5(TextureCube<float> texture, sampler s, float x, float y, float z) {
+ test float4 foo5(TextureCube<float> texture, sampler s, float x, float y, float z) {
return Gather(texture, s, float3(x, y, z));
}
- float4 foo6(TextureDepth2D<float> texture, sampler s, float x, float y) {
+ test float4 foo6(TextureDepth2D<float> texture, sampler s, float x, float y) {
return Gather(texture, s, float2(x, y));
}
- float4 foo7(TextureDepth2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
+ test float4 foo7(TextureDepth2D<float> texture, sampler s, float x, float y, int offsetX, int offsetY) {
return Gather(texture, s, float2(x, y), int2(offsetX, offsetY));
}
- float4 foo8(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer) {
+ test float4 foo8(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer) {
return Gather(texture, s, float3(x, y, layer));
}
- float4 foo9(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
+ test float4 foo9(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, int offsetX, int offsetY) {
return Gather(texture, s, float3(x, y, layer), int2(offsetX, offsetY));
}
- float4 foo10(TextureDepthCube<float> texture, sampler s, float x, float y, float z) {
+ test float4 foo10(TextureDepthCube<float> texture, sampler s, float x, float y, float z) {
return Gather(texture, s, float3(x, y, z));
}
- float4 foo11(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
+ test float4 foo11(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue) {
return GatherCmp(texture, s, float2(x, y), compareValue);
}
- float4 foo12(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
+ test float4 foo12(TextureDepth2D<float> texture, sampler s, float x, float y, float compareValue, int offsetX, int offsetY) {
return GatherCmp(texture, s, float2(x, y), compareValue, int2(offsetX, offsetY));
}
- float4 foo13(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
+ test float4 foo13(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue) {
return GatherCmp(texture, s, float3(x, y, layer), compareValue);
}
- float4 foo14(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
+ test float4 foo14(TextureDepth2DArray<float> texture, sampler s, float x, float y, float layer, float compareValue, int offsetX, int offsetY) {
return GatherCmp(texture, s, float3(x, y, layer), compareValue, int2(offsetX, offsetY));
}
`);
// FIXME: Gather other components
}
+
tests.commentParsing = function() {
let program = doPrep(`
/* this comment
runs over multiple lines */
- bool foo() { return true; }
+ test bool foo() { return true; }
`);
checkBool(program, callFunction(program, "foo", []), true);
tests.callArgumentsAreCopiedImmediatelyAfterEvaluation = () => {
let program = doPrep(`
- int foo()
+ test int foo()
{
return *bar(5) + *bar(7);
}