js/src/tests/js1_6/String/regress-306591.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_6/String/regress-306591.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,76 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +//-----------------------------------------------------------------------------
    1.10 +var BUGNUMBER = 306591;
    1.11 +var summary = 'String static methods';
    1.12 +var actual = '';
    1.13 +var expect = '';
    1.14 +
    1.15 +printBugNumber(BUGNUMBER);
    1.16 +printStatus (summary);
    1.17 +printStatus ('See https://bugzilla.mozilla.org/show_bug.cgi?id=304828');
    1.18 + 
    1.19 +expect = ['a', 'b', 'c'].toString();
    1.20 +actual = String.split(new String('abc'), '').toString();
    1.21 +reportCompare(expect, actual, summary +
    1.22 +              " String.split(new String('abc'), '')");
    1.23 +
    1.24 +expect = '2';
    1.25 +actual = String.substring(new Number(123), 1, 2);
    1.26 +reportCompare(expect, actual, summary +
    1.27 +              " String.substring(new Number(123), 1, 2)");
    1.28 +
    1.29 +expect = 'TRUE';
    1.30 +actual = String.toUpperCase(new Boolean(true)); 
    1.31 +reportCompare(expect, actual, summary +
    1.32 +              " String.toUpperCase(new Boolean(true))");
    1.33 +
    1.34 +try
    1.35 +{
    1.36 +  String.indexOf(null, 'l');
    1.37 +  throw new Error("should have thrown a TypeError");
    1.38 +}
    1.39 +catch (e)
    1.40 +{
    1.41 +  assertEq(e instanceof TypeError, true,
    1.42 +           "String.indexOf(null [, ...]) didn't work correctly");
    1.43 +}
    1.44 +
    1.45 +expect = 2;
    1.46 +actual = String.indexOf(String(null), 'l');             
    1.47 +reportCompare(expect, actual, summary +
    1.48 +              " String.indexOf(String(null), 'l')");
    1.49 +
    1.50 +expect = ['a', 'b', 'c'].toString();
    1.51 +actual = String.split('abc', '').toString();
    1.52 +reportCompare(expect, actual, summary +
    1.53 +              " String.split('abc', '')");
    1.54 +
    1.55 +expect = '2';
    1.56 +actual = String.substring(123, 1, 2);
    1.57 +reportCompare(expect, actual, summary +
    1.58 +              " String.substring(123, 1, 2)");
    1.59 +
    1.60 +expect = 'TRUE';
    1.61 +actual = String.toUpperCase(true);
    1.62 +reportCompare(expect, actual, summary +
    1.63 +              " String.toUpperCase(true)");
    1.64 +
    1.65 +try
    1.66 +{
    1.67 +  String.indexOf(undefined, 'd');
    1.68 +  throw new Error("should have thrown a TypeError");
    1.69 +}
    1.70 +catch (e)
    1.71 +{
    1.72 +  assertEq(e instanceof TypeError, true,
    1.73 +           "String.indexOf(undefined [, ...]) didn't work correctly");
    1.74 +}
    1.75 +
    1.76 +expect = 2;
    1.77 +actual = String.indexOf(String(undefined), 'd');
    1.78 +reportCompare(expect, actual, summary +
    1.79 +              " String.indexOf(String(undefined), 'd')");

mercurial