testez icon indicating copy to clipboard operation
testez copied to clipboard

.greater.than and .less.than

Open Kampfkarren opened this issue 7 years ago • 5 comments

Currently too unnatural to read:

expect(x > 0).to.equal(true)

Kampfkarren avatar Oct 08 '18 18:10 Kampfkarren

This falls apart once we consider >= and <= -- .greater.than.or.equal.to falls apart in the middle (or is a keyword)

LPGhatguy avatar Oct 08 '18 21:10 LPGhatguy

That's true, I forgot about >= and <=. Will readability have to suffer in favor of functionality?

greater_than, less_than greater_than.or_equal_to, less_than.or_equal_to?

Kampfkarren avatar Oct 08 '18 22:10 Kampfkarren

I suspect the best solution to this problem will be to make camelCase versions of everything be the default or radically change the assertion syntax.

expect(x).toBeGreaterThan(3) seems fine, especially if we can preserve all of the flexibility of the current syntax?

LPGhatguy avatar Oct 29 '18 20:10 LPGhatguy

https://github.com/Roblox/testez/issues/67

amoss-roblox avatar May 28 '20 15:05 amoss-roblox

Currently too unnatural to read:

expect(x > 0).to.equal(true)

The assertion description is no good from this:

Expected value "true" (boolean), got "false" (boolean) instead

Plain assertions fare better. Simple numerical comparison should be a given; batteries included.

The argument about or can be avoided the same way we got around not being a keyword.

expect(x >= 0).to.equal(true)

is

expect(x).never.less.than(0)

ployt0 avatar Feb 26 '23 23:02 ployt0