<commit_before>var expect =  require('chai').expect;
var fs = require('fs');
var PEG = require('pegjs');

describe('PlantUML Relationships', function() {

	var	parser;
	before(function(){
		var grammar = fs.readFileSync('./PlantUML.pegjs', 'utf8');
		parser = PEG.buildParser(grammar);
	});

	describe('basic relationships', function(){
		
		describe('length 1', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A - B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A . B');
			});
		});
		
		describe('length 2', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A -- B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A .. B');
			});
		});
		
		describe('length 5', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A ----- B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A ..... B');
			});
		});
		
	});
	
	describe('Realtionship types', function(){
		it('Extention', function(){
			var parsed = parser.parse('A -|> B');
		});
		
		it('Composition', function(){
			var parsed = parser.parse('A -* B');
		});
		
		it('Aggregation', function(){
			var parsed = parser.parse('A -o B');
		});
		
		it('Arrowed', function(){
			var parsed = parser.parse('A -> B');
		});
		
		it('Lollipop', function(){
			var parsed = parser.parse('A -() B');
		});
	});
	
	describe('Cardinality values', function(){	
		it('single number left', function(){
			var parsed = parser.parse('A "1" -- B');
		});
		
		it('single number right', function(){
			var parsed = parser.parse('A -- "1" B');
		});
		
		it('single number both', function(){
			var parsed = parser.parse('A "1" -- "1" B');
		});
		
		it('range number left', function(){
			var parsed = parser.parse('A "*..n" -- B');
		});
		
		it('range number right', function(){
			var parsed = parser.parse('A -- "*..n" B');
		});
		
		it('range number both', function(){
			var parsed = parser.parse('A "*..n" -- "*..n" B');
		});
	});
	
	describe('Relationship label', function(){
		it('non literal', function(){
			var parsed = parser.parse('A - B: has some relation \n');
		});
		
		it('literal string', function(){
			var parsed = parser.parse('A -> B: "has some symbols: -> class" \n');
		});
	});
	
	describe('Relationship label arrow', function(){
		it('point right', function(){
			var parsed = parser.parse('A - B: has some relation > \n');
		});
		
		it('point left', function(){
			var parsed = parser.parse('A - B: has some relation < \n');
		});
		
		it('label requried before', function(){
			expect(function(){parser.parse('A - B: < \n')}).to.throw(parser.SyntaxError);
		});
	});
	
}); // end relations<commit_msg>remove new lines from relationship spec<commit_after>var expect =  require('chai').expect;
var fs = require('fs');
var PEG = require('pegjs');

describe('PlantUML Relationships', function() {

	var	parser;
	before(function(){
		var grammar = fs.readFileSync('./PlantUML.pegjs', 'utf8');
		parser = PEG.buildParser(grammar);
	});

	describe('basic relationships', function(){
		
		describe('length 1', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A - B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A . B');
			});
		});
		
		describe('length 2', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A -- B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A .. B');
			});
		});
		
		describe('length 5', function(){
			it ('dashed', function(){
				var parsed = parser.parse('A ----- B');
			});
			
			it('doted', function(){
				var parsed = parser.parse('A ..... B');
			});
		});
		
	});
	
	describe('Realtionship types', function(){
		it('Extention', function(){
			var parsed = parser.parse('A -|> B');
		});
		
		it('Composition', function(){
			var parsed = parser.parse('A -* B');
		});
		
		it('Aggregation', function(){
			var parsed = parser.parse('A -o B');
		});
		
		it('Arrowed', function(){
			var parsed = parser.parse('A -> B');
		});
		
		it('Lollipop', function(){
			var parsed = parser.parse('A -() B');
		});
	});
	
	describe('Cardinality values', function(){	
		it('single number left', function(){
			var parsed = parser.parse('A "1" -- B');
		});
		
		it('single number right', function(){
			var parsed = parser.parse('A -- "1" B');
		});
		
		it('single number both', function(){
			var parsed = parser.parse('A "1" -- "1" B');
		});
		
		it('range number left', function(){
			var parsed = parser.parse('A "*..n" -- B');
		});
		
		it('range number right', function(){
			var parsed = parser.parse('A -- "*..n" B');
		});
		
		it('range number both', function(){
			var parsed = parser.parse('A "*..n" -- "*..n" B');
		});
	});
	
	describe('Relationship label', function(){
		it('non literal', function(){
			var parsed = parser.parse('A - B: has some relation');
		});
		
		it('literal string', function(){
			var parsed = parser.parse('A -> B: "has some symbols: -> class"');
		});
	});
	
	describe('Relationship label arrow', function(){
		it('point right', function(){
			var parsed = parser.parse('A - B: has some relation >');
		});
		
		it('point left', function(){
			var parsed = parser.parse('A - B: has some relation <');
		});
		
		it('label requried before', function(){
			expect(function(){parser.parse('A - B: <')}).to.throw(parser.SyntaxError);
		});
	});
	
}); // end relations
{'fraction_non_alphanumeric': 0.2256400810462332, 'fraction_numerical': 0.002947135752440597, 'mean_word_length': 3.0582959641255605, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6406352', 'n_tokens_mistral': 2102, 'n_tokens_neox': 1703, 'n_words': 452}