File: regex.ls

package info (click to toggle)
node-livescript 1.5.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 636 kB
  • ctags: 25
  • sloc: makefile: 44; sh: 2
file content (99 lines) | stat: -rw-r--r-- 1,674 bytes parent folder | download
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
ok /x/.test 'x'
ok 'x'.match /x/
eq /\\/ + '', '/\\\\/'
eq /^/.source, '^'


# Should not be mixed-up with the division operator.
g = h = i = 2

eq g / h / i, 2 / 2 / 2

eq g/h/i, 2/2/2

eq [g][0]/h/i, (2)/2/2

eq 2, g /= h / i

eq \=, /=/. source
eq ' ' (/ /)source


compileThrows 'unterminated regex' 1 '/1'


# Should be cached aptly.
eq 0 (/_/ <<< {0}).0


# Should accuse duplicate flag.
compileThrows 'duplicate regex flag `g`' 1 '/^/gg'


# Should be ASI safe.
/ /
[0][0]


# ACI interaction
eq \/1/ '0'.replace //#{0}// ''+/1/ \g


# ADI interaction
eq true, /a/itest \A


### Heregex
eq /^I'm\s+Heregex?\/\//gim + '', //
  ^ I'm \s+ Heregex? / / # or not
//gim + ''

eq '\\\\#{}\\\\\\\"', //
 #{
   "#{ '\\' }" # normal comment
 }
 # regex comment
 \#{}
 \\ \"
//.source

# [coffee#3059](https://github.com/jashkenas/coffee-script/pull/3059)
# Keep escaped whitespaces.
ok  //^
  a \ b \ c \
  d
$//test 'a b\u3000c\nd'

eq '(?:)' ////source

eq // _ #{if 1 then \g else \m}//? + '', '/_/g'

eq /\//source, //\///source

# Should work nested.
eq \01234 // 0 #{
  // 1 #{ //2//source } 3 //source
} 4 //source

let this = \THIS
  ok //^ \\##@#this $//test //\#THISTHIS//source


# [coffee#584](https://github.com/jashkenas/coffee-script/issues/584)
# Unescaped slashes in character classes.
ok /:\/[/]goog/.test 'http://google.com'


# [coffee#764](https://github.com/jashkenas/coffee-script/issues/764)
# Should be indexable.
eq /0/['source'], //#{0}//['source']


### $ flag
eq \string typeof /^$/$
eq \string typeof //^$//$
eq \string typeof //^#{''}$//$

eq      /\\\//$      /\\\//source
eq    //\\\///$    //\\\///source
eq //#{\\}\///$ //#{\\}\///source