Skip to content

Commit

Permalink
Remove unneeded complexity from test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwokcb committed Dec 12, 2024
1 parent 9ca8c95 commit febb67a
Showing 1 changed file with 3 additions and 83 deletions.
86 changes: 3 additions & 83 deletions javascript/MaterialXTest/element.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,104 +167,24 @@ describe('Element', () =>

describe('Equivalence', () =>
{
let mx, doc, doc2, inputMap, inputMap2, floatInputs;
let mx, doc, doc2

before(async () => {
mx = await Module();

doc = mx.createDocument();
inputMap = new Map([
["color3", " 1.0, +2.0, 3.0 "],
["color4", "1.0, 2.00, 0.3000, -4"],
["integer", " 12 "],
["matrix33", "01.0, 2.0, 0000.2310, 01.0, 2.0, 0000.2310, 01.0, 2.0, 0000.2310"],
["matrix44", "01.0, 2.0, 0000.2310, 0.100, 01.0, 2.0, 0000.2310, 0.100, 01.0, 2.0, 0000.2310, 0.100, 01.0, 2.0, 0000.2310, 0.100"],
["vector2", "1.0, 0.012345608"],
["vector3", " 1.0, +2.0, 3.0 "],
["vector4", "1.0, 2.00, 0.3000, -4"],
["string", "mystring"],
["boolean", "false"],
["filename", "filename1"],
["float", " 1.2e-10 "],
["float", " 00.1000 "]
]);

let index = 0;
let child = doc.addNodeGraph("mygraph");
let graph = child;
const comment = doc.addChildOfCategory(mx.CommentElement.CATEGORY);
comment.setDocString("Comment 1");

inputMap.forEach((value, key) => {
if (index == 0)
{
let input = graph.addInput(`input_${index}`, key);
if (key === "float") {
input.setAttribute(mx.ValueElement.UI_MIN_ATTRIBUTE, " 0.0100 ");
input.setAttribute(mx.ValueElement.UI_MAX_ATTRIBUTE, " 01.0100 ");
index++;
} else {
input.setName(`input_${key}`);
}
input.setValueString(value, key);
}
});

doc.addNodeGraph("graph");
doc2 = mx.createDocument();
inputMap2 = new Map([
["color3", " 1.0, 2.0, 3.0 "],
["color4", "1, 2, 0.3, -4"],

["integer", "12"],
["matrix33", "1, 2, 0.231, 1, 2, 0.231, 1, 2, 0.231, 1, 2, 0.231"],
["matrix44", "1, 2, 0.231, 0.1, 1, 2, 0.231, 0.1, 1, 2, 0.231, 0.1, 1, 2, 0.231, 0.1"],
["vector2", "1, 0.012345611"],
["string", "mystring"],
["boolean", "false"],
["color3", "1, 2, 3"],
["vector3", "1, 2, 3"],
["vector4", "1, 2, 0.3, -4"],
["filename", "filename1"],
["float", "1.2e-10"],
["float", "0.1"]
]);

index = 0;
let child2 = doc2.addNodeGraph("mygraph");
let graph2 = child2;
floatInputs = [];

inputMap2.forEach((value, key) => {
if (index == 0) {
let input = graph2.addInput(`input_${index}`, key);
input.setValueString(value, key);
if (key === "float") {
input.setAttribute(mx.ValueElement.UI_MIN_ATTRIBUTE, " 0.01");
input.setAttribute(mx.ValueElement.UI_MAX_ATTRIBUTE, " 1.01");
floatInputs.push(input);
index++;
} else {
input.setName(`input_${key}`);
}
}
});

const comment2 = doc2.addChildOfCategory(mx.CommentElement.CATEGORY);
comment2.setDocString("Comment 2");
const comment3 = doc2.addChildOfCategory(mx.CommentElement.CATEGORY);
comment3.setDocString("Comment 3");
doc2.addNodeGraph("graph1");
});

it('Compare document equivalency', () =>
{
let options = new mx.ElementEquivalenceOptions();

let differences = {};
options.performValueComparisons = false;
let result = doc.isEquivalent(doc2, options, differences);
expect(result).to.be.false;
expect(differences.message).to.not.be.empty;

result = doc.isEquivalent(doc2, options, undefined);
expect(result).to.be.false;
});
Expand Down

0 comments on commit febb67a

Please sign in to comment.