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

no notLessThan for 2 strings? also no Assert.greaterEqualThan, Assert.lessEqualThan? #93

Open
mw66 opened this issue Sep 25, 2020 · 5 comments

Comments

@mw66
Copy link

mw66 commented Sep 25, 2020

Error: template instance fluentasserts.core.base.Assert.opDispatch!("notLessThan", string, string) error instantiating

@gedaiu
Copy link
Owner

gedaiu commented Sep 25, 2020

is it possible to share the assert that triggered this error? This will help me to debug it. Also, it should work with the last release instead of the master branch.

@mw66
Copy link
Author

mw66 commented Sep 29, 2020

$ cat ab.d

#!/usr/bin/env dub
/+ dub.sdl:
dependency "fluent-asserts" version="~>0.13.0"
+/

import fluent.asserts;

void main() {
  assert("a" < "b");  // OK
  Assert.lessThan("c", "b");     // Error: no property lessThan for type fluentasserts.core.string.ShouldString
  Assert.notLessThan("c", "b");  // Error too
}

$ dub ab.d
../../../.dub/packages/fluent-asserts-0.13.3/fluent-asserts/source/fluentasserts/core/base.d-mixin-592(592,17): Error: no property lessThan for type fluentasserts.core.string.ShouldString
ab.d(10,18): Error: template instance fluentasserts.core.base.Assert.opDispatch!("lessThan", string, string) error instantiating
../../../.dub/packages/fluent-asserts-0.13.3/fluent-asserts/source/fluentasserts/core/base.d-mixin-592(592,17): Error: no property lessThan for type fluentasserts.core.string.ShouldString
ab.d(11,21): Error: template instance fluentasserts.core.base.Assert.opDispatch!("notLessThan", string, string) error instantiating

@mw66 mw66 changed the title no notLessThan for 2 strings? no notLessThan for 2 strings? also no Assert.greaterEqualThan, Assert.lessEqualThan? Oct 10, 2020
@mw66
Copy link
Author

mw66 commented Oct 10, 2020

Also I found there is no Assert.greaterEqualThan, Assert.lessEqualThan even for int?

@mw66
Copy link
Author

mw66 commented Apr 3, 2021

@gedaiu

ping.

Hit this problem again, we have notLessThan(), and Assert.notGreaterThan(), can we add alias to greaterEqualThan(), and lessEqualThan().

Thanks.

@gedaiu
Copy link
Owner

gedaiu commented Apr 3, 2021

I just added those 2 operations on the master branch and issued a new release v0.14.0-alpha.2 with those new operations.

I have mixed feelings for allowing lessThan and greaterThan to work with strings. I will research how other assert frameworks call this operations for strings. Maybe there is a better name.

If you want to enable those operations for strings, the v0.14 has a new way to extend the predefined asserts: https://github.com/gedaiu/fluent-asserts/blob/master/source/fluentasserts/core/lifecycle.d#L39

This should enable greaterThan comparisons for strings:

import fluentasserts.core.operations.registry;

static this() {
    Registry.instance.register("string", "string", "greaterThan", &greaterThan!string);
}

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

2 participants