Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions lib/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"nodes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"opcode": {
"type": "string",
"pattern": "^([a-zA-Z0-9\\_\\-\\.\\:])+$"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

},
"control": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
},
"inputs": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
},
"literals": {
"type": "array"
}
},
"additionalProperties": false,
"required": [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think other fields are required too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed all your requests.

"opcode",
"control",
"inputs",
"literals"
]
}
},
"cfg": {
"type": "object",
"properties": {
"blocks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node": {
"type": "integer",
"minimum": 0
},
"nodes": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
},
"successors": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
}
},
"additionalProperties": false,
"required": [
"node",
"nodes",
"successors"
]
}
}
},
"additionalProperties": false,
"required": [
"blocks"
]
},
"dominance": {
"type": "object",
"properties": {
"blocks": {
"type": "array",
"items": {
"type": "object",
"properties": {
"node": {
"type": "integer",
"minimum": 0
},
"parent": {
"oneOf": [
{
"type": "integer",
"minimum": 0
},
{
"type": "null"
}
]
},
"frontier": {
"type": "array",
"items": {
"type": "integer",
"minimum": 0
}
}
},
"additionalProperties": false,
"required": [
"node",
"parent",
"frontier"
]
}
}
},
"additionalProperties": false,
"required": [
"blocks"
]
}
},
"additionalProperties": false,
"required": [
"nodes"
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"assert-text": "^1.1.0",
"jscs": "^1.13.1",
"jshint": "^2.8.0",
"mocha": "^2.2.5"
"mocha": "^2.2.5",
"tv4": "^1.1.12"
},
"dependencies": {
"bitfield.js": "^1.1.0"
Expand Down
8 changes: 8 additions & 0 deletions test/pipeline-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var assert = require('assert');
var assertText = require('assert-text');
var schema = require('../lib/schema.json');
var tv4 = require('tv4');

assertText.options.trim = true;

Expand All @@ -13,6 +15,12 @@ describe('JSON Pipeline', function() {
p = pipeline.create();
});

'p0 p1 p1cfg p2dom'.split(' ').forEach(function (e) {
it(e + ' should comply with the schema', function() {
assert.equal(tv4.validate(fixtures.json[e], schema), true);
});
});

it('should render JSON', function() {
var start = p.add('start');
var one = p.add('literal').addLiteral(1);
Expand Down