-
-
Notifications
You must be signed in to change notification settings - Fork 47
Add JET.jl static analysis tests #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ChrisRackauckas-Claude
wants to merge
1
commit into
SciML:main
from
ChrisRackauckas-Claude:static-improvements-20260107-165438
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| using ModelingToolkitStandardLibrary, JET, Test | ||
|
|
||
| # JET.jl static analysis tests for ModelingToolkitStandardLibrary | ||
| # | ||
| # Note: This package heavily uses ModelingToolkit's @component and @connector macros | ||
| # which generate code at macro expansion time. Full package analysis with JET times out. | ||
| # Instead, we focus on testing specific utility functions that are not macro-generated. | ||
|
|
||
| @testset "JET static analysis" begin | ||
| # Test that the package loads without JET-detectable issues | ||
| # We use a targeted approach since full package analysis is not feasible | ||
| # for metaprogramming-heavy packages like this one. | ||
|
|
||
| @testset "Module loading" begin | ||
| # Verify modules can be accessed (basic sanity check) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Blocks) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Electrical) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Mechanical) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Thermal) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Magnetic) | ||
| @test isdefined(ModelingToolkitStandardLibrary, :Hydraulic) | ||
| end | ||
|
|
||
| @testset "Utility functions - Hydraulic" begin | ||
| # Test hydraulic utility functions for type stability | ||
| # These are pure numerical functions that don't use metaprogramming | ||
|
|
||
| # regPow function - regularized power | ||
| regPow = ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.regPow | ||
| @test_opt target_modules = (ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible,) regPow( | ||
| 1.0, 0.5, 0.01 | ||
| ) | ||
|
|
||
| # transition function - smooth transition between values | ||
| transition = ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.transition | ||
| @test_opt target_modules = (ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible,) transition( | ||
| 0.0, 1.0, 0.0, 1.0, 0.5 | ||
| ) | ||
|
|
||
| # friction_factor function - calculates friction factor for pipe flow | ||
| friction_factor = ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor | ||
| @test_opt target_modules = (ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible,) friction_factor( | ||
| 1.0, 0.01, 0.1, 0.001, 64.0 | ||
| ) | ||
| end | ||
|
|
||
| @testset "Utility functions - Blocks sources" begin | ||
| # Test smooth functions used in source blocks | ||
| # These are pure numerical functions for generating smooth waveforms | ||
|
|
||
| Blocks = ModelingToolkitStandardLibrary.Blocks | ||
|
|
||
| # smooth_step - smooth step function | ||
| @test_opt target_modules = (Blocks,) Blocks.smooth_step(1.0, 0.01, 1.0, 0.0, 0.0) | ||
|
|
||
| # smooth_xH - smooth ramp helper | ||
| @test_opt target_modules = (Blocks,) Blocks.smooth_xH(1.0, 0.01, 0.0) | ||
|
|
||
| # square - square wave | ||
| @test_opt target_modules = (Blocks,) Blocks.square(1.0, 1.0, 1.0, 0.0, 0.0) | ||
|
|
||
| # triangular - triangular wave | ||
| @test_opt target_modules = (Blocks,) Blocks.triangular(1.0, 1.0, 1.0, 0.0, 0.0) | ||
| end | ||
|
|
||
| @testset "Digital logic - Electrical" begin | ||
| # Test digital logic table operations | ||
| E = ModelingToolkitStandardLibrary.Electrical | ||
|
|
||
| # Logic enum operations | ||
| @test E.F0 isa E.Logic | ||
| @test E.F1 isa E.Logic | ||
|
|
||
| # Test logic operations type stability | ||
| @test_opt target_modules = (E,) E._and2(E.F0, E.F1) | ||
| @test_opt target_modules = (E,) E._or2(E.F0, E.F1) | ||
| @test_opt target_modules = (E,) E._not(E.F0) | ||
| @test_opt target_modules = (E,) E._xor2(E.F0, E.F1) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
times out for whom? 😅