https://github.com/probmods/webppl
Tip revision: 049e17de9ca7ad5b59102058d432aa1721232fdd authored by Andreas Stuhlmüller on 09 September 2015, 17:30:06 UTC
0.1.1
0.1.1
Tip revision: 049e17d
test-examples.js
'use strict';
var _ = require('underscore');
var fs = require('fs');
var webppl = require('../src/main.js');
var erp = require('../src/erp');
var examplesDir = './examples/';
var examples = [
'binomial',
'geometric',
'hmm',
'hmmIncremental',
'pcfg',
'pcfgIncremental',
'scalarImplicature',
'semanticParsing',
'pragmaticsWithSemanticParsing',
'multiplex'
];
var loadExample = function(example) {
var filename = examplesDir + example + '.wppl';
return fs.readFileSync(filename, 'utf-8');
};
var generateTestCases = function() {
_.each(examples, function(example) {
exports[example] = function(test) {
test.doesNotThrow(function() {
webppl.run(loadExample(example), function(s, val) {
test.ok(erp.isErp(val));
});
});
test.done();
};
});
};
generateTestCases();