added tests but need to do rewrites. focus on GPU execution for now
Some checks are pending
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.10) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, 1.6) (push) Waiting to run
CI / Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} (x64, ubuntu-latest, pre) (push) Waiting to run

This commit is contained in:
2024-07-11 15:44:22 +02:00
parent 81d0158e46
commit 26741adec7
6 changed files with 119 additions and 52 deletions

View File

@ -0,0 +1,31 @@
expressions = Vector{Expr}(undef, 1)
variables = Matrix{Float64}(undef, 1,2)
parameters = Vector{Vector{Float64}}(undef, 1)
# Resulting value should be 10
expressions[1] = :(x1 + 1 * x2 + p1)
variables[1,1] = 2
variables[1,2] = 3
parameters[1] = Vector{Float64}(undef, 1)
parameters[1][1] = 5
@testset "Test symtable construction" begin
symtable = ExpressionExecutorCuda.ExpressionProcessing.construct_symtable(expressions, variables, parameters)
@test haskey(symtable, (expressions[1], :x1))
@test haskey(symtable, (expressions[1], :x2))
@test haskey(symtable, (expressions[1], :p1))
@test symtable[(expressions[1], :x1)] 2.0 atol=0.01
@test symtable[(expressions[1], :x2)] 3.0 atol=0.01
@test symtable[(expressions[1], :p1)] 5.0 atol=0.01
end
@testset "Test variable replacement in expression" begin
symtable = ExpressionExecutorCuda.ExpressionProcessing.construct_symtable(expressions, variables, parameters)
println(keys(symtable))
exprCopy = deepcopy(expressions[1])
ExpressionExecutorCuda.ExpressionProcessing.replace_variables!(exprCopy, symtable, expressions[1])
dump(exprCopy)
@test eval(exprCopy) == 10 # If it can be evaluated, it means all variables have been replaced, as there are no globally defined variables
end

View File

@ -0,0 +1,2 @@
[deps]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

View File

@ -2,5 +2,5 @@ using ExpressionExecutorCuda
using Test
@testset "ExpressionExecutorCuda.jl" begin
# Write your tests here.
include("ExpressionProcessing.jl")
end