- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: [ANN] specs 1.5.0
Thu, 2009-05-07, 16:16
That would have to be must `match`, as match is a keyword.
2009/5/7 Randall R Schulz <rschulz@sonic.net>
2009/5/7 Randall R Schulz <rschulz@sonic.net>
On Thursday May 7 2009, Eric Torreborre wrote:
> Hi all,
>
> I'm very pleased to announce the release of
> http://code.google.com/p/specs/ specs 1.5.0 .
>
> Just as a reminder, specs is a Behavior-Driven Development library
> for Scala, providing simple ways to write software specifications:
>
> object helloWorld extends Specification {
> "'hello world' has 11 characters" in {
> "hello world".size must be equalTo(11)
> }
> "'hello world' matches 'h.* w.*'" in {
> "hello world" must be matching("h.* w.*")
> }
> }
Is there a reason why this example (and others like it) can't be more
like this:
... "hellow world" must match("h.* w.*") ...
It seems much more natural to me.
> ...
>
> Cheers,
>
> Eric.
>
> ...
Randall Schulz
Thu, 2009-05-07, 18:07
#2
Re: [ANN] specs 1.5.0
>>>>> "Ricky" == Ricky Clarkson writes:
Ricky> That would have to be must `match`, as match is a keyword.
m4tch, then :-)
Thu, 2009-05-07, 21:07
#3
Re: [ANN] specs 1.5.0
Hi All,
On Thu, May 7, 2009 at 8:16 AM, Ricky Clarkson wrote:
>
> 2009/5/7 Randall R Schulz
>>
>> On Thursday May 7 2009, Eric Torreborre wrote:
>>>
>> > object helloWorld extends Specification {
>> > "'hello world' has 11 characters" in {
>> > "hello world".size must be equalTo(11)
>> > }
>> > "'hello world' matches 'h.* w.*'" in {
>> > "hello world" must be matching("h.* w.*")
>> > }
>> > }
>>
>> Is there a reason why this example (and others like it) can't be more
>> like this:
>>
>> ... "hellow world" must match("h.* w.*") ...
>>
>> It seems much more natural to me.
>>
> That would have to be must `match`, as match is a keyword.
>
In ScalaTest matchers the syntax is:
string must fullyMatch regex ("h*")
It's fullyMatch for two reasons, one of which is that match is a
keyword. The other is to clarify that the entire string must match,
not just part of it. The regex is in there to make it more obvious to
casual readers that the kind of match going on is a regular expression
one. In addition, this use of regex is consistent with other matcher
expressions that deal with regexes. If you want to check for a
substring within a string, you write one of:
string must include ("h")
string must startWith ("h")
string must endWith ("h")
Note that with is a keyword also, which is the main reason it's
startWith not start with. If you want to look for a regex inside I
string, you write:
string must include regex ("h")
string must startWith regex ("h")
string must endWith regex ("h")
So "fullyMatch regex" is symetrical with "include regex", etc.
Bill
Thu, 2009-05-07, 22:37
#4
Re: [ANN] specs 1.5.0
You can still use the old style (I do). My understanding is that it
is just a few marchers which have been pimped with the infix-happy
syntax.
Daniel
On May 7, 2009, at 4:31 PM, Stepan Koltsov wrote:
> On Thu, May 7, 2009 at 20:21, Daniel Spiewak
> wrote:
>> Well, here's the question then: what would be the optimal DSL for
>> defining a
>> specification? This is very much a subjective issue, as
>> illustrated by the
>> fact that I think that Specs is already pretty close to optimal. :-)
>
> specs before 1.5 is fine: not too many spaces between words:
>
> something must beLike { case x => true }
> something must_== value
> something must beEmpty
>
> instead of
>
> something must be like { case x => y }
> something must be equal to value
> something must be empty
>
> I program in Scala long enough, but I still cannot tell exactly what
> is result of compilation of "something must be equal to". And I don't
> want to know, until I really need it. I like KISS principle.
>
> S.
>
>
>> Daniel
>>
>> On Thu, May 7, 2009 at 11:18 AM, David Chase
>> wrote:
>>>
>>> I wish to support Stepan in his flaming statement. We're not all
>>> English
>>> speakers, and almost-English can be quite confusing. It's
>>> important that it
>>> things be readable from the get-go -- to say that you could read
>>> it, after
>>> you translate it to another form, is not the same as being able to
>>> read it
>>> as is.
>>>
>>> With DSLs, I think you need to make a distinction between using an
>>> existing DSL (e.g., mathematics, music, chemistry) and inventing a
>>> new DSL.
>>> The point of (adapting) an existing DSL is to avoid the need to
>>> learn new
>>> rules.
>>>
>>> David
>>>
>>> On 2009-05-07, at 11:52 AM, Stepan Koltsov wrote:
>>>
>>>> On Thu, May 7, 2009 at 19:32, Ricky Clarkson >>> >
>>>> wrote:
>>>>>
>>>>> If it won't work, it won't compile, mostly. It is trivial to
>>>>> convert
>>>>> that
>>>>> syntax to regular.calls(like).this, if you have any doubts about
>>>>> precedence. Though doubts about precedence should be resolved by
>>>>> learning
>>>>> the language's rules.
>>>>>
>>>>> The result is you need to learn Specs via its documentation or
>>>>> tests,
>>>>> instead of via the source or scaladoc.
>>>>>
>>>>> Multiple ways of doing the same thing can be ok. Specs'
>>>>> documentation
>>>>> doesn't let the more verbose way get in the way of learning to use
>>>>> Specs.
>>>>> Imaginary problems are imaginary.
>>>>
>>>> It's a bit flaming statement:
>>>> It is imaginary problem while you write small projects alone in
>>>> your
>>>> favorite language. Problems are real when you are trying to hack
>>>> a big
>>>> project, written in foreign language written by a group of people
>>>> you
>>>> don't know. In this case you don't want to read or learn anything.
>>>> You'd like everything to be simple and obvious.
>>>>
>>>> S.
>>>
>>
>>
Thu, 2009-05-07, 22:47
#5
Re: [ANN] specs 1.5.0
On Fri, May 8, 2009 at 01:38, Ricky Clarkson wrote:
>> I program in Scala long enough, but I still cannot tell exactly what
>> is result of compilation of "something must be equal to". And I don't
>> want to know, until I really need it. I like KISS principle.
>
> Deliberate avoidance of learning detected. Solution: Force learning by
> providing answer in annoyingly-worded email:
> it is really quite simple to work out how it compiles
> it.is(really).quite(simple).to(work).out(how).it(compiles)
> now.please(stop).pretending(the).rules(are).obscure(or).hard(in).some(way)
> Solution complete. Time to mute this thread in gmail.
I cannot learn everything. I do learn only that I really need.
S.
On Thursday May 7 2009, Ricky Clarkson wrote:
> 2009/5/7 Randall R Schulz
>
> > ...
> >
> > Is there a reason why this example (and others like it) can't be
> > more like this:
> >
> > ... "hellow world" must match("h.* w.*") ...
> >
> > It seems much more natural to me.
> That would have to be must `match`, as match is a keyword.
Yes, but aside from the fact that "match" is a keyword. It was the "be"
that I was asking about.
RRS