https://github.com/probmods/webppl
Tip revision: a1d59b4a12193b710bd50712c0d741a5ab7d7e26 authored by Andreas Stuhlmüller on 23 June 2016, 16:48:16 UTC
0.8.0
0.8.0
Tip revision: a1d59b4
test-examples.js
'use strict';
var _ = require('underscore');
var fs = require('fs');
var webppl = require('../src/main');
var dists = require('../src/dists');
var examplesDir = './examples/';
var examples = [
'binomial',
'geometric',
'hmm',
'hmmIncremental',
'lda',
'ldaCollapsed',
'linearRegression',
'logisticRegression',
'multivariateRegression',
'pcfg',
'pcfgIncremental',
'scalarImplicature',
'semanticParsing',
'pragmaticsWithSemanticParsing'
];
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(dists.isDist(val));
});
});
test.done();
};
});
};
generateTestCases();