Skip to content

Commit

Permalink
bug getodk#4: empty-string successor relevance values emitted () rele…
Browse files Browse the repository at this point in the history
…vant.
  • Loading branch information
issa-tseng committed Feb 13, 2019
1 parent 8287f56 commit f71c08b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
20 changes: 11 additions & 9 deletions lib/convert.js

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

6 changes: 6 additions & 0 deletions spec/src/convert-question-spec.ls
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ describe 'followup question' ->
expect(result.relevant).toBe("(selected(testquestion, 'testvalue'))")
expect(context.successor-relevance).toBe(undefined)

test 'blank values are ignored' ->
context = new-context() with successor-relevance: ""
result = convert-question({ type: \inputText }, context)
expect(result.relevant).toBe(undefined)
expect(context.successor-relevance).toBe(undefined)

test 'context is cleared at the end of group scope' ->
context = new-context()
convert-question({ type: \group, children: [{ type: \inputSelectOne, name: \test, other: [ \test ] }] }, context)
Expand Down
3 changes: 2 additions & 1 deletion src/convert.ls
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ convert-question = (question, context, prefix = []) ->

## merge in convenience relevant logic definitions:
if (successor-relevance = delete context.successor-relevance)?
question.relevant = (question.relevant ? []) ++ [ successor-relevance ] |> map(-> "(#it)") |> (.join(' and '))
unless is-nonsense(successor-relevance)
question.relevant = (question.relevant ? []) ++ [ successor-relevance ] |> map(-> "(#it)") |> (.join(' and '))

## drop successor information into context:
if (other = delete question.other)?
Expand Down

0 comments on commit f71c08b

Please sign in to comment.