Permalink
Browse files

Allow falsy values for IIP contents

  • Loading branch information...
1 parent 919874f commit ffc72d3082c064d92c79a5861168efd760cfc98d @bergie bergie committed Dec 19, 2012
Showing with 16 additions and 3 deletions.
  1. +1 −0 CHANGES.md
  2. +2 −2 src/lib/Fbp.coffee
  3. +1 −1 src/lib/Graph.coffee
  4. +12 −0 test/FbpParser.coffee
View
@@ -43,6 +43,7 @@ NoFlo internals:
* The `addX` methods of _Graph_ now return the object that was added to the graph
* NoFlo networks now emit `start` and `end` events
* Component instances have the ID of the node available at the `nodeId` property
+* Empty strings and other falsy values are now allowed as contents of Initial Information Packets
Changes to core components:
View
@@ -5,7 +5,7 @@ class Fbp
matchPort: new RegExp "([A-Z\.]+)"
matchComponent: new RegExp "([A-Za-z\.]+)\\(([A-Za-z0-9\/\.]+|)\\)"
matchComponentGlobal: new RegExp "([A-Za-z\.]+)\\(([A-Za-z0-9\/\.]+|)\\)", "g"
- matchInitial: new RegExp "\'(.+)\'"
+ matchInitial: new RegExp "\'(.*)\'"
matchConnection: new RegExp "\-\>"
matchSeparator: new RegExp "[\\s,\\n]"
matchSubgraph: new RegExp "\n *\\'(.+)\\' *-> *GRAPH *([A-Za-z\\.]+)\\(Graph\\)"
@@ -154,7 +154,7 @@ class Fbp
tgt: {}
handlePort: (port) ->
- if @currentEdge.data or @currentEdge.src.port
+ if @currentEdge.data isnt undefined or @currentEdge.src.port
@currentEdge.tgt =
port: port[1].toLowerCase()
return
View
@@ -252,7 +252,7 @@ exports.loadJSON = (definition, success) ->
graph.addNode id, def.component, def.display
for conn in definition.connections
- if conn.data
+ if conn.data isnt undefined
graph.addInitial conn.data, conn.tgt.process, conn.tgt.port.toLowerCase()
continue
graph.addEdge conn.src.process, conn.src.port.toLowerCase(), conn.tgt.process, conn.tgt.port.toLowerCase()
View
@@ -39,6 +39,18 @@ exports["test strings with whitespace"] = (test) ->
test.equal graph.nodes.length, 1
test.done()
+exports["test empty strings"] = (test) ->
+ fbpData = """
+ '' -> IN Display(Output)
+ """
+
+ noflo.graph.loadFBP fbpData, (graph) ->
+ test.equal graph.edges.length, 0
+ test.equal graph.initializers.length, 1
+ test.equal graph.initializers[0].from.data, ""
+ test.equal graph.nodes.length, 1
+ test.done()
+
exports["test strings with comments"] = (test) ->
fbpData = """
# Do more

0 comments on commit ffc72d3

Please sign in to comment.