gpu.js/test/internal/backend/web-gl/function-node/astMemberExpression.js
Robert Plummer f48409cc56 fix: Web side tests
Also cleanup moving methods around for reuse and so code can be more concise.
Removed some older references, where now we use `this.thread.x` or `this.output.x`.
Removed some older methods we no longer use (astFunctionPrototype).
Removed some overloaded functions from webgl1 and webgl2 glsl.  We no longer need them.
Removed some references to `=== null` in favor of truthy.  `if (undefined === null)` is true, and can lead to unexpected results, where we really wanted truthy, and is simpler to write.
2019-02-05 21:17:20 -05:00

33 lines
1.1 KiB
JavaScript

const { assert, test, module: describe } = require('qunit');
const { WebGLFunctionNode } = require(process.cwd() + '/src');
describe('WebGLFunctionNode.astMemberExpression()');
// TODO: finish
function run(value, name, type) {
const expression = acorn.parse(value).body[0].expression;
const instance = {
isState: () => false,
astMemberExpressionUnroll: () => name,
declarations: {
[name]: type
},
astGetFirstAvailableName: () => name,
getVariableType: () => type,
astGeneric: () => {},
pushState: () => {},
popState: () => {},
isAstVariable: WebGLFunctionNode.prototype.isAstVariable,
getVariableSignature: WebGLFunctionNode.prototype.getVariableSignature,
memberExpressionPropertyMarkup: WebGLFunctionNode.prototype.memberExpressionPropertyMarkup,
};
return WebGLFunctionNode.prototype.astMemberExpression.call(instance, expression, []).join('');
}
// test('it[]', () => {
// console.log(run('it[0];', 'it', 'Array'));
// console.log(run('it[0][1];', 'it', 'Array'));
// console.log(run('it[0][1][2];', 'it', 'Array'));
// console.log(run('it[this.thread.x + 100];', 'it', 'Array'));
// });