Skip to content

Commit a965621

Browse files
authored
Switch Core tests to "Test Item Framework" (#475)
1 parent 9fff016 commit a965621

25 files changed

+96
-65
lines changed

Project.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,4 @@ SparseArrays = "1"
6464
SpecialFunctions = "2"
6565
StaticArraysCore = "1"
6666
StochasticDiffEq = "6"
67-
Test = "1"
6867
julia = "1.10"
69-
70-
[extras]
71-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
72-
73-
[targets]
74-
test = ["Test"]

docs/src/resources/contributing.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ The tests are divided into several test groups, where the group names are define
3838
make GROUP=Core test
3939
```
4040

41+
### [Test Item Framework for Core tests](@id doc-Contribute:Test-Item-Framework-for-Core-tests)
42+
43+
The tests in `GROUP=Core` are provided using the [Test Item Framework](https://www.julia-vscode.org/docs/stable/userguide/testitems/), which structures the test codes into `@testitems` and makes it easier to run individually.
44+
45+
The [VS Code](https://code.visualstudio.com/) and its [Julia extension](https://www.julia-vscode.org/) provides us with options to run individual `@testitems`. It is much easier to find the specific core test that failed since the [Julia extension](https://www.julia-vscode.org/) in [VS Code](https://code.visualstudio.com/) will collect all core test failures and then display them in a structured way, directly at the place in the code where a specific core test failed. See [here](https://www.julia-vscode.org/docs/stable/userguide/testitems/) for more details.
46+
4147
## [Julia Code Format](@id doc-Contribute:Julia-Code-Format)
4248

4349
We use [`JuliaFormatter.jl`](https://github.com/domluna/JuliaFormatter.jl) to format all the source codes. The code style and extra formatting options is defined in the file `.JuliaFormatter.toml` in the repository.

src/qobj/quantum_object_base.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,53 @@ Constructor representing a bra state ``\langle\psi|``.
3030
"""
3131
struct Bra <: QuantumObjectType end
3232

33+
Base.show(io::IO, ::Bra) = print(io, "Bra()")
34+
3335
@doc raw"""
3436
Ket <: QuantumObjectType
3537
3638
Constructor representing a ket state ``|\psi\rangle``.
3739
"""
3840
struct Ket <: QuantumObjectType end
3941

42+
Base.show(io::IO, ::Ket) = print(io, "Ket()")
43+
4044
@doc raw"""
4145
Operator <: QuantumObjectType
4246
4347
Constructor representing an operator ``\hat{O}``.
4448
"""
4549
struct Operator <: QuantumObjectType end
4650

51+
Base.show(io::IO, ::Operator) = print(io, "Operator()")
52+
4753
@doc raw"""
4854
SuperOperator <: SuperOperatorType
4955
5056
Constructor representing a super-operator ``\hat{\mathcal{O}}`` acting on vectorized density operator matrices.
5157
"""
5258
struct SuperOperator <: SuperOperatorType end
5359

60+
Base.show(io::IO, ::SuperOperator) = print(io, "SuperOperator()")
61+
5462
@doc raw"""
5563
OperatorBra <: QuantumObjectType
5664
5765
Constructor representing a bra state in the [`SuperOperator`](@ref) formalism ``\langle\langle\rho|``.
5866
"""
5967
struct OperatorBra <: QuantumObjectType end
6068

69+
Base.show(io::IO, ::OperatorBra) = print(io, "OperatorBra()")
70+
6171
@doc raw"""
6272
OperatorKet <: QuantumObjectType
6373
6474
Constructor representing a ket state in the [`SuperOperator`](@ref) formalism ``|\rho\rangle\rangle``.
6575
"""
6676
struct OperatorKet <: QuantumObjectType end
6777

78+
Base.show(io::IO, ::OperatorKet) = print(io, "OperatorKet()")
79+
6880
@doc raw"""
6981
size(A::AbstractQuantumObject)
7082
size(A::AbstractQuantumObject, idx::Int)

test/Project.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[deps]
2+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
4+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5+
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
6+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
7+
StaticArraysCore = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
8+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
9+
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
10+
11+
[compat]
12+
Pkg = "1"
13+
Test = "1"
14+
TestItemRunner = "1"

test/core-test/block_diagonal_form.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Block Diagonal Form" begin
1+
@testitem "Block Diagonal Form" begin
22
# Block Diagonal Form
33
N = 20
44
Δ = 0

test/core-test/code-quality/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
44
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
5+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
56

67
[compat]
78
Aqua = "0.8"

test/core-test/correlations_and_spectrum.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Correlations and Spectrum" begin
1+
@testitem "Correlations and Spectrum" begin
22
N = 10
33
Id = qeye(N)
44
a = destroy(N)

test/core-test/dynamical-shifted-fock.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Dynamical Shifted Fock" begin
1+
@testitem "Dynamical Shifted Fock" begin
22
F = 3
33
Δ = 0.25
44
κ = 1

test/core-test/dynamical_fock_dimension_mesolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### DYNAMICAL FOCK DIMENSION ###
2-
@testset "Dynamical Fock Dimension" begin
2+
@testitem "Dynamical Fock Dimension" begin
33
F, Δ, κ = 5, 0.25, 1
44
t_l = range(0, 15, length = 100)
55

test/core-test/eigenvalues_and_operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Eigenvalues and Operators" begin
1+
@testitem "Eigenvalues and Operators" begin
22
σx = sigmax()
33
result = eigenstates(σx, sparse = false)
44
λd, ψd, Td = result

0 commit comments

Comments
 (0)