Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Testing file for Polish Notation Calculator
- */
- require 'lib\cls\cls.LukasiewiczCalculator.php';
- use \lib\cls\LukasiewiczCalculator;
- $pnc = new LukasiewiczCalculator();
- echo '<h1><u>Polish Notation (PN) Calculator :</u></h1><p/>';
- echo '<h3>==> Error PN Tests :</h3><ul>';
- #
- # Set error expressions to test
- #
- $error_expressions = [
- '+1 7',
- '1 *-7',
- 'as17 / ',
- '',
- '1 7',
- '+ - * //',
- ];
- #
- # Call Calculate function against error expressions and print results
- #
- foreach($error_expressions as $expression)
- {
- echo "<li>$expression : " . $pnc->Calculate($expression) . '</li>';
- }
- echo '</ul><p/><br/>';
- echo '<h3>==> Valid PN Tests :</h3><ul>';
- #
- # Set valid expressions to calculate
- #
- $valid_expressions = [
- '+ 1 1', # 2
- '+ 9 * 2 6', # 21
- '* 3 + 4 5', # 27
- '- * / 15 - 7 + 1 1 3 + 2 + 1 1', # 5
- '* + 8 6 - + 1 2 3', # 0
- ];
- #
- # Call Calculate function against valid expressions and print results
- #
- foreach($valid_expressions as $expression)
- {
- echo "<li>$expression : <b style=\"margin-left: 1em; color: blue\">" . $pnc->Calculate($expression) . '</b></li><br/>';
- }
- echo '</ul><p/>';
- exit;
Add Comment
Please, Sign In to add comment