From: why t. l. s. <yam...@wh...> - 2002-07-09 06:23:51
|
Ryan King (rk...@pa...) wrote: > On 2002.07.08, yam...@wh... <yam...@wh...> wrote: > > 2. Unit tests > > [..] > > perl: | > > ['foo ' x 20] > > ruby: | > > ['foo ' * 20] > > Awesome. Beautiful. Perfect. Keep bugging Ingy until he caves > in and does this. I love it. Yeah, this excites me too. Not only do the files function as unit tests, but they could plausibly build a definitive YAML Cookbook. In other words, we could go for a structure that includes brief descriptions. title: Simple implicit map description: | This implicit map has unquoted strings for keys, with various numeric types for values. perl: | { hr => 65, avg => 0.278, rbi => 147 } ruby: | { 'hr' => 65, 'avg' => 0.278, 'rbi' => 147 } python: | { 'hr': 65, 'avg': 0.278, 'rbi': 147 } yaml: | avg: 0.278 hr: 65 rbi: 147 spec: http://www.yaml.org/spec/#trans-map Seems like a really neat use of YAML... > On a different note (err.. on a different key... er... on a > different keyboard), what's up with this?: > > ~/yaml4r-0.14$ ruby -Isrc tests/basic.rb > tests/basic.rb:6:in `require': No such file to load -- yaml4r (LoadError) > from tests/basic.rb:6 yaml4r.rb isn't actually born until you run install.rb. The grammar is in yaml.y and the emitter is in emitter.rb. Racc builds the grammar and then its flowed into a new yaml4r.rb. I figured it was better to distribute the actual source I am working with rather than the generated files. > I like what I see, by the way. It's interesting to see how > you've done some things just like how Steve and I did it in our > original Ruby-emitter spikes. And feel free to make any comments on the API or to submit patches. I'm totally flexible and we can all get more done together. > And on yet another keyboard, here's a random idea. Why not > replace the things in basic.rb that look like this: > > def test_basic > # Check foo: > assert('foo'...) > > > # Check bar: > assert('bar'...) > end > > with this?: > > def test_foo > assert('foo'...) > end > > def test_bar > assert('bar'...) > end > > > The main reason I do it this way is that I've found that *Unit > test frameworks seem to like it better this way -- specifically, > they help you when a test fails: > 1. They keep going, and run the other tests, too. > 2. They tell you the name of which test method failed, which > can help debugging a bit. > > Iunno... you might know something I don't. =) Excellent suggestion. I believe I'll be moving to this technique inthe next few days. And if you want bleeding edge... I just checked in 0.15 with support for Regexp and better double-quoting. Also, the explicit implicit works now: integer: 12 also int: ! "12" string: !str 12 I allow currently allow maps to be explicitly typed as sequences and vice versa. - !seq test: one another: two Performs Hash#to_a: [ ['test', 'one'], ['another', 'two'] ] Whereas the opposite: - !map - test - one - another - two Performs Hash.[]: [ {'test' => 'one', 'another' => 'two'} ] While I'm making major changes each night, I won't be releasing all the minor versions. Sync up with CVS: cvs -d:pserver:ano...@cv...:/cvsroot/yaml4r login cvs -d:pserver:ano...@cv...:/cvsroot/yaml4r co yaml4r The best part is actually being able to use YAML with Ruby now! It rules! 8D _why |