WebKit Bugzilla
Attachment 349399 Details for
Bug 189502
: [WHLSL] Improve test suite type safety
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189502-20180911093008.patch (text/plain), 5.13 KB, created by
Thomas Denney
on 2018-09-11 09:30:09 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Thomas Denney
Created:
2018-09-11 09:30:09 PDT
Size:
5.13 KB
patch
obsolete
>Subversion Revision: 235894 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index e60abee4189f1442afc52c598099305a20175ed1..f980fcd92ffef0706b23e7bbefce210515f01b7d 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1 +1,19 @@ >+2018-09-11 Thomas Denney <tdenney@apple.com> >+ >+ [WHLSL] Improve test suite type safety >+ https://bugs.webkit.org/show_bug.cgi?id=189502 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Each of the 'makeT' functions now call the relevant cast function on the >+ value before hand. The checkNumber function has also been removed and >+ its uses have been replaced with functions that also check the type. >+ Finally, some of the arithmetic checks have been updated to reflect that >+ the casts happen outside of WHLSL evaluation. >+ >+ * WebGPUShadingLanguageRI/Casts.js: >+ (castToBool): Added. >+ * WebGPUShadingLanguageRI/Test.js: Updated makeT functions, tests that >+ used checkNumber, and the uchar arithmetic tests to reflect the casting. >+ > == Rolled over to ChangeLog-2018-09-11 == >diff --git a/Tools/WebGPUShadingLanguageRI/Casts.js b/Tools/WebGPUShadingLanguageRI/Casts.js >index acbb2ea028535b4670423097f7a5b57caf6b8b1c..fc37893c00fe0147e3da3a50c318672885777881 100644 >--- a/Tools/WebGPUShadingLanguageRI/Casts.js >+++ b/Tools/WebGPUShadingLanguageRI/Casts.js >@@ -39,6 +39,11 @@ function bitwiseCast(typedArrayConstructor1, typedArrayConstructor2, value) > return typedArray2[0]; > } > >+function castToBool(value) >+{ >+ return !!value; >+} >+ > function castToUchar(number) > { > return number & 0xFF; >diff --git a/Tools/WebGPUShadingLanguageRI/Test.js b/Tools/WebGPUShadingLanguageRI/Test.js >index 2bcea7d7da3cb382f1aabe2167ef3a7891392333..82fbed7db4f4f5cc5a1cf4bcd0041e399b6d91d4 100644 >--- a/Tools/WebGPUShadingLanguageRI/Test.js >+++ b/Tools/WebGPUShadingLanguageRI/Test.js >@@ -55,32 +55,32 @@ function doLex(code) > > function makeInt(program, value) > { >- return TypedValue.box(program.intrinsics.int, value); >+ return TypedValue.box(program.intrinsics.int, castToInt(value)); > } > > function makeUint(program, value) > { >- return TypedValue.box(program.intrinsics.uint, value); >+ return TypedValue.box(program.intrinsics.uint, castToUint(value)); > } > > function makeUchar(program, value) > { >- return TypedValue.box(program.intrinsics.uchar, value); >+ return TypedValue.box(program.intrinsics.uchar, castToUchar(value)); > } > > function makeBool(program, value) > { >- return TypedValue.box(program.intrinsics.bool, value); >+ return TypedValue.box(program.intrinsics.bool, castToBool(value)); > } > > function makeFloat(program, value) > { >- return TypedValue.box(program.intrinsics.float, value); >+ return TypedValue.box(program.intrinsics.float, castToFloat(value)); > } > > function makeHalf(program, value) > { >- return TypedValue.box(program.intrinsics.half, value); >+ return TypedValue.box(program.intrinsics.half, castToHalf(value)); > } > > function makeEnum(program, enumName, value) >@@ -221,19 +221,12 @@ function makeRW2DDepthTextureArray(program, array, elementType) > return TypedValue.box(program.intrinsics[`RWTextureDepth2DArray<${elementType}>`], new TextureDepth2DArrayRW(elementType, array)); > } > >-function checkNumber(program, result, expected) >-{ >- if (!result.type.unifyNode.isNumber) >- throw new Error("Wrong result type; result: " + result); >- if (result.value != expected) >- throw new Error("Wrong result: " + result.value + " (expected " + expected + ")"); >-} >- > function checkInt(program, result, expected) > { > if (!result.type.equals(program.intrinsics.int)) > throw new Error("Wrong result type; result: " + result); >- checkNumber(program, result, expected); >+ if (result.value != expected) >+ throw new Error(`Wrong result: ${result.value} (expected ${expected})`); > } > > function checkEnum(program, result, expected) >@@ -1039,13 +1032,13 @@ tests.passNullToPtrMonomorphicArrayRef = function() > tests.returnIntLiteralUint = function() > { > let program = doPrep("test uint foo() { return 42; }"); >- checkNumber(program, callFunction(program, "foo", []), 42); >+ checkUint(program, callFunction(program, "foo", []), 42); > } > > tests.returnIntLiteralFloat = function() > { > let program = doPrep("test float foo() { return 42; }"); >- checkNumber(program, callFunction(program, "foo", []), 42); >+ checkFloat(program, callFunction(program, "foo", []), 42); > } > > tests.badIntLiteralForInt = function() >@@ -2705,8 +2698,8 @@ tests.ucharRShift = function() > } > `); > checkUchar(program, callFunction(program, "foo", [makeUchar(program, 1), makeUint(program, 7)]), 0); >- checkUchar(program, callFunction(program, "foo", [makeUchar(program, 65535), makeUint(program, 2)]), 255); >- checkUchar(program, callFunction(program, "foo", [makeUchar(program, -1), makeUint(program, 5)]), 255); >+ checkUchar(program, callFunction(program, "foo", [makeUchar(program, 65535), makeUint(program, 2)]), 63); >+ checkUchar(program, callFunction(program, "foo", [makeUchar(program, -1), makeUint(program, 5)]), 7); > checkUchar(program, callFunction(program, "foo", [makeUchar(program, 0), makeUint(program, 3)]), 0); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189502
:
349399
|
349429
|
349456
|
350126