-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from JordanRL/dev
Dev
- Loading branch information
Showing
6 changed files
with
143 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,41 @@ | ||
build: | ||
environment: | ||
variables: | ||
COMPOSER_ROOT_VERSION: 2.0 | ||
php: | ||
version: 8.0 | ||
ini: | ||
xdebug.mode: coverage | ||
nodes: | ||
analysis: | ||
project_setup: | ||
override: true | ||
standalone-tests: | ||
tests: | ||
override: [php-scrutinizer-run] | ||
before: | ||
- mkdir build | ||
- mkdir build/logs | ||
override: | ||
- command: php vendor/bin/phpunit | ||
coverage: | ||
file: build/logs/coverage.clover | ||
format: clover | ||
with-modules-tests: | ||
requires: | ||
- node: standalone-tests | ||
tests: | ||
before: | ||
- mkdir build | ||
- mkdir build/logs | ||
- composer require "samsara/fermat-coordinate-systems:dev-master" | ||
- composer require "samsara/fermat-complex-numbers:dev-master" | ||
- composer require "samsara/fermat-matrices-and-vectors:dev-master" | ||
- composer require "samsara/fermat-stats:dev-master" | ||
- composer require "samsara/fermat-algebra-expressions:dev-master" | ||
override: | ||
- command: php vendor/bin/phpunit -c phpunit-modules.xml | ||
coverage: | ||
file: build/logs/coverage.clover | ||
format: clover | ||
build_failure_conditions: | ||
- 'elements.rating(<= D).new.exists' | ||
- 'project.metric_change("scrutinizer.test_coverage", < -0.05)' | ||
- 'project.metric("scrutinizer.test_coverage", < 0.70)' | ||
- 'project.metric("scrutinizer.quality", < 8)' | ||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
- 'project.metric("scrutinizer.quality", < 8)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0"?> | ||
<ruleset> | ||
<rule ref="PSR1.Classes.ClassDeclaration"/> | ||
<rule ref="PSR1.Files.SideEffects"/> | ||
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/> | ||
<rule ref="Generic.CodeAnalysis.EmptyStatement"/> | ||
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> | ||
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> | ||
<rule ref="Generic.CodeAnalysis.JumbledIncrementer"/> | ||
<rule ref="Generic.Files.ByteOrderMark"/> | ||
<rule ref="Generic.NamingConventions.ConstructorName"/> | ||
<rule ref="Generic.PHP.ForbiddenFunctions"/> | ||
<rule ref="Squiz.Scope.MemberVarScope"/> | ||
<rule ref="Squiz.PHP.CommentedOutCode"/> | ||
<rule ref="Squiz.PHP.GlobalKeyword"/> | ||
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/> | ||
<rule ref="Squiz.Operators.ValidLogicalOperators"/> | ||
<rule ref="PSR2.Classes.PropertyDeclaration"/> | ||
<rule ref="PSR2.Classes.ClassDeclaration"/> | ||
<rule ref="PSR2.Methods.MethodDeclaration"/> | ||
<rule ref="PSR2.Namespaces.UseDeclaration"/> | ||
<rule ref="PSR2.ControlStructures.SwitchDeclaration"/> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="tests/bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="true" | ||
stopOnFailure="false" | ||
beStrictAboutOutputDuringTests="true" | ||
timeoutForSmallTests="2" | ||
timeoutForMediumTests="15" | ||
timeoutForLargeTests="60" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">./src/Samsara/Fermat</directory> | ||
</include> | ||
<report> | ||
<clover outputFile="build/logs/coverage.clover"/> | ||
</report> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Values"> | ||
<directory suffix=".php">./tests-with-modules/Samsara/Fermat/Values</directory> | ||
</testsuite> | ||
</testsuites> | ||
<logging/> | ||
</phpunit> |
52 changes: 52 additions & 0 deletions
52
tests-with-modules/Samsara/Fermat/Values/ImmutableDecimal2Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Samsara\Fermat\Values; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @runTestsInSeparateProcesses | ||
* @preserveGlobalState disabled | ||
*/ | ||
class ImmutableDecimal2Test extends TestCase | ||
{ | ||
|
||
|
||
/** | ||
* @group arithmetic | ||
* @group complex | ||
* @medium | ||
*/ | ||
public function testImaginaryAdd() | ||
{ | ||
|
||
$zero = new ImmutableDecimal(0); | ||
$one = new ImmutableDecimal(1); | ||
$oneI = new ImmutableDecimal('1i'); | ||
|
||
$this->assertEquals('1+1i', $one->add($oneI)->getValue()); | ||
$this->assertEquals('1+1i', $oneI->add($one)->getValue()); | ||
$this->assertEquals('1i', $oneI->add($zero)->getValue()); | ||
$this->assertEquals('1i', $zero->add($oneI)->getValue()); | ||
|
||
} | ||
|
||
/** | ||
* @group arithmetic | ||
* @group complex | ||
* @medium | ||
*/ | ||
public function testImaginarySubtract() | ||
{ | ||
|
||
$zero = new ImmutableDecimal(0); | ||
$one = new ImmutableDecimal(1); | ||
$oneI = new ImmutableDecimal('1i'); | ||
|
||
$this->assertEquals('1-1i', $one->subtract($oneI)->getValue()); | ||
$this->assertEquals('-1+1i', $oneI->subtract($one)->getValue()); | ||
$this->assertEquals('1i', $oneI->subtract($zero)->getValue()); | ||
$this->assertEquals('-1i', $zero->subtract($oneI)->getValue()); | ||
|
||
} | ||
} |