Skip to content

Commit d5e9866

Browse files
committed
Get rid of eval in compiler tests
1 parent 9db8f1f commit d5e9866

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

test/compiler.jl

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using .Turing, Random, MacroTools, Distributions, Test
2-
using DynamicPPL: DynamicPPL, @vsym, @vinds, @varname, VarInfo, VarName
2+
using DynamicPPL: DynamicPPL, vsym, vinds, @varname, VarInfo, VarName
33

44
dir = splitdir(splitdir(pathof(DynamicPPL))[1])[1]
55
include(dir*"/test/test_utils/AllUtils.jl")
@@ -498,33 +498,29 @@ priors = 0 # See "new grammar" test.
498498
end
499499
@testset "var name splitting" begin
500500
var_expr = :(x)
501-
sym, inds = @eval @vsym($var_expr), @vinds($var_expr)
502-
@test sym == :x
503-
@test inds == ()
501+
sym, inds = vsym(var_expr), vinds(var_expr)
502+
@test sym == :(:x)
503+
@test inds == :(())
504504

505505
var_expr = :(x[1,1][2,3])
506-
sym, inds = @eval @vsym($var_expr), @vinds($var_expr)
507-
@test sym == :x
508-
@test inds[1] == (1, 1)
509-
@test inds[2] == (2, 3)
506+
sym, inds = vsym(var_expr), vinds(var_expr)
507+
@test sym == :(:x)
508+
@test inds == :(((1, 1), (2, 3)))
510509

511-
var_expr = :(x[Colon(),1][2,Colon()])
512-
sym, inds = @eval @vsym($var_expr), @vinds($var_expr)
513-
@test sym == :x
514-
@test inds[1] == (Colon(), 1)
515-
@test inds[2] == (2, Colon())
510+
var_expr = :(x[:,1][2,:])
511+
sym, inds = vsym(var_expr), vinds(var_expr)
512+
@test sym == :(:x)
513+
@test inds == :(((:, 1), (2, :)))
516514

517515
var_expr = :(x[2:3,1][2,1:2])
518-
sym, inds = @eval @vsym($var_expr), @vinds($var_expr)
519-
@test sym == :x
520-
@test inds[1] == (2:3, 1)
521-
@test inds[2] == (2, 1:2)
516+
sym, inds = vsym(var_expr), vinds(var_expr)
517+
@test sym == :(:x)
518+
@test inds == :(((2:3, 1), (2, 1:2)))
522519

523520
var_expr = :(x[2:3,2:3][[1,2],[1,2]])
524-
sym, inds = @eval @vsym($var_expr), @vinds($var_expr)
525-
@test sym == :x
526-
@test inds[1] == (2:3, 2:3)
527-
@test inds[2] == ([1, 2], [1, 2])
521+
sym, inds = vsym(var_expr), vinds(var_expr)
522+
@test sym == :(:x)
523+
@test inds == :(((2:3, 2:3), ([1, 2], [1, 2])))
528524
end
529525
@testset "user-defined variable name" begin
530526
@model f1() = begin

0 commit comments

Comments
 (0)