js/src/tests/ecma_5/RegExp/regexp-space-character-class.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 var gTestfile = 'regexp-space-character-class.js';
michael@0 7 //-----------------------------------------------------------------------------
michael@0 8 var BUGNUMBER = 514808;
michael@0 9 var summary = 'Correct space character class in regexes';
michael@0 10 var actual = '';
michael@0 11 var expect = '';
michael@0 12
michael@0 13
michael@0 14 //-----------------------------------------------------------------------------
michael@0 15 test();
michael@0 16 //-----------------------------------------------------------------------------
michael@0 17
michael@0 18 function test()
michael@0 19 {
michael@0 20 enterFunc ('test');
michael@0 21 printBugNumber(BUGNUMBER);
michael@0 22 printStatus (summary);
michael@0 23
michael@0 24 var spaces = [ "\u0009", "\u000b", "\u000c", "\u0020", "\u00a0", "\u1680",
michael@0 25 "\u180e", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004",
michael@0 26 "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200a",
michael@0 27 "\u202f", "\u205f", "\u3000", "\ufeff" ];
michael@0 28 var line_terminators = [ "\u2028", "\u2029", "\u000a", "\u000d" ];
michael@0 29 var space_chars = [].concat(spaces, line_terminators);
michael@0 30
michael@0 31 var non_space_chars = [ "\u200b", "\u200c", "\u200d" ];
michael@0 32
michael@0 33 var chars = [].concat(space_chars, non_space_chars);
michael@0 34 var is_space = [].concat(space_chars.map(function(ch) { return true; }),
michael@0 35 non_space_chars.map(function(ch) { return false; }));
michael@0 36 var expect = is_space.join(',');
michael@0 37
michael@0 38 var actual = chars.map(function(ch) { return /\s/.test(ch); }).join(',');
michael@0 39 reportCompare(expect, actual, summary);
michael@0 40
michael@0 41 jit(true);
michael@0 42 var actual = chars.map(function(ch) { return /\s/.test(ch); }).join(',');
michael@0 43 reportCompare(expect, actual, summary);
michael@0 44 jit(false);
michael@0 45
michael@0 46 exitFunc ('test');
michael@0 47 }

mercurial