js/src/jit-test/lib/referencesVia.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/lib/referencesVia.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function referencesVia(from, edge, to) {
     1.9 +    if (typeof findReferences !== 'function')
    1.10 +        return true;
    1.11 +
    1.12 +    edge = "edge: " + edge;
    1.13 +    var edges = findReferences(to);
    1.14 +    if (edge in edges && edges[edge].indexOf(from) != -1)
    1.15 +        return true;
    1.16 +
    1.17 +    // Be nice: make it easy to fix if the edge name has just changed.
    1.18 +    var alternatives = [];
    1.19 +    for (var e in edges) {
    1.20 +        if (edges[e].indexOf(from) != -1)
    1.21 +            alternatives.push(e);
    1.22 +    }
    1.23 +    if (alternatives.length == 0) {
    1.24 +        print("referent not referred to by referrer after all");
    1.25 +    } else {
    1.26 +        print("referent is not referenced via: " + uneval(edge));
    1.27 +        print("but it is referenced via:       " + uneval(alternatives));
    1.28 +    }
    1.29 +    print("all incoming edges, from any object:");
    1.30 +    for (var e in edges)
    1.31 +        print(e);
    1.32 +    return false;
    1.33 +}

mercurial