Hoa central
Public Member Functions | List of all members
Hoa\Math\Test\Unit\Visitor\Arithmetic Class Reference
Inheritance diagram for Hoa\Math\Test\Unit\Visitor\Arithmetic:

Public Member Functions

 case_visitor_exhaustively ()
 
- Public Member Functions inherited from Hoa\Test\Unit\Suite
 __construct ()
 
 getTestedClassName ()
 
 getTestedClassNamespace ()
 
 beforeTestMethod ($methodName)
 

Detailed Description

Class .

Test suite of the hoa://Library/Math/Arithmetic.pp grammar and the Hoa class.

Definition at line 55 of file Arithmetic.php.

Member Function Documentation

Hoa\Math\Test\Unit\Visitor\Arithmetic::case_visitor_exhaustively ( )

Definition at line 57 of file Arithmetic.php.

58  {
59  $this
60  ->given(
61  $sampler = new Compiler\Llk\Sampler\BoundedExhaustive(
62  Compiler\Llk\Llk::load(
63  new File\Read('hoa://Library/Math/Test/Unit/Arithmetic.pp')
64  ),
65  new Regex\Visitor\Isotropic(
66  new LUT\Sampler\Random()
67  ),
68  9
69  ),
70  $compiler = Compiler\Llk\Llk::load(
71  new File\Read('hoa://Library/Math/Arithmetic.pp')
72  ),
73  $visitor = new CUT()
74  )
75  ->executeOnFailure(function () use (&$expression) {
76  echo 'Failed expression: ', $expression, '.', "\n";
77  })
78  ->when(function () use (&$sampler, &$compiler, &$visitor) {
79  foreach ($sampler as $expression) {
80  $dump = $expression;
81 
82  try {
83  $x = (float) $visitor->visit(
84  $compiler->parse($expression)
85  );
86  } catch (\Exception $e) {
87  continue;
88  }
89 
90  eval('$y = (float) ' . $expression . ';');
91 
92  if (is_nan($x) || is_nan($y)) {
93  $this->boolean(true);
94 
95  continue;
96  }
97 
98  $this
99  ->float($x)
100  ->isNearlyEqualTo($y);
101  }
102  });
103  }

The documentation for this class was generated from the following file: