Sounds like Dart was introduced earlier in its development than Go.
This is a *good thing*.
Colin
Can I recommend a \usepackage{hyperref}, if only for getting a
hyperlinked table of contents?
--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
Can I recommend a \usepackage{hyperref}, if only for getting a
hyperlinked table of contents?
--
Damien Pollet
type less, do more [ | ] http://people.untyped.org/damien.pollet
> I think Go's choice makes a lot of sense for a server-side back-end language.
>
> Since Dart is aiming for the client-side web community
I personally like to think of Go as a system programming language, while Dart is an application programming language. I'd certainly love to do server-side programming in Dart (and I even think that Dart would be suitable for teaching programming!).
(And btw, while thinking about doing some real stuff, I quickly came up with a conclusion that the sole really missing thing now is reflection. Everything else -- I hope to write a mail about my opinions to the list soon -- can come later, but you can't even write a decent unit testing framework now. And yes, I've seen the one in samples.)
LT
> I think Go's choice makes a lot of sense for a server-side back-end language.
>> Since Dart is aiming for the client-side web communityI personally like to think of Go as a system programming language, while Dart is an application programming language. I'd certainly love to do server-side programming in Dart (and I even think that Dart would be suitable for teaching programming!).
(And btw, while thinking about doing some real stuff, I quickly came up with a conclusion that the sole really missing thing now is reflection. Everything else -- I hope to write a mail about my opinions to the list soon -- can come later, but you can't even write a decent unit testing framework now. And yes, I've seen the one in samples.)
Ha! That is a kind of style I'd wanted to see in the main samples! Nice.
main() {test('addition', () {expect(1 + 2).equals(3);expect(1 + 3).equals(4);});group('unary', () {test('postfix increment', () {var i = 3;expect(i++).equals(3);expect(i).equals(4);});test('prefix increment', () {var i = 3;expect(++i).equals(4);expect(i).equals(4);});});}
main() {test('addition', () {expect(1 + 2).equals(3);expect(1 + 3).equals(4);});group('unary', () {test('postfix increment', () {var i = 3;expect(i++).equals(3);expect(i).equals(4);});test('prefix increment', () {var i = 3;expect(++i).equals(4);expect(i).equals(4);});});}Yeah, this looks pretty neat (I admit I was thinking too much Java-style), and it's completely different from what I've seen. But I guess you'd need a little more, at least before/after (setup/teardown), or JUnit-like "rules"... well, I assume you've already got that :-)
If matchers were an independent and extensible library (like Hamcrest in Java world), that would be great!
I haven't figured that out yet because we haven't needed it yet, but I'll keep that in mind. I'm trying to keep it as terse as possible for simple cases where you don't need a lot of setup while still allowing that stuff when you do.It shouldn't be too hard to do. Things get much easier I find when you can safely assume a single thread of control. :)If matchers were an independent and extensible library (like Hamcrest in Java world), that would be great!Extensibility here is an excellent idea. Let me give that some thought.
If matchers were an independent and extensible library (like Hamcrest in Java world), that would be great!Extensibility here is an excellent idea. Let me give that some thought.
main() {expectThat(0, zero());expectThat(1, not(zero()));expectThat(1, positive());expectThat(-1, negative());expectThat(1, equals(1));expectThat(1, lessThan(2));expectThat(1, lessThanOrEqual(1));...expectThat("abc", contains("b"));expectThat("abc", matches("a.c"));expectThat("abc", matches(new RegExp("a.c")));expectThat("abcd", not(matches(@"^a.c$")));print('ok');}
> That looks pretty nice! The only thing I'm a little iffy on is that it means
> putting all of the matchers in top-level scope. Things like "zero" and "not"
> and "contains" seem like there's a decent chance they may collide with a
> name in the code you're trying to test. That's one of the things I was
> hoping to avoid by using chaining.
> I'd be curious to hear anyone else's opinion on this.
+1 on chaining. A library shouldn't pollute the top-level scope.
Colin
That looks pretty nice! The only thing I'm a little iffy on is that it means putting all of the matchers in top-level scope. Things like "zero" and "not" and "contains" seem like there's a decent chance they may collide with a name in the code you're trying to test.
That's one of the things I was hoping to avoid by using chaining.
Oh, I totally forgot about that. Will have a look at it... but I can only think of noSuchMethod as an extension point.
Bob Nystrom
18 October, 2011 4:27 PM
main() {expectThat(0, zero());expectThat(1, not(zero()));expectThat(1, positive());expectThat(-1, negative());expectThat(1, equals(1));expectThat(1, lessThan(2));expectThat(1, lessThanOrEqual(1));...expectThat("abc", contains("b"));expectThat("abc", matches("a.c"));expectThat("abc", matches(new RegExp("a.c")));expectThat("abcd", not(matches(@"^a.c$")));print('ok');}That looks pretty nice! The only thing I'm a little iffy on is that it means putting all of the matchers in top-level scope. Things like "zero" and "not" and "contains" seem like there's a decent chance they may collide with a name in the code you're trying to test. That's one of the things I was hoping to avoid by using chaining.I'd be curious to hear anyone else's opinion on this.- bob
Ladislav Thon
18 October, 2011 3:59 PM
I was thinking about this today and decided to finally write some code. I won't say that this is idiomatic Dart (it probably looks a lot like Java), but I hope it will be useful to someone. So, this is my attempt at standalone extensible matchers library in Dart: https://github.com/Ladicek/dart-matchers
LTBob Nystrom
18 October, 2011 1:55 PM
On Tue, Oct 18, 2011 at 1:23 AM, Ladislav Thon <lad...@gmail.com> wrote:main() {test('addition', () {expect(1 + 2).equals(3);expect(1 + 3).equals(4);});group('unary', () {test('postfix increment', () {var i = 3;expect(i++).equals(3);expect(i).equals(4);});test('prefix increment', () {var i = 3;expect(++i).equals(4);expect(i).equals(4);});});}Yeah, this looks pretty neat (I admit I was thinking too much Java-style), and it's completely different from what I've seen. But I guess you'd need a little more, at least before/after (setup/teardown), or JUnit-like "rules"... well, I assume you've already got that :-)I haven't figured that out yet because we haven't needed it yet, but I'll keep that in mind. I'm trying to keep it as terse as possible for simple cases where you don't need a lot of setup while still allowing that stuff when you do.It shouldn't be too hard to do. Things get much easier I find when you can safely assume a single thread of control. :)
If matchers were an independent and extensible library (like Hamcrest in Java world), that would be great!Extensibility here is an excellent idea. Let me give that some thought.
- bobLadislav Thon
18 October, 2011 4:23 AM
Yeah, this looks pretty neat (I admit I was thinking too much Java-style), and it's completely different from what I've seen. But I guess you'd need a little more, at least before/after (setup/teardown), or JUnit-like "rules"... well, I assume you've already got that :-)
If matchers were an independent and extensible library (like Hamcrest in Java world), that would be great!
LTBob Nystrom
17 October, 2011 6:21 PM
On Mon, Oct 17, 2011 at 3:14 PM, Ladislav Thon <lad...@gmail.com> wrote:> I think Go's choice makes a lot of sense for a server-side back-end language.
>> Since Dart is aiming for the client-side web communityI personally like to think of Go as a system programming language, while Dart is an application programming language. I'd certainly love to do server-side programming in Dart (and I even think that Dart would be suitable for teaching programming!).
Agreed on server-side Dart. I didn't mean to imply that we want Dart to only be a client-side language, but being on the client is important, and I think that requires broader user support than a strictly server-side language needs.(And btw, while thinking about doing some real stuff, I quickly came up with a conclusion that the sole really missing thing now is reflection. Everything else -- I hope to write a mail about my opinions to the list soon -- can come later, but you can't even write a decent unit testing framework now. And yes, I've seen the one in samples.)
I'm working on the unit test lib right now (it creaks under the weight of an old Java-style API). What don't you like about it?For a point of reference, the new API I'm working on is:
main() {test('addition', () {expect(1 + 2).equals(3);expect(1 + 3).equals(4);});group('unary', () {test('postfix increment', () {var i = 3;expect(i++).equals(3);expect(i).equals(4);});test('prefix increment', () {var i = 3;expect(++i).equals(4);expect(i).equals(4);});});}
If your tests were in test classes as in xUnit, then couldn't you just provide all those as methods on a Test superclass.
> If your tests were in test classes as in xUnit, then couldn't you just provide all those as methods on a Test superclass.
I certainly could, but:
1. Inheritance is bad :-)
2. Matchers are useful for more things than just testing (think validation etc.)
LT
1. It feels weird to have to go around the type system and go completely dynamic for this. It feels like a fairly straightforward use case so it doesn't seem like you should have to jump through hoops like this.
On Tue, Oct 18, 2011 at 1:44 PM, Bob Nystrom <rnys...@google.com> wrote:1. It feels weird to have to go around the type system and go completely dynamic for this. It feels like a fairly straightforward use case so it doesn't seem like you should have to jump through hoops like this.It seems like you would want to use code generation and mirrors for this, to achieve an effect like JUnit.
Am 18.10.2011 22:40 schrieb "Ladislav Thon" <lad...@gmail.com>:
> Yes, I agree. If Dart had something like "static imports" from Java, these functions could be moved to one class while still allowing this kind of concise code...
Seems much more this is a call for mix-ins again.
Am 19.10.2011 04:33 schrieb "Alan Knight" :
> That does leave the question of how to do the test
> framework when there isn't any reflection available yet.
>But the code I've seen so far seems like something I'd
> consider a stopgap until better facilities became available.
It is a more functional approach and I would prefer such over reflection, so perhaps more than only a stopgap.
Looking at
Void main() {
test('somename', () {...} );
I wonder what 'test' is. If it's a function only or perhaps a method on an already instanciated and configured test frame.
var test = new Tester()
test.setup = () => //some preparation here
test.add('test', (ctx) { do something, use ctx } );
test.run()
BTW: Groovy has a very nice feature. It allows for setting the delegate on a closure, such that it builds the scope on which free method calls are searched.
Regarding Delegate: Ladislav Thon formulated the same idea in a PM I read afterwards. So perhaps a valid point for consideration?
Regarding Delegate: Ladislav Thon formulated the same idea in a PM I read afterwards. So perhaps a valid point for consideration?
Am 19.10.2011 04:33 schrieb "Alan Knight" :
> That does leave the question of how to do the test
> framework when there isn't any reflection available yet.
>But the code I've seen so far seems like something I'd
> consider a stopgap until better facilities became available.It is a more functional approach and I would prefer such over reflection, so perhaps more than only a stopgap.
Looking at
Void main() {
test('somename', () {...} );I wonder what 'test' is. If it's a function only or perhaps a method on an already instanciated and configured test frame.
var test = new Tester()
test.setup = () => //some preparation heretest.add('test', (ctx) { do something, use ctx } );
test.run()
BTW: Groovy has a very nice feature. It allows for setting the delegate on a closure, such that it builds the scope on which free method calls are searched.