~ubuntu-branches/ubuntu/saucy/qtdeclarative-opensource-src/saucy

« back to all changes in this revision

Viewing changes to tests/auto/qml/parserstress/tests/ecma/String/15.5.1.js

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 14:17:19 UTC
  • Revision ID: package-import@ubuntu.com-20130205141719-qqeyml8wslpyez52
Tags: upstream-5.0.1
ImportĀ upstreamĀ versionĀ 5.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Mozilla Public License Version
 
6
 * 1.1 (the "License"); you may not use this file except in compliance with
 
7
 * the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/MPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is Mozilla Communicator client code, released
 
16
 * March 31, 1998.
 
17
 *
 
18
 * The Initial Developer of the Original Code is
 
19
 * Netscape Communications Corporation.
 
20
 * Portions created by the Initial Developer are Copyright (C) 1998
 
21
 * the Initial Developer. All Rights Reserved.
 
22
 *
 
23
 * Contributor(s):
 
24
 *
 
25
 * Alternatively, the contents of this file may be used under the terms of
 
26
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
27
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
28
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
29
 * of those above. If you wish to allow use of your version of this file only
 
30
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
31
 * use your version of this file under the terms of the MPL, indicate your
 
32
 * decision by deleting the provisions above and replace them with the notice
 
33
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
34
 * the provisions above, a recipient may use your version of this file under
 
35
 * the terms of any one of the MPL, the GPL or the LGPL.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
gTestfile = '15.5.1.js';
 
40
 
 
41
/**
 
42
   File Name:          15.5.1.js
 
43
   ECMA Section:       15.5.1 The String Constructor called as a Function
 
44
   15.5.1.1 String(value)
 
45
   15.5.1.2 String()
 
46
 
 
47
   Description: When String is called as a function rather than as
 
48
   a constructor, it performs a type conversion.
 
49
   - String(value) returns a string value (not a String
 
50
   object) computed by ToString(value)
 
51
   - String() returns the empty string ""
 
52
 
 
53
   Author:             christine@netscape.com
 
54
   Date:               1 october 1997
 
55
*/
 
56
 
 
57
var SECTION = "15.5.1";
 
58
var VERSION = "ECMA_1";
 
59
startTest();
 
60
var TITLE   = "The String Constructor Called as a Function";
 
61
 
 
62
writeHeaderToLog( SECTION + " "+ TITLE);
 
63
 
 
64
new TestCase( SECTION,  "String('string primitive')",   "string primitive",     String('string primitive') );
 
65
new TestCase( SECTION,  "String(void 0)",               "undefined",            String( void 0) );
 
66
new TestCase( SECTION,  "String(null)",                     "null",                     String( null ) );
 
67
new TestCase( SECTION,  "String(true)",                     "true",                     String( true) );
 
68
new TestCase( SECTION,  "String(false)",                    "false",            String( false ) );
 
69
new TestCase( SECTION,  "String(Boolean(true))",        "true",                 String(Boolean(true)) );
 
70
new TestCase( SECTION,  "String(Boolean(false))",       "false",                String(Boolean(false)) );
 
71
new TestCase( SECTION,  "String(Boolean())",            "false",                String(Boolean(false)) );
 
72
new TestCase( SECTION,  "String(new Array())",          "",                         String( new Array()) );
 
73
new TestCase( SECTION,  "String(new Array(1,2,3))",     "1,2,3",                String( new Array(1,2,3)) );
 
74
 
 
75
 
 
76
new TestCase( SECTION,    "String( Number.NaN )",       "NaN",                  String( Number.NaN ) );
 
77
new TestCase( SECTION,    "String( 0 )",                "0",                    String( 0 ) );
 
78
new TestCase( SECTION,    "String( -0 )",               "0",                   String( -0 ) );
 
79
new TestCase( SECTION,    "String( Number.POSITIVE_INFINITY )", "Infinity",     String( Number.POSITIVE_INFINITY ) );
 
80
new TestCase( SECTION,    "String( Number.NEGATIVE_INFINITY )", "-Infinity",    String( Number.NEGATIVE_INFINITY ) );
 
81
new TestCase( SECTION,    "String( -1 )",               "-1",                   String( -1 ) );
 
82
 
 
83
// cases in step 6:  integers  1e21 > x >= 1 or -1 >= x > -1e21
 
84
 
 
85
new TestCase( SECTION,    "String( 1 )",                    "1",                    String( 1 ) );
 
86
new TestCase( SECTION,    "String( 10 )",                   "10",                   String( 10 ) );
 
87
new TestCase( SECTION,    "String( 100 )",                  "100",                  String( 100 ) );
 
88
new TestCase( SECTION,    "String( 1000 )",                 "1000",                 String( 1000 ) );
 
89
new TestCase( SECTION,    "String( 10000 )",                "10000",                String( 10000 ) );
 
90
new TestCase( SECTION,    "String( 10000000000 )",          "10000000000",          String( 10000000000 ) );
 
91
new TestCase( SECTION,    "String( 10000000000000000000 )", "10000000000000000000", String( 10000000000000000000 ) );
 
92
new TestCase( SECTION,    "String( 100000000000000000000 )","100000000000000000000",String( 100000000000000000000 ) );
 
93
 
 
94
new TestCase( SECTION,    "String( 12345 )",                    "12345",                    String( 12345 ) );
 
95
new TestCase( SECTION,    "String( 1234567890 )",               "1234567890",               String( 1234567890 ) );
 
96
 
 
97
new TestCase( SECTION,    "String( -1 )",                       "-1",                       String( -1 ) );
 
98
new TestCase( SECTION,    "String( -10 )",                      "-10",                      String( -10 ) );
 
99
new TestCase( SECTION,    "String( -100 )",                     "-100",                     String( -100 ) );
 
100
new TestCase( SECTION,    "String( -1000 )",                    "-1000",                    String( -1000 ) );
 
101
new TestCase( SECTION,    "String( -1000000000 )",              "-1000000000",              String( -1000000000 ) );
 
102
new TestCase( SECTION,    "String( -1000000000000000 )",        "-1000000000000000",        String( -1000000000000000 ) );
 
103
new TestCase( SECTION,    "String( -100000000000000000000 )",   "-100000000000000000000",   String( -100000000000000000000 ) );
 
104
new TestCase( SECTION,    "String( -1000000000000000000000 )",  "-1e+21",                   String( -1000000000000000000000 ) );
 
105
 
 
106
new TestCase( SECTION,    "String( -12345 )",                    "-12345",                  String( -12345 ) );
 
107
new TestCase( SECTION,    "String( -1234567890 )",               "-1234567890",             String( -1234567890 ) );
 
108
 
 
109
// cases in step 7: numbers with a fractional component, 1e21> x >1 or  -1 > x > -1e21,
 
110
new TestCase( SECTION,    "String( 1.0000001 )",                "1.0000001",                String( 1.0000001 ) );
 
111
 
 
112
 
 
113
// cases in step 8:  fractions between 1 > x > -1, exclusive of 0 and -0
 
114
 
 
115
// cases in step 9:  numbers with 1 significant digit >= 1e+21 or <= 1e-6
 
116
 
 
117
new TestCase( SECTION,    "String( 1000000000000000000000 )",   "1e+21",             String( 1000000000000000000000 ) );
 
118
new TestCase( SECTION,    "String( 10000000000000000000000 )",   "1e+22",            String( 10000000000000000000000 ) );
 
119
 
 
120
//  cases in step 10:  numbers with more than 1 significant digit >= 1e+21 or <= 1e-6
 
121
new TestCase( SECTION,    "String( 1.2345 )",                    "1.2345",                  String( 1.2345));
 
122
new TestCase( SECTION,    "String( 1.234567890 )",               "1.23456789",             String( 1.234567890 ));
 
123
 
 
124
new TestCase( SECTION,    "String( .12345 )",                   "0.12345",               String(.12345 )     );
 
125
new TestCase( SECTION,    "String( .012345 )",                  "0.012345",              String(.012345)     );
 
126
new TestCase( SECTION,    "String( .0012345 )",                 "0.0012345",             String(.0012345)    );
 
127
new TestCase( SECTION,    "String( .00012345 )",                "0.00012345",            String(.00012345)   );
 
128
new TestCase( SECTION,    "String( .000012345 )",               "0.000012345",           String(.000012345)  );
 
129
new TestCase( SECTION,    "String( .0000012345 )",              "0.0000012345",          String(.0000012345) );
 
130
new TestCase( SECTION,    "String( .00000012345 )",             "1.2345e-7",            String(.00000012345));
 
131
 
 
132
new TestCase( "15.5.2", "String()",                             "",                         String() );
 
133
 
 
134
test();