Skip to content

Commit

Permalink
Merge pull request #51 from aragon/fix-empty-strings
Browse files Browse the repository at this point in the history
Fix evaluator crash with empty strings
  • Loading branch information
izqui authored Nov 13, 2018
2 parents 2038f97 + b2618ad commit 4922768
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 38 deletions.
74 changes: 37 additions & 37 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion src/evaluator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Evaluator {
}

if (node.type === 'StringLiteral') {
return new TypedValue('string', node.value)
return new TypedValue('string', node.value || '')
}

if (node.type === 'NumberLiteral') {
Expand Down
4 changes: 4 additions & 0 deletions test/examples/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ const cases = [
source: 'a is `a`, b is `b` and "c d" is `c d`',
bindings: { a: int(1), b: int(2), c: int(3), d: int(4) }
}, 'a is 1, b is 2 and "c d" is 3 4'],
[{
source: 'An empty string`\'\'`',
bindings: { }
}, 'An empty string'],

// Maths
[{
Expand Down

0 comments on commit 4922768

Please sign in to comment.