C
Christer Nilsson
I'm trying to make my own simple assert, but have problem displaying
arrays.
assert "123", [1,2,[3]].to_s
Is there a method or function x, fullfilling these requirements
assert "[1,2,[3]]", [1,2,[3]].x
assert "[1,2,[3]]", x([1,2,[3]])
assert "1", x(1)
assert "a", x("a")
or some of them?
There is no problem with the comparison as
assert [1,2,[3]], [1,2,[3]]
The problem appears when displaying different values:
assert [1,2,[3]], [1,2,3]
...
expect: 123
actual: 123
...
which is not very helpful.
This is the definition of my assert:
def assert(expect, actual)
expect==actual ? print(".") : print("\nexpect: #{expect}\nactual:
#{actual}\n")
end
This is probably very easy, but I haven't found anything.
Christer
arrays.
assert "123", [1,2,[3]].to_s
Is there a method or function x, fullfilling these requirements
assert "[1,2,[3]]", [1,2,[3]].x
assert "[1,2,[3]]", x([1,2,[3]])
assert "1", x(1)
assert "a", x("a")
or some of them?
There is no problem with the comparison as
assert [1,2,[3]], [1,2,[3]]
The problem appears when displaying different values:
assert [1,2,[3]], [1,2,3]
...
expect: 123
actual: 123
...
which is not very helpful.
This is the definition of my assert:
def assert(expect, actual)
expect==actual ? print(".") : print("\nexpect: #{expect}\nactual:
#{actual}\n")
end
This is probably very easy, but I haven't found anything.
Christer