Skip to content

Commit

Permalink
make sure we can detect hashtags at the end of the line
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpizz committed Apr 2, 2012
1 parent a3ddad5 commit 79d4cab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hashmonitor.coffee
Expand Up @@ -2,7 +2,7 @@

Distribution = require('./stats').Distribution

HASHTAG_REGEX = /\#([a-zA-Z][\w\d_]+)(?:(?:[\s$]+)|\=(\-?\d+(?:\.\d+)?))/g
HASHTAG_REGEX = /\#([a-zA-Z][\w\d_]+)(?:(?:\s+|$)|\=(\-?\d+(?:\.\d+)?))/g

class HashMonitor

Expand Down
18 changes: 18 additions & 0 deletions test/test-hashmonitor.coffee
Expand Up @@ -86,6 +86,24 @@ exports["Invalid hashtags are skipped"] = (assert, done) ->

done()

exports["Can detect hashtags at the end of the line"] = (assert, done) ->

# Parse a bunch of lines.
monitor = new HashMonitor()
monitor.parse("zippy #foo")
monitor.parse("fuzzy #foo")

# Since the monitor runs asynchronously, we wait for the next event tick
# to see the results.
process.nextTick ->

stats = monitor.calculate()

assert.equals(stats.foo?, true, "expected to have metrics for #foo")
assert.equals(stats.foo.count, 2)

done()

# Map CommonJS async test functions to the signature required by nodeunit.
maptest = (description) ->
cjstest = exports[description]
Expand Down

0 comments on commit 79d4cab

Please sign in to comment.