Skip to content

[Raw idea] Implement Power asserts #413

@ligurio

Description

@ligurio

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions