<commit_before>/**
 * @author bhouston / http://exocortex.com
 * @author TristanVALCKE / https://github.com/Itee
 */
/* global QUnit */
import { Euler } from '../../../../src/math/Euler';
import { Matrix4 } from '../../../../src/math/Matrix4';
import { Quaternion } from '../../../../src/math/Quaternion';
import { Vector3 } from '../../../../src/math/Vector3';
import { x, y, z } from './Constants.tests';

const eulerZero = new Euler( 0, 0, 0, "XYZ" );
const eulerAxyz = new Euler( 1, 0, 0, "XYZ" );
const eulerAzyx = new Euler( 0, 1, 0, "ZYX" );

function matrixEquals4( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	if ( a.elements.length != b.elements.length ) {

		return false;

	}

	for ( var i = 0, il = a.elements.length; i < il; i ++ ) {

		var delta = a.elements[ i ] - b.elements[ i ];
		if ( delta > tolerance ) {

			return false;

		}

	}

	return true;

}

function eulerEquals( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );

	return ( diff < tolerance );

}

function quatEquals( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z ) + Math.abs( a.w - b.w );

	return ( diff < tolerance );

}

export default QUnit.module( 'Maths', () => {

	QUnit.module( 'Euler', () => {

		// INSTANCING
		QUnit.test( "Instancing", ( assert ) => {

			var a = new Euler();
			assert.ok( a.equals( eulerZero ), "Passed!" );
			assert.ok( ! a.equals( eulerAxyz ), "Passed!" );
			assert.ok( ! a.equals( eulerAzyx ), "Passed!" );

		} );

		// STATIC STUFF
		QUnit.todo( "RotationOrders", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		QUnit.todo( "DefaultOrder", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		// PROPERTIES STUFF
		QUnit.todo( "x", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		QUnit.todo( "y", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		QUnit.todo( "z", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		QUnit.todo( "order", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		// PUBLIC STUFF
		QUnit.todo( "isEuler", ( assert ) => {
<commit_msg>add euler unittests<commit_after>/**
 * @author bhouston / http://exocortex.com
 * @author TristanVALCKE / https://github.com/Itee
 */
/* global QUnit */
import { Euler } from '../../../../src/math/Euler';
import { Matrix4 } from '../../../../src/math/Matrix4';
import { Quaternion } from '../../../../src/math/Quaternion';
import { Vector3 } from '../../../../src/math/Vector3';
import { x, y, z } from './Constants.tests';

const eulerZero = new Euler( 0, 0, 0, "XYZ" );
const eulerAxyz = new Euler( 1, 0, 0, "XYZ" );
const eulerAzyx = new Euler( 0, 1, 0, "ZYX" );

function matrixEquals4( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	if ( a.elements.length != b.elements.length ) {

		return false;

	}

	for ( var i = 0, il = a.elements.length; i < il; i ++ ) {

		var delta = a.elements[ i ] - b.elements[ i ];
		if ( delta > tolerance ) {

			return false;

		}

	}

	return true;

}

function eulerEquals( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z );

	return ( diff < tolerance );

}

function quatEquals( a, b, tolerance ) {

	tolerance = tolerance || 0.0001;
	var diff = Math.abs( a.x - b.x ) + Math.abs( a.y - b.y ) + Math.abs( a.z - b.z ) + Math.abs( a.w - b.w );

	return ( diff < tolerance );

}

export default QUnit.module( 'Maths', () => {

	QUnit.module( 'Euler', () => {

		// INSTANCING
		QUnit.test( "Instancing", ( assert ) => {

			var a = new Euler();
			assert.ok( a.equals( eulerZero ), "Passed!" );
			assert.ok( ! a.equals( eulerAxyz ), "Passed!" );
			assert.ok( ! a.equals( eulerAzyx ), "Passed!" );

		} );

		// STATIC STUFF
		QUnit.test( "RotationOrders", ( assert ) => {

			assert.ok( Array.isArray( Euler.RotationOrders ), "Passed!" );
			assert.deepEqual( Euler.RotationOrders, [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ], "Passed!" );

		} );

		QUnit.test( "DefaultOrder", ( assert ) => {

			assert.equal( Euler.DefaultOrder, "XYZ", "Passed!" );


		} );

		// PROPERTIES STUFF
		QUnit.test( "x", ( assert ) => {

			var a = new Euler();
			assert.ok( a.x === 0, "Passed!" );

			a = new Euler( 1, 2, 3 );
			assert.ok( a.x === 1, "Passed!" );

			a = new Euler( 4, 5, 6, "XYZ" );
			assert.ok( a.x === 4, "Passed!" );

			a = new Euler( 7, 8, 9, "XYZ" );
			a.x = 10;
			assert.ok( a.x === 10, "Passed!" );

			a = new Euler( 11, 12, 13, "XYZ" );
			var b = false;
			a._onChange( function () {

				b = true;

			} );
			a.x = 14;
			assert.ok( b, "Passed!" );
			assert.ok( a.x === 14, "Passed!" );

		} );

		QUnit.test( "y", ( assert ) => {


			var a = new Euler();
			assert.ok( a.y === 0, "Passed!" );

			a = new Euler( 1, 2, 3 );
			assert.ok( a.y === 2, "Passed!" );

			a = new Euler( 4, 5, 6, "XYZ" );
			assert.ok( a.y === 5, "Passed!" );

			a = new Euler( 7, 8, 9, "XYZ" );
			a.y = 10;
			assert.ok( a.y === 10, "Passed!" );

			a = new Euler( 11, 12, 13, "XYZ" );
			var b = false;
			a._onChange( function () {

				b = true;

			} );
			a.y = 14;
			assert.ok( b, "Passed!" );
			assert.ok( a.y === 14, "Passed!" );

		} );

		QUnit.test( "z", ( assert ) => {


			var a = new Euler();
			assert.ok( a.z === 0, "Passed!" );

			a = new Euler( 1, 2, 3 );
			assert.ok( a.z === 3, "Passed!" );

			a = new Euler( 4, 5, 6, "XYZ" );
			assert.ok( a.z === 6, "Passed!" );

			a = new Euler( 7, 8, 9, "XYZ" );
			a.z = 10;
			assert.ok( a.z === 10, "Passed!" );

			a = new Euler( 11, 12, 13, "XYZ" );
			var b = false;
			a._onChange( function () {

				b = true;

			} );
			a.z = 14;
			assert.ok( b, "Passed!" );
			assert.ok( a.z === 14, "Passed!" );

		} );

		QUnit.todo( "order", ( assert ) => {

			assert.ok( false, "everything's gonna be alright" );

		} );

		// PUBLIC STUFF
		QUnit.todo( "isEuler", ( assert ) => {

{'fraction_non_alphanumeric': 0.22085092562520298, 'fraction_numerical': 0.02240987333549854, 'mean_word_length': 2.3933884297520662, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, 'https://': 2, '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': '2743605', 'n_tokens_mistral': 2883, 'n_tokens_neox': 2420, 'n_words': 643}