Skip to content
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

[Raw idea] Implement Power asserts #413

Open
ligurio opened this issue Jan 16, 2025 · 0 comments
Open

[Raw idea] Implement Power asserts #413

ligurio opened this issue Jan 16, 2025 · 0 comments

Comments

@ligurio
Copy link
Member

ligurio commented Jan 16, 2025

There is a so-called "Power assertions" that makes assertions quite more powerful. The best way to demonstrate power assertion is an example:

    assert(types[index].name === bob.name)
           |    ||      |    |   |   |
           |    ||      |    |   |   "bob"
           |    ||      |    |   Person{name:"bob",age:5}
           |    ||      |    false
           |    |11     "alice"
           |    Person{name:"alice",age:3}
           ["string",98.6,true,false,null,undefined,#Array#,#Object#,NaN,Infinity,/^not/,#Person#]
  
    --- [string] bob.name
    +++ [string] types[index].name
    @@ -1,3 +1,5 @@
    -bob
    +alice

Power assertions in other languages: Kotlin 1, Rust 2, .NET 3, Ruby 4, Javasctipt 5, Grooyv 6.

Footnotes

  1. https://kotlinlang.org/docs/power-assert.html

  2. https://github.com/gifnksm/power-assert-rs

  3. https://github.com/PowerAssert/PowerAssert.Net

  4. https://github.com/ruby/power_assert

  5. https://github.com/power-assert-js/power-assert#description

  6. https://dontmindthelanguage.wordpress.com/2009/12/11/groovy-1-7-power-assert/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant