Permalink
Browse files

Move some node type tests around.

  • Loading branch information...
1 parent 96b22f6 commit 84588e573a0a65ac935354b09c7c022672dba2d7 @jcoglan committed May 14, 2012
Showing with 32 additions and 19 deletions.
  1. +32 −0 spec/canopy/compiler/choice_part_spec.js
  2. +0 −19 spec/canopy/compiler/reference_spec.js
@@ -34,6 +34,38 @@ function() { with(this) {
}})
}})
+ describe('where the underlying parser is a reference', function() { with(this) {
+ before(function() { with(this) {
+ Canopy.compile('grammar JS.ENV.TypedRefTest\
+ first <- second <First>\
+ second <- "bar" <Second>')
+
+ TypedRefTestParser.First = { first: function() { return '1'} }
+ TypedRefTestParser.Second = { second: function() { return '2'} }
+ }})
+
+ it('extends the chosen node with the root type', function() { with(this) {
+ assertEqual( '2', TypedRefTestParser.parse('bar').second() )
+ }})
+
+ it('extends the chosen node with the reference type', function() { with(this) {
+ assertEqual( '1', TypedRefTestParser.parse('bar').first() )
+ }})
+ }})
+
+ describe('when the underlying parser is a repetition', function() { with(this) {
+ before(function() { with(this) {
+ Canopy.compile('grammar JS.ENV.TypedRepeatTest\
+ rule <- "content"+ <NodeType>')
+
+ TypedRepeatTestParser.NodeType = { custom: function() { return 'pass!' } }
+ }})
+
+ it('extends the chosen node with the mixin', function() { with(this) {
+ assertEqual( 'pass!', TypedRepeatTestParser.parse('contentcontent').custom() )
+ }})
+ }})
+
describe('when the underlying parser is a maybe', function() { with(this) {
before(function() { with(this) {
Canopy.compile('grammar JS.ENV.TypedMaybeTest\
@@ -19,25 +19,6 @@ function() { with(this) {
}})
}})
- describe('where the nodes are typed', function() { with(this) {
- before(function() { with(this) {
- Canopy.compile('grammar JS.ENV.OneRefTest\
- first <- second <First>\
- second <- "bar" <Second>')
-
- OneRefTestParser.First = { first: function() { return '1'} }
- OneRefTestParser.Second = { second: function() { return '2'} }
- }})
-
- it('extends the result with the root type', function() { with(this) {
- assertEqual( '2', OneRefTestParser.parse('bar').second() )
- }})
-
- it('extends the result with the reference type', function() { with(this) {
- assertEqual( '1', OneRefTestParser.parse('bar').first() )
- }})
- }})
-
describe('where the root contains the reference as part of a sequence', function() { with(this) {
before(function() { with(this) {
Canopy.compile('grammar JS.ENV.OneRefWithSequenceTest\

0 comments on commit 84588e5

Please sign in to comment.