Code Duplication    Length = 38-38 lines in 5 locations

Tests/Units/NumberTestCase.php 5 locations

@@ 346-383 (lines=38) @@
343
    /*
344
     * Test add.
345
     */
346
    public function testAdd()
347
    {
348
        $this
349
            ->given(
350
                $a = $this->fromNative($this->randomNativeNumber()),
351
                $b = $this->fromNative($this->randomNativeNumber())
352
            )
353
            ->when($c = $a->add($b->toInteger()))
354
            ->and($d = $a->addInteger($b->toInteger()))
355
            ->then
356
                ->object($c)
357
                    ->isEqualTo($d)
358
        ;
359
360
        $this
361
            ->given(
362
                $a = $this->fromNative($this->randomNativeNumber()),
363
                $b = $this->fromNative($this->randomNativeNumber())
364
            )
365
            ->when($c = $a->add($b->toReal()))
366
            ->and($d = $a->addReal($b->toReal()))
367
            ->then
368
                ->object($c)
369
                    ->isEqualTo($d)
370
        ;
371
372
        $this
373
            ->given(
374
                $a = $this->fromNative($this->randomNativeNumber()),
375
                $b = $this->fromNative($this->randomNativeNumber())
376
            )
377
            ->when($c = $a->add($b->toDecimal()))
378
            ->and($d = $a->addDecimal($b->toDecimal()))
379
            ->then
380
                ->object($c)
381
                    ->isEqualTo($d)
382
        ;
383
    }
384
385
    /*
386
     * Test add commutative.
@@ 465-502 (lines=38) @@
462
    /*
463
     * Test sub.
464
     */
465
    public function testSub()
466
    {
467
        $this
468
            ->given(
469
                $a = $this->fromNative($this->randomNativeNumber()),
470
                $b = $this->fromNative($this->randomNativeNumber())
471
            )
472
            ->when($c = $a->sub($b->toInteger()))
473
            ->and($d = $a->subInteger($b->toInteger()))
474
            ->then
475
                ->object($c)
476
                    ->isEqualTo($d)
477
        ;
478
479
        $this
480
            ->given(
481
                $a = $this->fromNative($this->randomNativeNumber()),
482
                $b = $this->fromNative($this->randomNativeNumber())
483
            )
484
            ->when($c = $a->sub($b->toReal()))
485
            ->and($d = $a->subReal($b->toReal()))
486
            ->then
487
                ->object($c)
488
                    ->isEqualTo($d)
489
        ;
490
491
        $this
492
            ->given(
493
                $a = $this->fromNative($this->randomNativeNumber()),
494
                $b = $this->fromNative($this->randomNativeNumber())
495
            )
496
            ->when($c = $a->sub($b->toDecimal()))
497
            ->and($d = $a->subDecimal($b->toDecimal()))
498
            ->then
499
                ->object($c)
500
                    ->isEqualTo($d)
501
        ;
502
    }
503
504
    /*
505
     * Test sub zero.
@@ 527-564 (lines=38) @@
524
    /*
525
     * Test mult.
526
     */
527
    public function testMult()
528
    {
529
        $this
530
            ->given(
531
                $a = $this->fromNative($this->randomNativeNumber()),
532
                $b = $this->fromNative($this->randomNativeNumber())
533
            )
534
            ->when($c = $a->mult($b->toInteger()))
535
            ->and($d = $a->multInteger($b->toInteger()))
536
            ->then
537
                ->object($c)
538
                    ->isEqualTo($d)
539
        ;
540
541
        $this
542
            ->given(
543
                $a = $this->fromNative($this->randomNativeNumber()),
544
                $b = $this->fromNative($this->randomNativeNumber())
545
            )
546
            ->when($c = $a->mult($b->toReal()))
547
            ->and($d = $a->multReal($b->toReal()))
548
            ->then
549
                ->object($c)
550
                    ->isEqualTo($d)
551
        ;
552
553
        $this
554
            ->given(
555
                $a = $this->fromNative($this->randomNativeNumber()),
556
                $b = $this->fromNative($this->randomNativeNumber())
557
            )
558
            ->when($c = $a->mult($b->toDecimal()))
559
            ->and($d = $a->multDecimal($b->toDecimal()))
560
            ->then
561
                ->object($c)
562
                    ->isEqualTo($d)
563
        ;
564
    }
565
566
    /*
567
     * Test mult commutative.
@@ 699-736 (lines=38) @@
696
    /*
697
     * Test div.
698
     */
699
    public function testDiv()
700
    {
701
        $this
702
            ->given(
703
                $a = $this->fromNative($this->randomNativeNumber()),
704
                $b = $this->fromNative($this->randomNativeNumber())
705
            )
706
            ->when($c = $a->div($b->toInteger()))
707
            ->and($d = $a->divInteger($b->toInteger()))
708
            ->then
709
                ->object($c)
710
                    ->isEqualTo($d)
711
        ;
712
713
        $this
714
            ->given(
715
                $a = $this->fromNative($this->randomNativeNumber()),
716
                $b = $this->fromNative($this->randomNativeNumber())
717
            )
718
            ->when($c = $a->div($b->toReal()))
719
            ->and($d = $a->divReal($b->toReal()))
720
            ->then
721
                ->object($c)
722
                    ->isEqualTo($d)
723
        ;
724
725
        $this
726
            ->given(
727
                $a = $this->fromNative($this->randomNativeNumber()),
728
                $b = $this->fromNative($this->randomNativeNumber())
729
            )
730
            ->when($c = $a->div($b->toDecimal()))
731
            ->and($d = $a->divDecimal($b->toDecimal()))
732
            ->then
733
                ->object($c)
734
                    ->isEqualTo($d)
735
        ;
736
    }
737
738
    /*
739
     * Test div by zero.
@@ 776-813 (lines=38) @@
773
    /*
774
     * Test pow.
775
     */
776
    public function testPow()
777
    {
778
        $this
779
            ->given(
780
                $a = $this->fromNative($this->randomNativeNumber()),
781
                $b = $this->fromNative($this->randomNativeNumber())
782
            )
783
            ->when($c = $a->pow($b->toInteger()))
784
            ->and($d = $a->powInteger($b->toInteger()))
785
            ->then
786
                ->object($c)
787
                    ->isEqualTo($d)
788
        ;
789
790
        $this
791
            ->given(
792
                $a = $this->fromNative($this->randomNativeNumber()),
793
                $b = $this->fromNative($this->randomNativeNumber())
794
            )
795
            ->when($c = $a->pow($b->toReal()))
796
            ->and($d = $a->powReal($b->toReal()))
797
            ->then
798
                ->object($c)
799
                    ->isEqualTo($d)
800
        ;
801
802
        $this
803
            ->given(
804
                $a = $this->fromNative($this->randomNativeNumber()),
805
                $b = $this->fromNative($this->randomNativeNumber())
806
            )
807
            ->when($c = $a->pow($b->toDecimal()))
808
            ->and($d = $a->powDecimal($b->toDecimal()))
809
            ->then
810
                ->object($c)
811
                    ->isEqualTo($d)
812
        ;
813
    }
814
815
    /*
816
     * Test compareTo.