Permalink
Browse files

fix the bug of counting wrong due to object

  • Loading branch information...
1 parent 655fcce commit 58be60bf7ca455d8a5fe9b9db83bfd0243ab897e @jiyinyiyong committed Aug 4, 2013
Showing with 14 additions and 4 deletions.
  1. +1 −1 package.json
  2. +1 −1 pattern.coffee
  3. +1 −1 pattern.js
  4. +11 −1 test.Spec.coffee
View
@@ -1,6 +1,6 @@
{
"name": "coffee-pattern",
- "version": "0.0.5",
+ "version": "0.0.6",
"description": "coffee-pattern: write pattern matching in CoffeeScript syntax",
"main": "pattern.js",
"scripts": {
View
@@ -11,7 +11,7 @@ divide_list = (stack, long_list) ->
stack.push
pattern: key
result: long_list[0][key]
- divide_list stack, long_list[keys.length..]
+ divide_list stack, long_list[1..]
else
stack.push
pattern: long_list[0]
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -90,4 +90,14 @@ describe 'test patterns', ->
'': -> 'empty string'
name: -> 1
undefined, -> 2
- expect(ret).toBe(1)
+ expect(ret).toBe(1)
+
+ it 'dont count wrong on objects', ->
+ ret = match 'e',
+ a: 'a'
+ b: 'b'
+ c: 'c'
+ d: 'd'
+ 'e', 'e'
+ undefined, 'nothing'
+ expect(ret).toBe('e')

0 comments on commit 58be60b

Please sign in to comment.