not exists

41 views
Skip to first unread message

Daniel Sobral

unread,
Apr 10, 2013, 10:00:12 PM4/10/13
to specs2-users
I'm looking for something like !xs.exists(p). I have code like this:

valuesA1B1 must not haveKeys("a2", "a3", "b2")

And then I found that if any of these keys are not present, then this is condition is true. I need to assert that *none* of these keys are present. Suggestions?

--
Daniel C. Sobral

I travel to the future all the time.

etorreborre

unread,
Apr 10, 2013, 10:40:38 PM4/10/13
to specs2...@googlegroups.com
You can go:

forall(values) { v => Seq("a1", "a2", "a3") must not contain(v) }

E.

Daniel Sobral

unread,
Apr 11, 2013, 12:42:09 AM4/11/13
to specs2-users
Well, I suppose I can, but the failure message will be confusing.


--
You received this message because you are subscribed to the Google Groups "specs2-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specs2-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

etorreborre

unread,
Apr 11, 2013, 11:28:27 PM4/11/13
to specs2...@googlegroups.com
You can go:

 Seq(1, 2, 3) must not(containAnyOf(Seq(1, 4)))

But the failure message will say:

List(1, 2, 3) contains at least one of '1, 4' 
 
Which is not super precise, I need the improve that.

E.

etorreborre

unread,
Apr 12, 2013, 1:17:53 AM4/12/13
to specs2...@googlegroups.com
Hi Daniel,

With the latest SNAPSHOT the message is:

x List(1, 2, 3) contains '1'

Cheers,

Eric.

Daniel Sobral

unread,
Apr 16, 2013, 10:55:02 AM4/16/13
to specs2-users
On 12 April 2013 00:28, etorreborre <etorr...@gmail.com> wrote:
You can go:

 Seq(1, 2, 3) must not(containAnyOf(Seq(1, 4)))

But the failure message will say:

List(1, 2, 3) contains at least one of '1, 4' 
 
Which is not super precise, I need the improve that.

It's better, but it doesn't work with keys. I'd have to transform the input to extract just the keys, which would obscure what is being checked.

etorreborre

unread,
Apr 17, 2013, 12:54:35 AM4/17/13
to specs2...@googlegroups.com
 Hi Daniel,

In the latest 1.15-SNAPSHOT now the behaviour is more intuitive:

 Map(1 -> "1", 2 -> "2", 3 -> "3") must not haveKeys(1, 2)

> Map(1 -> 1, 2 -> 2, 3 -> 3) has the keys '1, 2'

Cheers,

Eric.

Daniel Sobral

unread,
Apr 24, 2013, 5:58:17 PM4/24/13
to specs2-users
Well, but Map(1 -> "1", 3 -> "3") must not haveKeys(1, 2) succeeds, which is what I find non-intuitive. And, regardless of whether that's intuitive or not (honestly, I think this is the kind of situation that's too ambiguous to be sure), I still don't have anything that will do what I _need_ doing. :-)

etorreborre

unread,
Apr 24, 2013, 6:53:12 PM4/24/13
to specs2...@googlegroups.com
Daniel, did you try it on the latest SNAPSHOT?

Because I get a failure:

x Map(1 -> 1, 3 -> 3) has the key '1'

E.

Daniel Sobral

unread,
Apr 25, 2013, 7:35:36 PM4/25/13
to specs2-users
Mmmmm. I thought I did, but it turns out the snapshot was not replaced due to Windows preventing the file from being removed because IntelliJ had it opened. Yes, it works exactly as I'd like it to now!
Reply all
Reply to author
Forward
0 new messages