Bug 146103 - Refactor CheckedArithmeticOperations.cpp to use templates instead of macros
Summary: Refactor CheckedArithmeticOperations.cpp to use templates instead of macros
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-18 01:43 PDT by Mark Lam
Modified: 2015-06-18 11:10 PDT (History)
2 users (show)

See Also:


Attachments
patch for review. (6.50 KB, patch)
2015-06-18 01:51 PDT, Mark Lam
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.