Sha256: 46b57e3c43bac2ae20381013e86eb7ca09ee2b6636bf054583b23391af7461e4

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

# Regular Expression Literals
# ---------------------------

# TODO: add method invocation tests: /regex/.toString()

# * Regexen
# * Heregexen

test "basic regular expression literals", ->
  ok 'a'.match(/a/)
  ok 'a'.match /a/
  ok 'a'.match(/a/g)
  ok 'a'.match /a/g

test "division is not confused for a regular expression", ->
  eq 2, 4 / 2 / 1

  a = 4
  b = 2
  g = 1
  eq 2, a / b/g

  a = 10
  b = a /= 4 / 2
  eq a, 5

  obj = method: -> 2
  two = 2
  eq 2, (obj.method()/two + obj.method()/two)

  i = 1
  eq 2, (4)/2/i
  eq 1, i/i/i

test "#764: regular expressions should be indexable", ->
  eq /0/['source'], ///#{0}///['source']

test "#584: slashes are allowed unescaped in character classes", ->
  ok /^a\/[/]b$/.test 'a//b'

test "#1724: regular expressions beginning with `*`", ->
  throws -> CoffeeScript.compile '/*/'


# Heregexe(n|s)

test "a heregex will ignore whitespace and comments", ->
  eq /^I'm\x20+[a]\s+Heregex?\/\/\//gim + '', ///
    ^ I'm \x20+ [a] \s+
    Heregex? / // # or not
  ///gim + ''

test "an empty heregex will compile to an empty, non-capturing group", ->
  eq /(?:)/ + '', ///  /// + ''

test "#1724: regular expressions beginning with `*`", ->
  throws -> CoffeeScript.compile '/// * ///'

test "empty regular expressions with flags", ->
  fn = (x) -> x
  a = "" + //i
  fn ""
  eq '/(?:)/i', a

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
guard-mthaml-0.4.0 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.3.1 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.3.0 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.5 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.4 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.3 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.2 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.1 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.2.0 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee
guard-mthaml-0.1.0 vendor/coffeescript/coffeescript/tests/cases/regexps.coffee