Skip to content

Commit

Permalink
fix #1025
Browse files Browse the repository at this point in the history
  • Loading branch information
pepkin88 authored and rhendric committed Jul 29, 2018
1 parent 61afa79 commit 7b91a13
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ast.ls
Expand Up @@ -708,7 +708,7 @@ class exports.Chain extends Node
this

auto-compare: (target) ->
test = @head
test = @head unless @tails.length
switch
| test instanceof Literal
Binary \=== test, target.0
Expand Down
12 changes: 12 additions & 0 deletions test/operator.ls
Expand Up @@ -988,3 +988,15 @@ ok not (even or 1) 3
ok ((.length > 4) or [1 2 3]) [1 2 3]

eq 8 ((-> &0 + &1 is 5) and (**)) 2 3

# [LiveScript#1025](https://github.com/gkz/LiveScript/issues/1025)
# The placeholder logic from `match` is also applied here
_ = -> -> false
_.isString = -> typeof it == \string
_.isNumber = -> typeof it == \number
eq false (_.isString || _.isNumber) []
eq false (_.isString || _!) []
eq true (_.isString || _.isNumber) 1

# other examples of Chains with tails
eq \bar ('foo'~slice || 'foobar'~slice) 3
17 changes: 17 additions & 0 deletions test/switch.ls
Expand Up @@ -275,6 +275,23 @@ match 1, 3, 3
| _ => ok 0


# [LiveScript#1025](https://github.com/gkz/LiveScript/issues/1025)
# Expressions starting from `_` were treated as placeholders in `match` cases
_ = -> -> false
_.isString = -> typeof it == \string
match 1
| _.isString => ok 0
| (_.isString) => ok 0
| _! => ok 0
match \foo
| _.isString => ok 1

# other examples of Chains with tails
match \foo
| 'barbaz'~starts-with => ok 0
| 'foobar'~starts-with => ok 1
| otherwise => ok 0

# [LiveScript#926](https://github.com/gkz/LiveScript/issues/926)
# `match` wasn't binding `this` correctly in expression position
o =
Expand Down

0 comments on commit 7b91a13

Please sign in to comment.