Esempio n. 1
0
 /**
  * This method tests the "add" method.
  *
  * @dataProvider data_add
  */
 public function test_add(array $provided, array $expected)
 {
     $p0 = IFloat\Module::add(IFloat\Type::box($provided[0]), IFloat\Type::box($provided[1]));
     $e0 = $expected[0];
     $this->assertInstanceOf('\\Saber\\Data\\IFloat\\Type', $p0);
     $this->assertSame($e0, $p0->unbox());
 }
Esempio n. 2
0
 /**
  * This method returns a list of all numbers for the specified sequence.
  *
  * @access public
  * @static
  * @param IFloat\Type $x                                    where to start
  * @param Core\Type $y                                      either an integer representing
  *                                                          the end of the sequence or a
  *                                                          tuple describing the sequence
  * @return IArrayList\Type                                  an empty array list
  */
 public static function sequence(IFloat\Type $x, Core\Type $y) : IArrayList\Type
 {
     $buffer = array();
     if ($y instanceof ITuple\Type) {
         $s = IFloat\Module::subtract($y->first(), $x);
         $n = $y->second();
     } else {
         // ($y instanceof IFloat\Type)
         $s = IFloat\Type::one();
         $n = $y;
     }
     if (IFloat\Module::isNegative($s)->unbox()) {
         for ($i = $x; IFloat\Module::ge($i, $n)->unbox(); $i = IFloat\Module::add($i, $s)) {
             $buffer[] = $i;
         }
     } else {
         for ($i = $x; IFloat\Module::le($i, $n)->unbox(); $i = IFloat\Module::add($i, $s)) {
             $buffer[] = $i;
         }
     }
     return IArrayList\Type::box($buffer);
 }