Skip to content

Commit 31a901e

Browse files
move PatternSet to build-support
1 parent 78024a6 commit 31a901e

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

Cakefile

+4-24
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ _ = require 'underscore'
77
CoffeeScript = require './lib/coffeescript'
88
helpers = require './lib/coffeescript/helpers'
99
{ setupConsole } = require './build-support/console'
10+
{ PatternSet } = require './build-support/patterns'
1011

1112
# ANSI Terminal Colors.
1213
bold = red = green = yellow = reset = ''
@@ -428,27 +429,6 @@ task 'bench', 'quick benchmark of compilation time', ->
428429
console.log "total #{ fmt total }"
429430

430431

431-
class PatternSet
432-
constructor: (patternStrings = [], {@negated = no} = {}) ->
433-
@matchers = (new RegExp p for p in patternStrings when p isnt '')
434-
435-
isEmpty: -> @matchers.length is 0
436-
437-
iterMatchers: -> @matchers[Symbol.iterator]()
438-
439-
test_: (arg) -> @iterMatchers().some (m) -> m.exec arg
440-
441-
allows: (arg) ->
442-
return yes if @isEmpty()
443-
if @negated
444-
not @test_ arg
445-
else
446-
@test_ arg
447-
448-
@fromCommaDelimitedList: (commaListStr) => new @ (commaListStr ? '').split /,/
449-
@empty: ({negated = no} = {}) => new @ [], {negated}
450-
451-
452432
# Run the CoffeeScript test suite.
453433
runTests = (CoffeeScript, {filePatterns, negFilePatterns, descPatterns, negDescPatterns} = {}) ->
454434
CoffeeScript.register() unless global.testingBrowser
@@ -457,7 +437,7 @@ runTests = (CoffeeScript, {filePatterns, negFilePatterns, descPatterns, negDescP
457437
negFilePatterns ?= PatternSet.empty {negated: yes}
458438
descPatterns ?= PatternSet.empty()
459439
negDescPatterns ?= PatternSet.empty {negated: yes}
460-
console.dir {filePatterns, negFilePatterns, descPatterns, negDescPatterns}
440+
console.dir.debug {filePatterns, negFilePatterns, descPatterns, negDescPatterns}
461441

462442
# These are attached to `global` so that they’re accessible from within
463443
# `test/async.coffee`, which has an async-capable version of
@@ -577,9 +557,9 @@ option null, '--negDesc [REGEXP*]', 'test description patterns to negatively mat
577557

578558
task 'test', 'run the CoffeeScript language test suite', ({
579559
file = [],
580-
negFile = ['sourcemap'],
560+
negFile = [],
581561
desc = [],
582-
negDesc = ['#4418', '#4558', 'dynamic import assertion', 'assert keyword'],
562+
negDesc = [],
583563
} = {}) ->
584564
testOptions =
585565
filePatterns: new PatternSet file

build-support/patterns.coffee

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
exports.PatternSet = class PatternSet
2+
constructor: (patternStrings = [], {@negated = no} = {}) ->
3+
@matchers = (new RegExp p for p in patternStrings when p isnt '')
4+
5+
isEmpty: -> @matchers.length is 0
6+
7+
iterMatchers: -> @matchers[Symbol.iterator]()
8+
9+
test_: (arg) -> @iterMatchers().some (m) -> m.exec arg
10+
11+
allows: (arg) ->
12+
return yes if @isEmpty()
13+
if @negated
14+
not @test_ arg
15+
else
16+
@test_ arg
17+
18+
@empty: ({negated = no} = {}) => new @ [], {negated}

0 commit comments

Comments
 (0)