Best JavaScript code snippet using wpt
webxr_test_asserts.js
Source:webxr_test_asserts.js
1// Utility assert functions.2// Relies on resources/testharness.js to be included before this file.3// Relies on webxr_test_constants.js to be included before this file.4// Relies on webxr_math_utils.js to be included before this file.5// |p1|, |p2| - objects with x, y, z, w components that are floating point numbers.6// Returns the name of mismatching component between p1 and p2.7const get_mismatched_component = function(p1, p2, epsilon = FLOAT_EPSILON) {8 for (const v of ['x', 'y', 'z', 'w']) {9 if (Math.abs(p1[v] - p2[v]) > epsilon) {10 return v;11 }12 }13 return null;14}15// |p1|, |p2| - objects with x, y, z, w components that are floating point numbers.16// |epsilon| - float specifying precision17// |prefix| - string used as a prefix for logging18const assert_point_approx_equals = function(p1, p2, epsilon = FLOAT_EPSILON, prefix = "") {19 if (p1 == null && p2 == null) {20 return;21 }22 assert_not_equals(p1, null, prefix + "p1 must be non-null");23 assert_not_equals(p2, null, prefix + "p2 must be non-null");24 const mismatched_component = get_mismatched_component(p1, p2, epsilon);25 if (mismatched_component !== null) {26 let error_message = prefix + ' Point comparison failed.\n';27 error_message += ` p1: {x: ${p1.x}, y: ${p1.y}, z: ${p1.z}, w: ${p1.w}}\n`;28 error_message += ` p2: {x: ${p2.x}, y: ${p2.y}, z: ${p2.z}, w: ${p2.w}}\n`;29 error_message += ` Difference in component ${mismatched_component} exceeded the given epsilon.\n`;30 assert_approx_equals(p2[mismatched_component], p1[mismatched_component], epsilon, error_message);31 }32};33const assert_orientation_approx_equals = function(q1, q2, epsilon = FLOAT_EPSILON, prefix = "") {34 if (q1 == null && q2 == null) {35 return;36 }37 assert_not_equals(q1, null, prefix + "q1 must be non-null");38 assert_not_equals(q2, null, prefix + "q2 must be non-null");39 const q2_flipped = flip_quaternion(q2);40 const mismatched_component = get_mismatched_component(q1, q2, epsilon);41 const mismatched_component_flipped = get_mismatched_component(q1, q2_flipped, epsilon);42 if (mismatched_component !== null && mismatched_component_flipped !== null) {43 // q1 doesn't match neither q2 nor -q2, so it definitely does not represent the same orientations,44 // log an assert failure.45 let error_message = prefix + ' Orientation comparison failed.\n';46 error_message += ` p1: {x: ${q1.x}, y: ${q1.y}, z: ${q1.z}, w: ${q1.w}}\n`;47 error_message += ` p2: {x: ${q2.x}, y: ${q2.y}, z: ${q2.z}, w: ${q2.w}}\n`;48 error_message += ` Difference in component ${mismatched_component} exceeded the given epsilon.\n`;49 assert_approx_equals(q2[mismatched_component], q1[mismatched_component], epsilon, error_message);50 }51}52// |p1|, |p2| - objects with x, y, z, w components that are floating point numbers.53// |epsilon| - float specifying precision54// |prefix| - string used as a prefix for logging55const assert_point_significantly_not_equals = function(p1, p2, epsilon = FLOAT_EPSILON, prefix = "") {56 assert_not_equals(p1, null, prefix + "p1 must be non-null");57 assert_not_equals(p2, null, prefix + "p2 must be non-null");58 let mismatched_component = get_mismatched_component(p1, p2, epsilon);59 if (mismatched_component === null) {60 let error_message = prefix + ' Point comparison failed.\n';61 error_message += ` p1: {x: ${p1.x}, y: ${p1.y}, z: ${p1.z}, w: ${p1.w}}\n`;62 error_message += ` p2: {x: ${p2.x}, y: ${p2.y}, z: ${p2.z}, w: ${p2.w}}\n`;63 error_message += ` Difference in components did not exceeded the given epsilon.\n`;64 assert_unreached(error_message);65 }66};67// |t1|, |t2| - objects containing position and orientation.68// |epsilon| - float specifying precision69// |prefix| - string used as a prefix for logging70const assert_transform_approx_equals = function(t1, t2, epsilon = FLOAT_EPSILON, prefix = "") {71 if (t1 == null && t2 == null) {72 return;73 }74 assert_not_equals(t1, null, prefix + "t1 must be non-null");75 assert_not_equals(t2, null, prefix + "t2 must be non-null");76 assert_point_approx_equals(t1.position, t2.position, epsilon, prefix + "positions must be equal");77 assert_orientation_approx_equals(t1.orientation, t2.orientation, epsilon, prefix + "orientations must be equal");78};79// |m1|, |m2| - arrays of floating point numbers80// |epsilon| - float specifying precision81// |prefix| - string used as a prefix for logging82const assert_matrix_approx_equals = function(m1, m2, epsilon = FLOAT_EPSILON, prefix = "") {83 if (m1 == null && m2 == null) {84 return;85 }86 assert_not_equals(m1, null, prefix + "m1 must be non-null");87 assert_not_equals(m2, null, prefix + "m2 must be non-null");88 assert_equals(m1.length, 16, prefix + "m1 must have length of 16");89 assert_equals(m2.length, 16, prefix + "m2 must have length of 16");90 let mismatched_element = -1;91 for (let i = 0; i < 16; ++i) {92 if (Math.abs(m1[i] - m2[i]) > epsilon) {93 mismatched_element = i;94 break;95 }96 }97 if (mismatched_element > -1) {98 let error_message = prefix + 'Matrix comparison failed.\n';99 error_message += ' Difference in element ' + mismatched_element +100 ' exceeded the given epsilon.\n';101 error_message += ' Matrix 1: [' + m1.join(',') + ']\n';102 error_message += ' Matrix 2: [' + m2.join(',') + ']\n';103 assert_approx_equals(104 m1[mismatched_element], m2[mismatched_element], epsilon,105 error_message);106 }107};108// |m1|, |m2| - arrays of floating point numbers109// |epsilon| - float specifying precision110// |prefix| - string used as a prefix for logging111const assert_matrix_significantly_not_equals = function(m1, m2, epsilon = FLOAT_EPSILON, prefix = "") {112 if (m1 == null && m2 == null) {113 return;114 }115 assert_not_equals(m1, null, prefix + "m1 must be non-null");116 assert_not_equals(m2, null, prefix + "m2 must be non-null");117 assert_equals(m1.length, 16, prefix + "m1 must have length of 16");118 assert_equals(m2.length, 16, prefix + "m2 must have length of 16");119 let mismatch = false;120 for (let i = 0; i < 16; ++i) {121 if (Math.abs(m1[i] - m2[i]) > epsilon) {122 mismatch = true;123 break;124 }125 }126 if (!mismatch) {127 let m1_str = '[';128 let m2_str = '[';129 for (let i = 0; i < 16; ++i) {130 m1_str += m1[i] + (i < 15 ? ', ' : '');131 m2_str += m2[i] + (i < 15 ? ', ' : '');132 }133 m1_str += ']';134 m2_str += ']';135 let error_message = prefix + 'Matrix comparison failed.\n';136 error_message +=137 ' No element exceeded the given epsilon ' + epsilon + '.\n';138 error_message += ' Matrix A: ' + m1_str + '\n';139 error_message += ' Matrix B: ' + m2_str + '\n';140 assert_unreached(error_message);141 }142};143// |r1|, |r2| - XRRay objects144// |epsilon| - float specifying precision145// |prefix| - string used as a prefix for logging146const assert_ray_approx_equals = function(r1, r2, epsilon = FLOAT_EPSILON, prefix = "") {147 assert_point_approx_equals(r1.origin, r2.origin, epsilon, prefix + "origin:");148 assert_point_approx_equals(r1.direction, r2.direction, epsilon, prefix + "direction:");149 assert_matrix_approx_equals(r1.matrix, r2.matrix, epsilon, prefix + "matrix:");...
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var q2_flipped = wptoolkit.q2_flipped;3var data = [1,2,3,4,5,6,7,8,9,10];4var result = q2_flipped(data);5console.log(result);6var wptoolkit = require('wptoolkit');7var q2_flipped = wptoolkit.q2_flipped;8var data = [1,2,3,4,5,6,7,8,9,10];9var result = q2_flipped(data);10console.log(result);11var wptoolkit = require('wptoolkit');12var q2_flipped = wptoolkit.q2_flipped;13var data = [1,2,3,4,5,6,7,8,9,10];14var result = q2_flipped(data);15console.log(result);16var wptoolkit = require('wptoolkit');17var q2_flipped = wptoolkit.q2_flipped;18var data = [1,2,3,4,5,6,7,8,9,10];19var result = q2_flipped(data);20console.log(result);21var wptoolkit = require('wptoolkit');22var q2_flipped = wptoolkit.q2_flipped;23var data = [1,2,3,4,5,6,7,8,9,10];24var result = q2_flipped(data);25console.log(result);26var wptoolkit = require('wptoolkit');27var q2_flipped = wptoolkit.q2_flipped;28var data = [1,2,3,4,5,6,7,8,9,10];29var result = q2_flipped(data);
Using AI Code Generation
1var wpt = require('wpt');2 if (err) {3 console.error(err);4 } else {5 console.log(data);6 }7});8const userSchema = new Schema({9 name: {10 },11 username: {12 },13 email: {14 },15 password: {16 },17 date: {18 }19});20router.get('/search', ensureAuthenticated, (req, res) => {21 res.render('search');22});23router.post('/search', ensureAuthenticated, (req, res) => {24 const { search } = req.body;25 User.find({ $text: { $search: search } })26 .then(users => res.json(users))27 .catch(err => res.send(err));28});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getTesters(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6var wpt = require('wpt');7var wpt = new WebPageTest('www.webpagetest.org');8 if (err) return console.error(err);9 console.log(data);10});11var wpt = require('wpt');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) return console.error(err);14 console.log(data);15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) return console.error(err);19 console.log(data);20});21var wpt = require('wpt');22var wpt = new WebPageTest('www.webpagetest.org');23 if (err) return console.error(err);24 console.log(data);25});26var wpt = require('wpt');27var wpt = new WebPageTest('www.webpagetest.org');28 if (err) return console.error(err);
Using AI Code Generation
1var wptools = require('wptools');2var q2_flipped = wptools.q2_flipped;3var q2 = wptools.q2;4var q2_flipped = wptools.q2_flipped;5q2_flipped('Albert Einstein')6 .then(function(page) {7 console.log(page.data);8 })9 .catch(function(err) {10 console.log(err);11 });
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var q2_flipped = wptoolkit.q2_flipped;3var q2 = wptoolkit.q2;4var q2_flipped = wptoolkit.q2_flipped;5var q3 = wptoolkit.q3;6var q4 = wptoolkit.q4;7var q4_flipped = wptoolkit.q4_flipped;8var q5 = wptoolkit.q5;9var q6 = wptoolkit.q6;10var q2_flipped = require('wptoolkit').q2_flipped;11var q2 = require('wptoolkit').q2;12var q2_flipped = require('wptoolkit').q2_flipped;13var q3 = require('wptoolkit').q3;14var q4 = require('wptoolkit').q4;15var q4_flipped = require('wptoolkit').q4_flipped;16var q5 = require('wptoolkit').q5;17var q6 = require('wptoolkit').q6;18var q2_flipped = require('wptoolkit').q2_flipped;19var q2 = require('wptoolkit').q2;20var q2_flipped = require('wptoolkit').q2_flipped;21var q3 = require('wptoolkit').q3;22var q4 = require('wptoolkit').q4;23var q4_flipped = require('wptoolkit').q4_flipped;24var q5 = require('wptoolkit').q5;25var q6 = require('wptoolkit').q6;
Using AI Code Generation
1var wpt = require('wpt');2wpt.q2_flipped(1, 2, function(err, data){3 if(err) throw err;4 console.log(data);5});6var wpt = require('wpt');7wpt.q2_flipped(1, 2, function(err, data){8 if(err) throw err;9 console.log(data);10});11var wpt = require('wpt');12wpt.q2_flipped(1, 2, function(err, data){13 if(err) throw err;14 console.log(data);15});16var wpt = require('wpt');17wpt.q2_flipped(1, 2, function(err, data){18 if(err) throw err;19 console.log(data);20});21var wpt = require('wpt');22wpt.q2_flipped(1, 2, function(err, data){23 if(err) throw err;24 console.log(data);25});26var wpt = require('wpt');27wpt.q2_flipped(1, 2, function(err, data){28 if(err) throw err;29 console.log(data);30});31var wpt = require('wpt');32wpt.q2_flipped(1, 2, function(err, data){33 if(err) throw err;34 console.log(data);35});36var wpt = require('wpt');37wpt.q2_flipped(1, 2, function(err, data){38 if(err) throw err;39 console.log(data);40});41var wpt = require('wpt');42wpt.q2_flipped(1, 2, function(err, data){43 if(err) throw err;44 console.log(data);45});46var wpt = require('wpt');47wpt.q2_flipped(1, 2
Using AI Code Generation
1var wpt = require('wpt')2 if (err) console.log(err);3 else {4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) console.log(err);6 else console.log(data);7 });8 }9});10{ statusCode: 200,11 { testId: '150620_9E_2R',12{ statusCode: 200,13 { testId: '150620_9E_2R',
Using AI Code Generation
1var wptoolbox = require('wptoolbox');2var q2_flipped = new wptoolbox.q2_flipped();3q2_flipped.q2_flipped(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);4console.log(q2_flipped.output);5var wptoolbox = require('wptoolbox');6var q2_flipped = new wptoolbox.q2_flipped();7q2_flipped.q2_flipped(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);8console.log(q2_flipped.output);9var wptoolbox = require('wptoolbox');10var q2_flipped = new wptoolbox.q2_flipped();11q2_flipped.q2_flipped(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);12console.log(q2_flipped.output);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!