File: properties-001.js

package info (click to toggle)
qtwebkit-opensource-src 5.3.2%2Bdfsg-2~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 291,472 kB
  • sloc: cpp: 1,358,084; python: 70,286; ansic: 42,964; perl: 35,474; ruby: 12,229; objc: 9,465; xml: 8,396; asm: 3,866; yacc: 2,397; sh: 1,647; makefile: 644; lex: 644; java: 110
file content (85 lines) | stat: -rw-r--r-- 2,847 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 *  File Name:          RegExp/properties-001.js
 *  ECMA Section:       15.7.6.js
 *  Description:        Based on ECMA 2 Draft 7 February 1999
 *
 *  Author:             christine@netscape.com
 *  Date:               19 February 1999
 */
    var SECTION = "RegExp/properties-001.js";
    var VERSION = "ECMA_2";
    var TITLE   = "Properties of RegExp Instances";
    var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346000";

    startTest();

    AddRegExpCases( new RegExp, "",   false, false, false, 0 );
    AddRegExpCases( /.*/,       ".*", false, false, false, 0 );
    AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 );
    AddRegExpCases( /[\S]?$/i,  "[\\S]?$", false, true, false, 0 );
    AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m,  "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 );
    AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi,      "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 );
    AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 );
    AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 );

    AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 );
    AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 );
    AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 );

    test();

function AddRegExpCases( re, s, g, i, m, l ) {

    AddTestCase( re + ".test == RegExp.prototype.test",
                 true,
                 re.test == RegExp.prototype.test );

    AddTestCase( re + ".toString == RegExp.prototype.toString",
                 true,
                 re.toString == RegExp.prototype.toString );

    AddTestCase( re + ".contructor == RegExp.prototype.constructor",
                 true,
                 re.constructor == RegExp.prototype.constructor );

    AddTestCase( re + ".compile == RegExp.prototype.compile",
                 true,
                 re.compile == RegExp.prototype.compile );

    AddTestCase( re + ".exec == RegExp.prototype.exec",
                 true,
                 re.exec == RegExp.prototype.exec );

    // properties

/*
 * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed
 * the behavior of toString() and toSource() on empty regexps.
 * So branch if |s| is the empty string -
 */
    var S = s? s : '(?:)';

    AddTestCase( re + ".source",
                 S,
                 re.source );

    AddTestCase( re + ".toString()",
                 "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""),
                 re.toString() );

    AddTestCase( re + ".global",
                 g,
                 re.global );

    AddTestCase( re + ".ignoreCase",
                 i,
                 re.ignoreCase );

    AddTestCase( re + ".multiline",
                 m,
                 re.multiline);

    AddTestCase( re + ".lastIndex",
                 l,
                 re.lastIndex  );
}