<commit_before>import {should} from 'chai';
import Vector from '../../src/module/vector.js';

should();

describe('Vector', () => {

	describe('#constructor', () => {
		let numVector = new Vector(10, 20);
		let vecVector = new Vector(numVector);
		it('constructor by number x & y', () => {
			numVector.x.should.equal(10);
			numVector.y.should.equal(20);
		});

		it('constructor by Vector', () => {
			vecVector.x.should.equal(10);
			vecVector.y.should.equal(20);
		});
	});
	describe('#math test', () => {
		let v1 = new Vector(120,200),
				v2 = new Vector(-20,50);
		it('add', () => {
			let result = v1.add(v2);
			let res = [result.x, result.y];
			res.should.to.be.deep.equal([100, 250]);
		});
		it('sub', () => {
			let result = v1.substract(v2);
			result.x.should.to.be.equal(140);
			result.y.should.to.be.equal(150);
		});
		it('normalize', () => {
			let result = v1.substract(v2);
			result.x.should.to.be.equal(140);
			result.y.should.to.be.equal(150);
		});
	});
});<commit_msg>完善vector测试<commit_after>import {should} from 'chai';
import Vector from '../../src/module/vector.js';

should();

describe('Vector', () => {

	describe('#constructor', () => {
		let numVector = new Vector(10, 20);
		let vecVector = new Vector(numVector);
		it('constructor by number x & y', () => {
			numVector.x.should.equal(10);
			numVector.y.should.equal(20);
		});

		it('constructor by Vector', () => {
			vecVector.x.should.equal(10);
			vecVector.y.should.equal(20);
		});
	});
	describe('#math test', () => {
		let v1 = new Vector(120,200),
				v2 = new Vector(-20,50);
		it('add', () => {
			let result = v1.add(v2);
			let res = [result.x, result.y];
			res.should.to.be.deep.equal([100, 250]);
		});
		it('sub', () => {
			let result = v1.substract(v2);
			result.x.should.to.be.equal(140);
			result.y.should.to.be.equal(150);
		});
		it('normalize', () => {
			let result = v1.substract(v2);
			result.x.should.to.be.equal(140);
			result.y.should.to.be.equal(150);
		});
		it('dotProduct', () => {
			let result = v1.dotProduct(v2);
			result.should.to.be.equal(7600);
		});
	});
});
{'fraction_non_alphanumeric': 0.2317596566523605, 'fraction_numerical': 0.04864091559370529, 'mean_word_length': 3.2816326530612243, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '4302824', 'n_tokens_mistral': 955, 'n_tokens_neox': 805, 'n_words': 131}