16 ms·
It sounds like you want support for a bad practice. Each of those code blocks are logically distinct tasks, and it would serve readability to factor them into f
by scott_s 15y ago
It sounds like you want support for a bad practice. Each of those code blocks are logically distinct tasks, and it would serve readability to factor them into functions. Further, you're abusing a language construct to do something other than its purpose.
I've never programming in Scala, so I'm going to write Python code that represents what I think is a better way of doing that kind of testing:
def test1(data):
result = SomethingToTest(data)
assert result == result.getSth()
def test2(data, out):
result = SomethingToTest(data, out)
assert result == result.getSth()
out = open("blah")
test2(out, "abcdefg")
test2(out, "hijk")
test1("hijk")
The problem is not that copy-pasted code may be incorrect. The problem is that you're copying and pasting code and expecting it to be correct. The way you're nesting scopes is confusing.