1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00
jashkenas--coffeescript/test/test_regexps.coffee

46 lines
656 B
CoffeeScript
Raw Normal View History

# Regular expression literals.
ok 'x'.match(/x/g)
ok 'x'.match /x/g
ok 'x'.match(/x/)
ok 'x'.match /x/
ok 4 / 2 / 1 is 2
2010-07-25 01:23:37 -04:00
y = 4
x = 2
g = 1
ok y / x/g is 2
2010-07-25 01:23:37 -04:00
obj = {
width: -> 10
height: -> 20
}
2010-07-25 01:23:37 -04:00
id = 2
ok (obj.width()/id - obj.height()/id) is -5
2010-10-03 19:22:42 -04:00
eq /\\/.source, "\\\\"
eq /^I'm\s+Heregex?\/\/\//gim + '', ///
^ I'm \s+ Heregex? / // # or not
2010-10-03 19:22:42 -04:00
///gim + ''
eq '\\\\#{}\\\\\\\"', ///
2010-10-03 19:22:42 -04:00
#{
"#{ '\\' }" # normal comment
2010-10-03 19:22:42 -04:00
}
# regex comment
2010-10-03 19:22:42 -04:00
\#{}
\\ \"
2010-10-03 19:22:42 -04:00
///.source
eq /// /// + '', '/(?:)/'
2010-10-05 00:16:55 -04:00
#584: Unescaped slashes in character classes.
ok /:\/[/]goog/.test 'http://google.com'
#764: Should be indexable.
eq /0/['source'], ///#{0}///['source']