Skip to content

Commit

Permalink
Fix indentation, move function definition
Browse files Browse the repository at this point in the history
  • Loading branch information
AnHeuermann committed Oct 11, 2022
1 parent ca83323 commit 47e5c43
Showing 1 changed file with 36 additions and 45 deletions.
81 changes: 36 additions & 45 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
module TestOMJulia

using OMJulia
using Test

@testset "OMJulia" begin

@testset "Parser" begin

function check(string, expected_value, expected_type)
value = OMJulia.Parser.parseOM(string)
expected_value == value && expected_type == typeof(value)
end

@test check("123.0", 123.0, Float64)
@test check("123", 123, Int)
@test check("1.", 1.0, Float64)
@test check(".2", 0.2, Float64)
@test check("1e3", 1e3, Float64)
@test check("1e+2", 1e+2, Float64)
@test check("tRuE", true, Bool)
@test check("false", false, Bool)
@test check("\"ab\\nc\"", "ab\nc", String)
@test check("{\"abc\"}", ["abc"], Array{String,1})
@test check("{1}", [1], Array{Int,1})
@test check("{1,2,3}", [1,2,3], Array{Int,1})
@test check("(1,2,3)", (1,2,3), Tuple{Int,Int,Int})
@test check("NONE()", nothing, Nothing)
@test check("SOME(1)", 1, Int)
@test check("abc_2", :abc_2, Symbol)
@test check("record ABC end ABC;", Dict(), Dict{String,Any})
@test check("record ABC a = 1, 'b' = 2,\n c = 3\nend ABC;", Dict("a" => 1, "'b'" => 2, "c" => 3), Dict{String,Int})
@test check("", nothing, Nothing)

end

@testset "OpenModelica" begin

omc = OMJulia.OMCSession()

@test 3==OMJulia.sendExpression(omc, "1+2")

end

end

using OMJulia
using Test

function check(string, expected_value, expected_type)
value = OMJulia.Parser.parseOM(string)
expected_value == value && expected_type == typeof(value)
end

@testset "OMJulia" begin
@testset "Parser" begin
@test check("123.0", 123.0, Float64)
@test check("123", 123, Int)
@test check("1.", 1.0, Float64)
@test check(".2", 0.2, Float64)
@test check("1e3", 1e3, Float64)
@test check("1e+2", 1e+2, Float64)
@test check("tRuE", true, Bool)
@test check("false", false, Bool)
@test check("\"ab\\nc\"", "ab\nc", String)
@test check("{\"abc\"}", ["abc"], Array{String,1})
@test check("{1}", [1], Array{Int,1})
@test check("{1,2,3}", [1,2,3], Array{Int,1})
@test check("(1,2,3)", (1,2,3), Tuple{Int,Int,Int})
@test check("NONE()", nothing, Nothing)
@test check("SOME(1)", 1, Int)
@test check("abc_2", :abc_2, Symbol)
@test check("record ABC end ABC;", Dict(), Dict{String,Any})
@test check("record ABC a = 1, 'b' = 2,\n c = 3\nend ABC;", Dict("a" => 1, "'b'" => 2, "c" => 3), Dict{String,Int})
@test check("", nothing, Nothing)
end

@testset "OpenModelica" begin
omc = OMJulia.OMCSession()
@test 3==OMJulia.sendExpression(omc, "1+2")
end
end
end

0 comments on commit 47e5c43

Please sign in to comment.