Skip to content

Migrate to new testing library #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: git config --system core.autocrlf false; git config --system core.eol lf

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
Expand All @@ -43,7 +43,7 @@ jobs:
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2.1.3
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -56,4 +56,4 @@ jobs:
echo "vendor/autoload.php" > composer.pth

- name: Run test suite
run: sh xp-run xp.unittest.TestRunner src/test/php
run: sh xp-run xp.test.Runner src/test/php
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"php" : ">=7.0.0"
},
"require-dev" : {
"xp-framework/unittest": "^11.0 | ^10.0"
"xp-framework/test": "^1.0"
},
"bin": ["bin/xp.xp-framework.compiler.compile", "bin/xp.xp-framework.compiler.ast"],
"autoload" : {
Expand Down
8 changes: 4 additions & 4 deletions src/test/php/lang/ast/unittest/EmitterTest.class.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php namespace lang\ast\unittest;

use io\streams\MemoryOutputStream;
use lang\ast\nodes\{Variable, Comment};
use lang\ast\{Emitter, Node, Code, Result};
use lang\{IllegalStateException, IllegalArgumentException};
use unittest\{Assert, Expect, Test, TestCase};
use lang\ast\nodes\{Comment, Variable};
use lang\ast\{Code, Emitter, Node, Result};
use lang\{IllegalArgumentException, IllegalStateException};
use test\{Assert, Expect, Test, TestCase};

class EmitterTest {

Expand Down
6 changes: 3 additions & 3 deletions src/test/php/lang/ast/unittest/ResultTest.class.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php namespace lang\ast\unittest;

use io\streams\MemoryOutputStream;
use lang\ast\emit\{Result, Declaration, Escaping, Reflection};
use lang\ast\emit\{Declaration, Escaping, Reflection, Result};
use lang\ast\nodes\ClassDeclaration;
use lang\{Value, ClassNotFoundException};
use unittest\{Assert, Expect, Test};
use lang\{ClassNotFoundException, Value};
use test\{Assert, Expect, Test};

class ResultTest {

Expand Down
18 changes: 9 additions & 9 deletions src/test/php/lang/ast/unittest/TypeLiteralsTest.class.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace lang\ast\unittest;

use lang\ast\emit\{PHP70, PHP71, PHP72, PHP74, PHP80, PHP81, PHP82};
use lang\ast\types\{IsLiteral, IsArray, IsFunction, IsMap, IsValue, IsNullable, IsUnion, IsIntersection, IsGeneric};
use unittest\{Assert, Test, Values};
use lang\ast\types\{IsArray, IsFunction, IsGeneric, IsIntersection, IsLiteral, IsMap, IsNullable, IsUnion, IsValue};
use test\{Assert, Test, Values};

class TypeLiteralsTest {

Expand Down Expand Up @@ -156,37 +156,37 @@ private function php82() {
yield [new IsIntersection([new IsValue('Test'), new IsValue('Iterator')]), 'Test&Iterator'];
}

#[Test, Values('php70')]
#[Test, Values(from: 'php70')]
public function php70_literals($type, $literal) {
Assert::equals($literal, (new PHP70())->literal($type));
}

#[Test, Values('php71')]
#[Test, Values(from: 'php71')]
public function php71_literals($type, $literal) {
Assert::equals($literal, (new PHP71())->literal($type));
}

#[Test, Values('php72')]
#[Test, Values(from: 'php72')]
public function php72_literals($type, $literal) {
Assert::equals($literal, (new PHP72())->literal($type));
}

#[Test, Values('php74')]
#[Test, Values(from: 'php74')]
public function php74_literals($type, $literal) {
Assert::equals($literal, (new PHP74())->literal($type));
}

#[Test, Values('php80')]
#[Test, Values(from: 'php80')]
public function php80_literals($type, $literal) {
Assert::equals($literal, (new PHP80())->literal($type));
}

#[Test, Values('php81')]
#[Test, Values(from: 'php81')]
public function php81_literals($type, $literal) {
Assert::equals($literal, (new PHP81())->literal($type));
}

#[Test, Values('php82')]
#[Test, Values(from: 'php82')]
public function php82_literals($type, $literal) {
Assert::equals($literal, (new PHP82())->literal($type));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\cli;

use unittest\Test;
use test\Test;
use xp\compiler\CompileOnly;

class CompileOnlyTest {
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/cli/FromFileTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use io\streams\FileInputStream;
use io\{File, Folder};
use lang\Environment;
use unittest\{Assert, After, Before, Test};
use test\{After, Assert, Before, Test};
use xp\compiler\FromFile;

class FromFileTest {
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/cli/FromFilesInTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use io\streams\FileInputStream;
use io\{File, Folder};
use lang\Environment;
use unittest\{Assert, After, Before, Test, Values};
use test\{After, Assert, Before, Test, Values};
use xp\compiler\FromFilesIn;

class FromFilesInTest {
Expand Down Expand Up @@ -50,7 +50,7 @@ public function can_create_from_string() {
new FromFilesIn($this->folder->getURI());
}

#[Test, Values('files')]
#[Test, Values(from: 'files')]
public function iteration($expected) {
$results= [];
foreach (new FromFilesIn($this->folder) as $path => $stream) {
Expand Down
6 changes: 3 additions & 3 deletions src/test/php/lang/ast/unittest/cli/FromInputsTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\cli;

use io\streams\{FileInputStream, ConsoleInputStream};
use unittest\{Assert, Test, Values};
use io\streams\{ConsoleInputStream, FileInputStream};
use test\{Assert, Test, Values};
use xp\compiler\FromInputs;

class FromInputsTest {
Expand All @@ -18,7 +18,7 @@ public function can_create() {
new FromInputs([]);
}

#[Test, Values('inputs')]
#[Test, Values(from: 'inputs')]
public function iteration($inputs, $expected) {
$results= [];
foreach (new FromInputs($inputs) as $path => $stream) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/cli/InputTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use io\{File, Folder};
use lang\{Environment, IllegalArgumentException};
use unittest\{Assert, After, Before, Expect, Test, Values};
use test\{After, Assert, Before, Expect, Test, Values};
use util\cmd\Console;
use xp\compiler\{Input, FromStream, FromFile, FromFilesIn, FromInputs};
use xp\compiler\{FromFile, FromFilesIn, FromInputs, FromStream, Input};

class InputTest {
private $folder, $file;
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/cli/OutputTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use io\{File, Folder};
use lang\Environment;
use unittest\{Assert, After, Before, Test, Values};
use test\{After, Assert, Before, Test, Values};
use util\cmd\Console;
use xp\compiler\{Output, CompileOnly, ToStream, ToFile, ToArchive, ToFolder};
use xp\compiler\{CompileOnly, Output, ToArchive, ToFile, ToFolder, ToStream};

class OutputTest {
private $folder, $file, $archive;
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/cli/ToArchiveTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use io\{File, Folder};
use lang\Environment;
use lang\archive\ArchiveClassLoader;
use unittest\{After, Assert, Before, Test};
use test\{After, Assert, Before, Test};
use xp\compiler\ToArchive;

class ToArchiveTest {
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/cli/ToFileTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use io\{File, Folder};
use lang\Environment;
use lang\FileSystemClassLoader;
use unittest\{After, Assert, Before, Test};
use test\{After, Assert, Before, Test};
use xp\compiler\ToFile;

class ToFileTest {
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/cli/ToFolderTest.class.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php namespace lang\ast\unittest\cli;

use io\{Folder, File};
use io\{File, Folder};
use lang\Environment;
use lang\FileSystemClassLoader;
use unittest\{After, Assert, Before, Test};
use test\{After, Assert, Before, Test};
use xp\compiler\ToFolder;

class ToFolderTest {
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/cli/ToStreamTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\cli;

use io\streams\MemoryOutputStream;
use unittest\{Assert, Test};
use test\{Assert, Test};
use xp\compiler\ToStream;

class ToStreamTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\IllegalArgumentException;
use unittest\{Assert, Expect, Test, Values};
use test\{Assert, Expect, Test, Values};

/**
* Annotations support. There are two tests extending this base class:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\Runnable;
use unittest\{Assert, Test};
use test\{Assert, Test};
use util\AbstractDeferredInvokationHandler;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use lang\Primitive;
use lang\ast\Errors;
use unittest\{Assert, Expect, Test};
use test\{Assert, Expect, Test};

/**
* Argument promotion
Expand Down Expand Up @@ -83,7 +83,7 @@ public function __construct(private int $id, private string $name) { }
);
}

#[Test, Expect(class: Errors::class, withMessage: 'Variadic parameters cannot be promoted')]
#[Test, Expect(class: Errors::class, message: '/Variadic parameters cannot be promoted/')]
public function variadic_parameters_cannot_be_promoted() {
$this->type('class <T> {
public function __construct(private string... $in) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\emit;

use unittest\{Assert, Test};
use test\{Assert, Test};

/**
* Argument unpacking
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\emit;

use unittest\{Assert, Test};
use test\{Assert, Test};

/**
* Array types
Expand Down
4 changes: 2 additions & 2 deletions src/test/php/lang/ast/unittest/emit/ArraysTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\IllegalStateException;
use unittest\{Assert, Expect, Test, Values};
use test\{Assert, Expect, Test, Values};

class ArraysTest extends EmittingTest {

Expand Down Expand Up @@ -40,7 +40,7 @@ public function run() {
Assert::equals([1, 2, 3], $r);
}

#[Test, Values(['[1, , 3]', '[1, , ]', '[, 1]']), Expect(class: IllegalStateException::class, withMessage: 'Cannot use empty array elements in arrays')]
#[Test, Values(['[1, , 3]', '[1, , ]', '[, 1]']), Expect(class: IllegalStateException::class, message: 'Cannot use empty array elements in arrays')]
public function arrays_cannot_have_empty_elements($input) {
$r= $this->run('class <T> {
public function run() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/emit/BlockTest.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\emit;

use unittest\{Assert, Test};
use test\{Assert, Test};

class BlockTest extends EmittingTest {

Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/emit/BracesTest.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\emit;

use unittest\{Assert, Test, Values};
use test\{Assert, Test, Values};

class BracesTest extends EmittingTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\Error;
use unittest\{Assert, Expect, Test, Values};
use test\{Assert, Expect, Test, Values};

/**
* Tests for first-class callable syntax
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/emit/CastingTest.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\ClassCastException;
use unittest\{Assert, Expect, Test, Values};
use test\{Assert, Expect, Test, Values};

class CastingTest extends EmittingTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\Primitive;
use unittest\{Assert, Test};
use test\{Assert, Test};

/**
* Tests `::class`
Expand Down
2 changes: 1 addition & 1 deletion src/test/php/lang/ast/unittest/emit/CommentsTest.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace lang\ast\unittest\emit;

use unittest\{Assert, Test};
use test\{Assert, Test};

class CommentsTest extends EmittingTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use lang\Throwable;
use unittest\{Assert, Expect, Test, Values};
use test\{Assert, Expect, Test, Values};

class ControlStructuresTest extends EmittingTest {

Expand Down Expand Up @@ -154,7 +154,7 @@ public function run($arg) {
Assert::equals('10+ items', $r);
}

#[Test, Expect(class: Throwable::class, withMessage: '/Unhandled match (value of type .+|case .+)/')]
#[Test, Expect(class: Throwable::class, message: '/Unhandled match (value of type .+|case .+)/')]
public function unhandled_match() {
$this->run('class <T> {
public function run($arg) {
Expand All @@ -167,7 +167,7 @@ public function run($arg) {
}', SEEK_END);
}

#[Test, Expect(class: Throwable::class, withMessage: '/Unknown seek mode .+/')]
#[Test, Expect(class: Throwable::class, message: '/Unknown seek mode .+/')]
public function match_with_throw_expression() {
$this->run('class <T> {
public function run($arg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use lang\ast\emit\Declaration;
use lang\ast\nodes\{ClassDeclaration, Property};
use lang\ast\types\IsValue;
use unittest\{Assert, Before, Test, Expect};
use test\{Assert, Before, Expect, Test};

class DeclarationTest {
private $type;
Expand Down
Loading