All 6 entries tagged Boo

No other Warwick Blogs use the tag Boo on entries | View entries tagged Boo at Technorati | View all 1 images tagged Boo

May 15, 2006

Specter Project

Writing about web page http://specter.sourceforge.net/

SourceForge finally accepted my project proposal.

I'm waiting on the SVN migration to take affect – but the source will be online very soon I hope.

For now, you can read more on the website .

— Edit —
Source now available via SubVersion:
https://svn.sourceforge.net/svnroot/specter/trunk


May 11, 2006

Boo AST Attribute Ideas

Here are some ideas I had for handy Boo AST (abstract syntax tree) attributes:
[HandleExceptionWithMessageBox]
def Foo():
CallSomething()
DoStuff()
MaybeCrash()
expands to
def Foo():
try:
CallSomething()
DoStuff()
MaybeCrash()
except ex:
MessageBox.Show(ex.Message)

Very handy for UI code that calls into business objects that may throw up exceptions. Not having to explicitly write the try…except block is a timesaver!

Also,

class MyForm:
btn = Button()

[HandleEvent(btn.Click)]
def ButtonClicked():
print "button clicked"
expands to
class MyForm:
btn = Button()

def constructor():
btn.Click += ButtonClicked

def ButtonClicked():
print "button clicked"
This allows the event hookup to appear on the handling method, rather than miles away in the constructor. This is great for UI code since it means u can delete a method and know there is not still a line of code else trying to point to it. (So basically is works like the VB.NET "handles" keyword.)

May 04, 2006

Specter

specter logo

May 02, 2006

Specter

I'm waiting for SourceForge to approve my Specter project (previously know as BooSpec). It's been 7 days so far already.. I'm hoping they're just really busy and will get round to me soon.
I'll blog as soon as the project is approved (fingers crossed!). Anyone who wants to collaborate will then be welcome to join the project.

I had another syntax idea today as well…

Instead of something like:

foo.Must.BeLessThanOrEqual(42)
how about:
foo.Must.Be <= 42

I can make the object returned by "Be" overload the comparison operators. This makes for much less typing and I think is easier to read. Of course, I can support both forms in Specter and let the user decide which they prefer.

Similarly the equality specifications become:

foo.Must.Be == 42
Actually, now that I think about it… I can probably make the Boo macro look for statements that are just binary expressions (A op B) and output correct method calls at compile time. This would make for specs like this:
context "Sample spec":
x as int

specify:
x < 42
:D This could be awesome!

April 18, 2006

BooSpec!

Follow-up to Behavior Driven Development: BooSpec from codeMonkey.Weblog();

Wooo! I thought it couldn't be done, but Boo's syntactic macros (given an afternoon of hacking!) allow me to do this:
import BooSpec

context TestContext:
data as string

setup:
data = "hello"

specify Print:
print data

#----------------------
e = TestContext()
e.SetUp()
e.Print()
Yup, that's right! The "context" macro is creating a new class. The setup and specify macros create methods. Basically what this means is soon we'll be able to write object behaviour specifications without all that nasty non-spec syntax getting in the way.
Compare:
[Context]
class EmptyStack:
[Specify]
def CountIsZero():
...etc
with simply:
context "Empty Stack"
specify "Count is zero":
...etc
I must say a huge thank you to the guys over on the BooLang group. Without their advice and examples I'd never have gotten here!

April 16, 2006

Behavior Driven Development: BooSpec

This weekend is watched this video I then spent a lot of time exploring a relatively new concept in the agile development world: Behavior Driven Development (BDD).

RSpec is a Ruby project to allow creation of runnable specifications. There is a related project for .NET called NSpec

I have also been exploring Boo , a cool new language targeting .NET. Whilst NSpec allows the creation of runnable specs, I don't like the slightly clunky syntax imposed by C#. I want my spec to be as human readable as possible. Basically we need extension methods in C#. These are coming in 3.0, but for now I thought I'd look at Boo. Boo allows me to more closely approximate RSpec's Ruby syntax, giving rise to Boo specs like this:

namespace Test

import BooSpec

[Context]
class EmptyStack:
private stack as Stack

[SetUp]
def SetUp():
stack = Stack(10)

[Specify]
def CountIsZero():
stack.Count.Must().Equal(0)

[Specify]
def PopThrowsException():
{ stack.Pop() }.Must().Throw(typeof(IllegalOperationException))

[Specify]
def PushedItemIsOnTop():
stack.Push(42)
stack.Peek().Must().Equal(42)

I especially like "{ stack.Pop() }.Must().Throw(typeof(IllegalOperationException))". It's just so succinct!

I'm tempted to start a new project called "BooSpec". This would be a library similar to RSpec and NSpec, but written in Boo. The BooSpec library could be used by any .NET language, except the Must() extension methods calls would have to revert to normal static calls. Of course there is nothing wrong with writing the spec in Boo and the application code in C# or VB.NET!


Google Ads

Search this blog

Most recent comments

  • I scratched my eye while i was holding some kind of plastic packaging.. Anyways the corner of the pl… by Ercan on this entry
  • About a year ago my contacts that i was wearing, i guess were fautly, because shortly after they wer… by Jon on this entry
  • I got shower gel in my eye 4 and a half days ago, and becasue i rubbed my eyes a lot, i have scratch… by Chris on this entry
  • This website may help http://www.webmd.com/eye–health/tc/Eye–Injuries–Home–Treatment by S on this entry
  • I somehow got dirt, or debris in my eye. The terrible pain sent me in a tailspin. I was afraid of sa… by Bobbi on this entry

Tags

September 2021

Mo Tu We Th Fr Sa Su
Aug |  Today  |
      1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30         

Galleries

Blog archive

Loading…
RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXXI