Daniel
68cedd75fc
Some checks failed
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Has been cancelled
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Has been cancelled
34 lines
1.5 KiB
Julia
34 lines
1.5 KiB
Julia
using .ExpressionProcessing
|
|
|
|
expressions = Vector{Expr}(undef, 1)
|
|
variables = Matrix{Float32}(undef, 1,2)
|
|
parameters = Vector{Vector{Float32}}(undef, 1)
|
|
|
|
# Resulting value should be 10
|
|
expressions[1] = :(x1 + 1 * x2 + p1)
|
|
variables[1,1] = 2
|
|
variables[1,2] = 3
|
|
parameters[1] = Vector{Float32}(undef, 1)
|
|
parameters[1][1] = 5
|
|
|
|
@testset "Test conversion expression element" begin
|
|
reference1 = ExpressionElement(FLOAT32, reinterpret(Int32, 1f0))
|
|
reference2 = ExpressionElement(INDEX, reinterpret(Int32, Int32(1)))
|
|
reference3 = ExpressionElement(OPERATOR, reinterpret(Int32, ADD))
|
|
|
|
@test isequal(reference1, ExpressionProcessing.convert_to_ExpressionElement(1.0))
|
|
@test isequal(reference2, ExpressionProcessing.convert_to_ExpressionElement(1))
|
|
@test isequal(reference3, ExpressionProcessing.convert_to_ExpressionElement(ADD))
|
|
end
|
|
|
|
@testset "Test conversion to postfix" begin
|
|
reference = PostfixType()
|
|
|
|
append!(reference, [ExpressionProcessing.convert_to_ExpressionElement(1), ExpressionProcessing.convert_to_ExpressionElement(1.0), ExpressionProcessing.convert_to_ExpressionElement(2), ExpressionProcessing.convert_to_ExpressionElement(MULTIPLY),
|
|
ExpressionProcessing.convert_to_ExpressionElement(ADD), ExpressionProcessing.convert_to_ExpressionElement(-1), ExpressionProcessing.convert_to_ExpressionElement(ADD)])
|
|
postfix = expr_to_postfix(expressions[1])
|
|
|
|
@test isequal(reference, postfix)
|
|
|
|
# TODO: Do more complex expressions because these have led to errors in the past
|
|
end |