On Tue Nov 19 19:34:48 2024 +0000, Jacek Caban wrote:
Being able to express that `todo_wine` sounds useful then. I guess that would be a reason to decouple property array from todos. It would mean passing twice properties that are missing in Wine, but that doesn't seem too bad, esp. if we could use it to decrypt the test. One way I could imagine it would be to have a global helper that's not at all specific to prototypes (so no special "constructor" property handling):
function test_own_props(obj, props, todos) { // we can just use something like todo_wine_if(todos && todos.indexOf(prop_name) != 1) }
Move all your test to separated tests, "prototypes" is long enough. Then define a local helper:
function check(constr, props, todos) { // a hack really, but also an interesting test on its own; we don't need todo_wine for constructor property after it ok(constr.prototype.constructor === constr, "..."); props.push("constructor"); // concatenate arrays from arguments[3..arguments.length-1]; this gives a convenient way to handle version specific props test_own_props(constr.prototype, props, todos); }
The test would be then a series of calls, like:
check(CustomEvent, ["detail", "initCustomEvent"]); check(MessageEvent, ["data", "initMessageEvent", "origin", "source"], null, v >= 10 ? ["ports"] : null); check(Evemt, ["AT_TARGET", ...], ["AT_TARGET", ...]);
I replied too soon, for version-specific cases, it may be more convenient to just do it in-place instead of the concatenation above, that would be: ``` check(MessageEvent, ["data", "initMessageEvent", "origin", v >= 10 ? "ports" : null, "source"]); ```