@@ -2432,6 +2432,86 @@ end
2432
2432
pop! (LOAD_PATH )
2433
2433
end
2434
2434
2435
+ if Base. VERSION >= v " 1.12.0-DEV.2047" && do_test (" struct/const revision" )
2436
+ @testset " struct/const revision" begin
2437
+ testdir = newtestdir ()
2438
+ dn = joinpath (testdir, " StructConst" , " src" )
2439
+ mkpath (dn)
2440
+ write (joinpath (dn, " StructConst.jl" ), """
2441
+ module StructConst
2442
+ const __hash__ = 0x71716e828e2d6093
2443
+ struct Fixed
2444
+ x::Int
2445
+ end
2446
+ Base.hash(f::Fixed, h::UInt) = hash(__hash__, hash(f.x, h))
2447
+ struct Point
2448
+ x::Float64
2449
+ end
2450
+ firstval(p::Point) = p.x
2451
+ mynorm(p::Point) = sqrt(p.x^2)
2452
+ end
2453
+ """ )
2454
+ sleep (mtimedelay)
2455
+ @eval using StructConst
2456
+ sleep (mtimedelay)
2457
+ f = StructConst. Fixed (5 )
2458
+ v1 = hash (f)
2459
+ p = StructConst. Point (5.0 )
2460
+ @test StructConst. firstval (p) == 5.0
2461
+ @test StructConst. mynorm (p) == 5.0
2462
+ @show methodswith (StructConst. Point, StructConst)
2463
+ write (joinpath (dn, " StructConst.jl" ), """
2464
+ module StructConst
2465
+ const __hash__ = 0xddaab158621d200c
2466
+ struct Fixed
2467
+ x::Int
2468
+ end
2469
+ Base.hash(f::Fixed, h::UInt) = hash(__hash__, hash(f.x, h))
2470
+ struct Point
2471
+ x::Float64
2472
+ y::Float64
2473
+ end
2474
+ firstval(p::Point) = p.x
2475
+ mynorm(p::Point) = sqrt(p.x^2)
2476
+ end
2477
+ """ )
2478
+ @yry ()
2479
+ @test StructConst. __hash__ == 0xddaab158621d200c
2480
+ v2 = hash (f)
2481
+ @test v1 != v2
2482
+ # These call outdated methods
2483
+ @test StructConst. firstval (p) == 5.0
2484
+ @test StructConst. mynorm (p) == 5.0
2485
+ p2 = StructConst. Point (3.0 , 4.0 )
2486
+ @show Int (Base. get_world_counter ())
2487
+ @show methods (StructConst. firstval)
2488
+ @test @eval (StructConst. firstval ($ p2)) == 3.0
2489
+ @test @eval (StructConst. mynorm ($ p2)) == 5.0
2490
+ write (joinpath (dn, " StructConst.jl" ), """
2491
+ module StructConst
2492
+ const __hash__ = 0x71716e828e2d6093
2493
+ struct Fixed
2494
+ x::Int
2495
+ end
2496
+ Base.hash(f::Fixed, h::UInt) = hash(__hash__, hash(f.x, h))
2497
+ struct Point
2498
+ x::Float64
2499
+ y::Float64
2500
+ end
2501
+ firstval(p::Point) = p.x
2502
+ mynorm(p::Point) = sqrt(p.x^2)
2503
+ end
2504
+ """ )
2505
+ @yry ()
2506
+ @test StructConst. __hash__ == 0x71716e828e2d6093
2507
+ v3 = hash (f)
2508
+ @test v1 == v3
2509
+
2510
+ rm_precompile (" StructConst" )
2511
+ pop! (LOAD_PATH )
2512
+ end
2513
+ end
2514
+
2435
2515
do_test (" get_def" ) && @testset " get_def" begin
2436
2516
testdir = newtestdir ()
2437
2517
dn = joinpath (testdir, " GetDef" , " src" )
0 commit comments