Bug 146103

Summary: Refactor CheckedArithmeticOperations.cpp to use templates instead of macros
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: Tools / TestsAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, oliver
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch for review. andersca: review+

Description Mark Lam 2015-06-18 01:43:58 PDT
Presently, the tests in CheckedArithmeticOperations.cpp are all implemented as part of a large macro.  This makes them harder to:
1. write: no editor help with indentations, have to add trailing '\'s, inconvenient to add line breaks and comments.
2. read: no chroma coding / syntax highlighting
3. debug: compile time errors are reported as being on the single line where the macro is used.

Refactoring the tests to use C++ templates solves all these issues.
Comment 1 Mark Lam 2015-06-18 01:51:04 PDT
Created attachment 255102 [details]
patch for review.

Note: this patch contains unwanted artifacts that left in for the sole purpose of minimizing the diff so that the patch will be easier to review.  The artifacts are documented in with comments in the patch, and will be removed before landing.
Comment 2 Basile Clement 2015-06-18 10:51:52 PDT
Comment on attachment 255102 [details]
patch for review.

View in context: https://bugs.webkit.org/attachment.cgi?id=255102&action=review

Not a reviewer, but I think Coerser should be Coercer throughout the patch.

> Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:36
> +        CheckedArithmeticTester<type, CoercerType, MixedSignednessTesterType>(); \

Shouldn't this be CheckedArithmeticTester<type, CoercerType, MixedSignednessTesterType>::run() ?
Comment 3 Mark Lam 2015-06-18 11:02:11 PDT
(In reply to comment #2)
> Comment on attachment 255102 [details]
> patch for review.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=255102&action=review
> 
> Not a reviewer, but I think Coerser should be Coercer throughout the patch.
> 
> > Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:36
> > +        CheckedArithmeticTester<type, CoercerType, MixedSignednessTesterType>(); \
> 
> Shouldn't this be CheckedArithmeticTester<type, CoercerType,
> MixedSignednessTesterType>::run() ?

Eek, you are right.  Fixing immediately.
Comment 4 Mark Lam 2015-06-18 11:10:00 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > Shouldn't this be CheckedArithmeticTester<type, CoercerType,
> > MixedSignednessTesterType>::run() ?
> 
> Eek, you are right.  Fixing immediately.

For the record, I had tested it with CheckedArithmeticTester<type, CoercerType, MixedSignednessTesterType>::run().  However, I had tried to change the patch to use a function template instead of a class template (hence the error you saw), but that turned out to be less readable.  So, I changed it back, but missed that one line.  It is not fixed.

Patch landed in r185708: <http://trac.webkit.org/r185708>.
Followup fix landed in r185711: <http://trac.webkit.org/r185711>.
Comment 5 Mark Lam 2015-06-18 11:10:51 PDT
(In reply to comment #4)
> changed it back, but missed that one line.  It is not fixed.

typo: I meant it is *now* fixed.