Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Issue 6904047: Test to ensure .call on native functions work correctly when passed (Closed)

Created:
9 years, 8 months ago by Rico
Modified:
9 years, 6 months ago
Reviewers:
Lasse Reichstein, MarkM
CC:
v8-dev, Mads Ager (chromium)
Visibility:
Public.

Description

Test to ensure .call on native functions work correctly when passed null or undefined. This does NOT include the changes needed to make this pass, but I wanted to agree on this before I do the implementation. Passing this test should ensure that we can close 981 and 1321.

Patch Set 1 #

Total comments: 10

Patch Set 2 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+298 lines, -0 lines) Patch
A test/mjsunit/function-call.js View 1 1 chunk +298 lines, -0 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Rico
Lasse: Could you double check my spec readings. Mark: Feel free to give input.
9 years, 8 months ago (2011-04-27 10:36:31 UTC) #1
Lasse Reichstein
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js File test/mjsunit/function-call.js (right): http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#newcode1 test/mjsunit/function-call.js:1: // Copyright 2011 the V8 project authors. All rights ...
9 years, 8 months ago (2011-04-27 11:26:50 UTC) #2
Rico
Addressed comments http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js File test/mjsunit/function-call.js (right): http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#newcode1 test/mjsunit/function-call.js:1: // Copyright 2011 the V8 project authors. ...
9 years, 8 months ago (2011-04-27 13:17:54 UTC) #3
Rico
9 years, 8 months ago (2011-04-28 05:59:10 UTC) #4
On 2011/04/27 13:17:54, Rico wrote:
> Addressed comments
> 
> http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js
> File test/mjsunit/function-call.js (right):
> 
>
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#n...
> test/mjsunit/function-call.js:1: // Copyright 2011 the V8 project authors. All
> rights reserved.
> On 2011/04/27 11:26:50, Lasse Reichstein wrote:
> > Put this file into mjsunit/bugs/bug-<bugnumber>.js
> > Then move it to regress when we fix the problem.
> I will implement this NOW.
> 
>
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#n...
> test/mjsunit/function-call.js:30: ['Object.prototype.toLocaleString',
> On 2011/04/27 11:26:50, Lasse Reichstein wrote:
> > Just make this an array of the functions, not strings. I.e., remove the
> quotes.
> 
> Done.
> 
>
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#n...
> test/mjsunit/function-call.js:37: 'Function.prototype.toString',
> On 2011/04/27 11:26:50, Lasse Reichstein wrote:
> > Function.prototype.{call,apply,bind} also throw on more than just null and
> > undefined. Either include them all, or drop toString - it's not ToObject
> that's
> > the cause of the throwing, and the exception message is likely to be
> different.
> > Ditto for other non-generic functions (e.g. String.prototype.toString).
> As discussed offline I am adding these to a different test (but still passing
in
> undefined and null) to actually test that they do not misbehave when null and
> undefined can be passed in as this (which could never happen before)
> 
>
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#n...
> test/mjsunit/function-call.js:143: 'RegExp.prototype.toString',
> On 2011/04/27 11:26:50, Lasse Reichstein wrote:
> > All Number, Date and RegExp methods are non-generic, and fails on everything
> > that's not a Number object or value, a Date object or a RegExp object,
> > respectively.
> > It's not about being null or undefined, and it's impossible to tell whether
> the
> > TypeError is thrown because the thisValue is null/undefined or it's the
Global
> > object.
> > I.e., the test doesn't  really test what it's supposed to.
> > This is a general problem for all non-generic methods. I.e., restrict the
test
> > to only those that use ToObject or CheckObjectCoercible on this.
> Again, I will still test this since the change to call will enable
functionality
> that was not possible before.
> 
>
http://codereview.chromium.org/6904047/diff/1/test/mjsunit/function-call.js#n...
> test/mjsunit/function-call.js:153: eval(should_throw_on_null_and_undefined[i]
+
> '.call(null)');
> On 2011/04/27 11:26:50, Lasse Reichstein wrote:
> > Check both .call and .apply.
> > Also consider checking functions that take a callback function and thisArg
> (e.g.
> > Array.prototype.{every,some,forEach.map,filter}, and those taking a callback
> and
> > always passing undefined as this (Array.prototype.{reduce,reduceRight}).
> > String.prototype.replace doesn't specify which "this" object it passes.
> 
> Done.
I am closing this, created http://codereview.chromium.org/6902104/ with actual
addition of checks for null and undefined in native functions.

Powered by Google App Engine
This is Rietveld 408576698