Closed
Bug 880568
Opened 10 years ago
Closed 10 years ago
_do_check_eq/_do_check_neq/do_print should put double-quotes around argument if the typeof argument is "string"
Categories
(Testing :: XPCShell Harness, defect)
Testing
XPCShell Harness
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla24
People
(Reporter: jaws, Assigned: jaws)
Details
Attachments
(2 files)
914 bytes,
patch
|
ted
:
review+
|
Details | Diff | Splinter Review |
2.22 KB,
patch
|
ted
:
review+
|
Details | Diff | Splinter Review |
When do_print is used and a string argument is passed to it, the output should be surrounded by double-quotes. I ran into this today, where I had a string with the value "null". do_print outputted: null However my tests for variable == null were failing, because variable was actually equal to "null". Quotes around the output would have helped me fix the test faster.
Assignee | ||
Comment 1•10 years ago
|
||
We could do the same thing for _do_check_eq, but I'm not sure if that will confuse people or not.
Assignee | ||
Comment 2•10 years ago
|
||
... and here's a second patch that also includes changes to do_check_eq and do_check_neq for consistency. I also noticed that there is some duplicate code between _do_check_neq and do_report_result. I'll file a separate bug to clean that up.
Attachment #759589 -
Flags: review?(ted)
Assignee | ||
Comment 3•10 years ago
|
||
Filed bug 880573 for the de-duplication.
Updated•10 years ago
|
Attachment #759585 -
Flags: review?(ted) → review+
Comment 4•10 years ago
|
||
Comment on attachment 759589 [details] [diff] [review] Patch including changes to do_check_eq and do_check_neq Review of attachment 759589 [details] [diff] [review]: ----------------------------------------------------------------- ::: testing/xpcshell/head.js @@ +399,5 @@ > * Prints a message to the output log. > */ > function do_print(msg) { > var caller_stack = Components.stack.caller; > + msg = typeof msg == "string" ? '"' + msg + '"' : msg; Feels like you probably want to put this into a helper function at this point, but it's not critical.
Attachment #759589 -
Flags: review?(ted) → review+
Assignee | ||
Comment 5•10 years ago
|
||
Thanks! I pulled that out to this function... function _wrap_with_quotes_if_necessary(val) { return typeof val == "string" ? '"' + val + '"' : val; } https://hg.mozilla.org/integration/mozilla-inbound/rev/606e6dbf61e1
Summary: do_print should put double-quotes around output if the typeof argument is "string" → _do_check_eq/_do_check_neq/do_print should put double-quotes around argument if the typeof argument is "string"
Comment 6•10 years ago
|
||
Hmm, we're using == and != for these things? I filed bug 880798 to switch from == to SameValue-style comparisons (see the bug for a description of SameValue semantics).
Comment 7•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/606e6dbf61e1
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in
before you can comment on or make changes to this bug.
Description
•