aboutsummaryrefslogtreecommitdiffstats
path: root/Test
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2014-09-29 09:46:47 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2014-09-29 09:46:47 +0200
commit7cc2021714ce1d013f41e6601c293340d3a873cb (patch)
tree300b5596b3bb2f5e3743739c9247170a4ab88751 /Test
parent801b29bd789f140ae73db9e5a213693e80cd2001 (diff)
downloadCompiler-7cc2021714ce1d013f41e6601c293340d3a873cb.zip
Compiler-7cc2021714ce1d013f41e6601c293340d3a873cb.tar.gz
Compiler-7cc2021714ce1d013f41e6601c293340d3a873cb.tar.bz2
Check soundness of other samplers.
Diffstat (limited to 'Test')
-rw-r--r--Test/Unit/Llk/Soundness.php65
1 files changed, 58 insertions, 7 deletions
diff --git a/Test/Unit/Llk/Soundness.php b/Test/Unit/Llk/Soundness.php
index f519f15..4be4792 100644
--- a/Test/Unit/Llk/Soundness.php
+++ b/Test/Unit/Llk/Soundness.php
@@ -39,6 +39,7 @@ namespace Hoa\Compiler\Test\Unit\Llk;
use Hoa\Test;
use Hoa\Compiler as LUT;
use Hoa\File;
+use Hoa\Iterator;
use Hoa\Math;
use Hoa\Regex;
@@ -56,19 +57,57 @@ class Soundness extends Test\Unit\Suite {
public function case_exaustive_json ( ) {
+ $this->with_json(
+ new LUT\Llk\Sampler\BoundedExhaustive(
+ $this->getJSONCompiler(),
+ $this->getRegexSampler(),
+ 12
+ )
+ );
+ }
+
+ public function case_coverage_json ( ) {
+
+ $this->with_json(
+ new LUT\Llk\Sampler\Coverage(
+ $this->getJSONCompiler(),
+ $this->getRegexSampler()
+ )
+ );
+ }
+
+ public function case_uniform_random_json ( ) {
+
$this
->given(
- $grammar = new File\Read('hoa://Library/Json/Grammar.pp'),
- $compiler = LUT\Llk::load($grammar),
- $sampler = new LUT\Llk\Sampler\BoundedExhaustive(
- $compiler,
- new Regex\Visitor\Isotropic(new Math\Sampler\Random()),
- 15
+ $sampler = new LUT\Llk\Sampler\Uniform(
+ $this->getJSONCompiler(),
+ $this->getRegexSampler(),
+ 5
)
)
+ ->with_json(
+ new Iterator\Limit(
+ new Iterator\CallbackGenerator(function ( ) use ( $sampler ) {
+
+ return $sampler->uniform();
+ }),
+ 0,
+ 1000
+ ),
+ $sampler->getCompiler()
+ );
+ }
+
+ protected function with_json ( $sampler, $compiler = null ) {
+
+ if(null === $compiler)
+ $compiler = $sampler->getCompiler();
+
+ $this
->when(function ( ) use ( $compiler, $sampler ) {
- foreach($sampler as $data ) {
+ foreach($sampler as $data) {
$this
->given(json_decode($data))
@@ -84,4 +123,16 @@ class Soundness extends Test\Unit\Suite {
}
});
}
+
+ protected function getJSONCompiler ( ) {
+
+ return LUT\Llk::load(
+ new File\Read('hoa://Library/Json/Grammar.pp')
+ );
+ }
+
+ protected function getRegexSampler ( ) {
+
+ return new Regex\Visitor\Isotropic(new Math\Sampler\Random());
+ }
}