Пример #1
0
		it('should generate items whose productions belong', function() {
			var productions = [
				new Production('stmt', [ 'if', 'x', '{', 'stmt', '}' ]),
				new Production('stmt', [ 'id', '=', 'x' ])
			], items = Grammar.items(productions);

			expect(items).to.all.satisfy(function(e) {
				return _.contains(productions, e.production);
			});
		});
Пример #2
0
		it('should generate the correct number of items', function() {
			var production = new Production('stmt', [ 'if', 'x', '{', 'stmt', '}' ]),
				items = Grammar.items([production]);

			expect(items).to.have.length(production.derives.length+1);
		});