tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

escaped-syntax-characters-simple.js (1689B)


      1 // Copyright (C) 2024 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-regexp.escape
      6 description: Escaped characters (simple assertions)
      7 info: |
      8  RegExp.escape ( string )
      9 
     10  This method produces a new string in which certain characters have been escaped.
     11  These characters are: . * + ? ^ $ | ( ) [ ] { } \
     12 
     13 features: [RegExp.escape]
     14 ---*/
     15 
     16 assert.sameValue(RegExp.escape('.'), '\\.', 'dot character is escaped correctly');
     17 assert.sameValue(RegExp.escape('*'), '\\*', 'asterisk character is escaped correctly');
     18 assert.sameValue(RegExp.escape('+'), '\\+', 'plus character is escaped correctly');
     19 assert.sameValue(RegExp.escape('?'), '\\?', 'question mark character is escaped correctly');
     20 assert.sameValue(RegExp.escape('^'), '\\^', 'caret character is escaped correctly');
     21 assert.sameValue(RegExp.escape('$'), '\\$', 'dollar character is escaped correctly');
     22 assert.sameValue(RegExp.escape('|'), '\\|', 'pipe character is escaped correctly');
     23 assert.sameValue(RegExp.escape('('), '\\(', 'open parenthesis character is escaped correctly');
     24 assert.sameValue(RegExp.escape(')'), '\\)', 'close parenthesis character is escaped correctly');
     25 assert.sameValue(RegExp.escape('['), '\\[', 'open bracket character is escaped correctly');
     26 assert.sameValue(RegExp.escape(']'), '\\]', 'close bracket character is escaped correctly');
     27 assert.sameValue(RegExp.escape('{'), '\\{', 'open brace character is escaped correctly');
     28 assert.sameValue(RegExp.escape('}'), '\\}', 'close brace character is escaped correctly');
     29 assert.sameValue(RegExp.escape('\\'), '\\\\', 'backslash character is escaped correctly');
     30 
     31 reportCompare(0, 0);