weekly release 2.4dev
[moodle.git] / lib / yuilib / 3.7.1 / build / dump / dump-coverage.js
blobcd222047d57a1273fd1fba14f1d948ead5691648
1 /*
2 YUI 3.7.1 (build 5627)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 if (typeof _yuitest_coverage == "undefined"){
8     _yuitest_coverage = {};
9     _yuitest_coverline = function(src, line){
10         var coverage = _yuitest_coverage[src];
11         if (!coverage.lines[line]){
12             coverage.calledLines++;
13         }
14         coverage.lines[line]++;
15     };
16     _yuitest_coverfunc = function(src, name, line){
17         var coverage = _yuitest_coverage[src],
18             funcId = name + ":" + line;
19         if (!coverage.functions[funcId]){
20             coverage.calledFunctions++;
21         }
22         coverage.functions[funcId]++;
23     };
25 _yuitest_coverage["build/dump/dump.js"] = {
26     lines: {},
27     functions: {},
28     coveredLines: 0,
29     calledLines: 0,
30     coveredFunctions: 0,
31     calledFunctions: 0,
32     path: "build/dump/dump.js",
33     code: []
35 _yuitest_coverage["build/dump/dump.js"].code=["YUI.add('dump', function (Y, NAME) {","","/**"," * Returns a simple string representation of the object or array."," * Other types of objects will be returned unprocessed.  Arrays"," * are expected to be indexed.  Use object notation for"," * associative arrays."," *"," * If included, the dump method is added to the YUI instance."," *"," * @module dump"," */","","    var L = Y.Lang,","        OBJ = '{...}',","        FUN = 'f(){...}',","        COMMA = ', ',","        ARROW = ' => ',","","    /**","     * Returns a simple string representation of the object or array.","     * Other types of objects will be returned unprocessed.  Arrays","     * are expected to be indexed.","     *","     * @method dump","     * @param {Object} o The object to dump.","     * @param {Number} d How deep to recurse child objects, default 3.","     * @return {String} the dump result.","     * @for YUI","     */","    dump = function(o, d) {","        var i, len, s = [], type = L.type(o);","","        // Cast non-objects to string","        // Skip dates because the std toString is what we want","        // Skip HTMLElement-like objects because trying to dump","        // an element will cause an unhandled exception in FF 2.x","        if (!L.isObject(o)) {","            return o + '';","        } else if (type == 'date') {","            return o;","        } else if (o.nodeType && o.tagName) {","            return o.tagName + '#' + o.id;","        } else if (o.document && o.navigator) {","            return 'window';","        } else if (o.location && o.body) {","            return 'document';","        } else if (type == 'function') {","            return FUN;","        }","","        // dig into child objects the depth specifed. Default 3","        d = (L.isNumber(d)) ? d : 3;","","        // arrays [1, 2, 3]","        if (type == 'array') {","            s.push('[');","            for (i = 0, len = o.length; i < len; i = i + 1) {","                if (L.isObject(o[i])) {","                    s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);","                } else {","                    s.push(o[i]);","                }","                s.push(COMMA);","            }","            if (s.length > 1) {","                s.pop();","            }","            s.push(']');","        // regexp /foo/","        } else if (type == 'regexp') {","            s.push(o.toString());","        // objects {k1 => v1, k2 => v2}","        } else {","            s.push('{');","            for (i in o) {","                if (o.hasOwnProperty(i)) {","                    try {","                        s.push(i + ARROW);","                        if (L.isObject(o[i])) {","                            s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);","                        } else {","                            s.push(o[i]);","                        }","                        s.push(COMMA);","                    } catch (e) {","                        s.push('Error: ' + e.message);","                    }","                }","            }","            if (s.length > 1) {","                s.pop();","            }","            s.push('}');","        }","","        return s.join('');","    };","","    Y.dump = dump;","    L.dump = dump;","","","","}, '3.7.1', {\"requires\": [\"yui-base\"]});"];
36 _yuitest_coverage["build/dump/dump.js"].lines = {"1":0,"14":0,"32":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"53":0,"56":0,"57":0,"58":0,"59":0,"60":0,"62":0,"64":0,"66":0,"67":0,"69":0,"71":0,"72":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"83":0,"85":0,"87":0,"91":0,"92":0,"94":0,"97":0,"100":0,"101":0};
37 _yuitest_coverage["build/dump/dump.js"].functions = {"dump:31":0,"(anonymous 1):1":0};
38 _yuitest_coverage["build/dump/dump.js"].coveredLines = 44;
39 _yuitest_coverage["build/dump/dump.js"].coveredFunctions = 2;
40 _yuitest_coverline("build/dump/dump.js", 1);
41 YUI.add('dump', function (Y, NAME) {
43 /**
44  * Returns a simple string representation of the object or array.
45  * Other types of objects will be returned unprocessed.  Arrays
46  * are expected to be indexed.  Use object notation for
47  * associative arrays.
48  *
49  * If included, the dump method is added to the YUI instance.
50  *
51  * @module dump
52  */
54     _yuitest_coverfunc("build/dump/dump.js", "(anonymous 1)", 1);
55 _yuitest_coverline("build/dump/dump.js", 14);
56 var L = Y.Lang,
57         OBJ = '{...}',
58         FUN = 'f(){...}',
59         COMMA = ', ',
60         ARROW = ' => ',
62     /**
63      * Returns a simple string representation of the object or array.
64      * Other types of objects will be returned unprocessed.  Arrays
65      * are expected to be indexed.
66      *
67      * @method dump
68      * @param {Object} o The object to dump.
69      * @param {Number} d How deep to recurse child objects, default 3.
70      * @return {String} the dump result.
71      * @for YUI
72      */
73     dump = function(o, d) {
74         _yuitest_coverfunc("build/dump/dump.js", "dump", 31);
75 _yuitest_coverline("build/dump/dump.js", 32);
76 var i, len, s = [], type = L.type(o);
78         // Cast non-objects to string
79         // Skip dates because the std toString is what we want
80         // Skip HTMLElement-like objects because trying to dump
81         // an element will cause an unhandled exception in FF 2.x
82         _yuitest_coverline("build/dump/dump.js", 38);
83 if (!L.isObject(o)) {
84             _yuitest_coverline("build/dump/dump.js", 39);
85 return o + '';
86         } else {_yuitest_coverline("build/dump/dump.js", 40);
87 if (type == 'date') {
88             _yuitest_coverline("build/dump/dump.js", 41);
89 return o;
90         } else {_yuitest_coverline("build/dump/dump.js", 42);
91 if (o.nodeType && o.tagName) {
92             _yuitest_coverline("build/dump/dump.js", 43);
93 return o.tagName + '#' + o.id;
94         } else {_yuitest_coverline("build/dump/dump.js", 44);
95 if (o.document && o.navigator) {
96             _yuitest_coverline("build/dump/dump.js", 45);
97 return 'window';
98         } else {_yuitest_coverline("build/dump/dump.js", 46);
99 if (o.location && o.body) {
100             _yuitest_coverline("build/dump/dump.js", 47);
101 return 'document';
102         } else {_yuitest_coverline("build/dump/dump.js", 48);
103 if (type == 'function') {
104             _yuitest_coverline("build/dump/dump.js", 49);
105 return FUN;
106         }}}}}}
108         // dig into child objects the depth specifed. Default 3
109         _yuitest_coverline("build/dump/dump.js", 53);
110 d = (L.isNumber(d)) ? d : 3;
112         // arrays [1, 2, 3]
113         _yuitest_coverline("build/dump/dump.js", 56);
114 if (type == 'array') {
115             _yuitest_coverline("build/dump/dump.js", 57);
116 s.push('[');
117             _yuitest_coverline("build/dump/dump.js", 58);
118 for (i = 0, len = o.length; i < len; i = i + 1) {
119                 _yuitest_coverline("build/dump/dump.js", 59);
120 if (L.isObject(o[i])) {
121                     _yuitest_coverline("build/dump/dump.js", 60);
122 s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);
123                 } else {
124                     _yuitest_coverline("build/dump/dump.js", 62);
125 s.push(o[i]);
126                 }
127                 _yuitest_coverline("build/dump/dump.js", 64);
128 s.push(COMMA);
129             }
130             _yuitest_coverline("build/dump/dump.js", 66);
131 if (s.length > 1) {
132                 _yuitest_coverline("build/dump/dump.js", 67);
133 s.pop();
134             }
135             _yuitest_coverline("build/dump/dump.js", 69);
136 s.push(']');
137         // regexp /foo/
138         } else {_yuitest_coverline("build/dump/dump.js", 71);
139 if (type == 'regexp') {
140             _yuitest_coverline("build/dump/dump.js", 72);
141 s.push(o.toString());
142         // objects {k1 => v1, k2 => v2}
143         } else {
144             _yuitest_coverline("build/dump/dump.js", 75);
145 s.push('{');
146             _yuitest_coverline("build/dump/dump.js", 76);
147 for (i in o) {
148                 _yuitest_coverline("build/dump/dump.js", 77);
149 if (o.hasOwnProperty(i)) {
150                     _yuitest_coverline("build/dump/dump.js", 78);
151 try {
152                         _yuitest_coverline("build/dump/dump.js", 79);
153 s.push(i + ARROW);
154                         _yuitest_coverline("build/dump/dump.js", 80);
155 if (L.isObject(o[i])) {
156                             _yuitest_coverline("build/dump/dump.js", 81);
157 s.push((d > 0) ? L.dump(o[i], d - 1) : OBJ);
158                         } else {
159                             _yuitest_coverline("build/dump/dump.js", 83);
160 s.push(o[i]);
161                         }
162                         _yuitest_coverline("build/dump/dump.js", 85);
163 s.push(COMMA);
164                     } catch (e) {
165                         _yuitest_coverline("build/dump/dump.js", 87);
166 s.push('Error: ' + e.message);
167                     }
168                 }
169             }
170             _yuitest_coverline("build/dump/dump.js", 91);
171 if (s.length > 1) {
172                 _yuitest_coverline("build/dump/dump.js", 92);
173 s.pop();
174             }
175             _yuitest_coverline("build/dump/dump.js", 94);
176 s.push('}');
177         }}
179         _yuitest_coverline("build/dump/dump.js", 97);
180 return s.join('');
181     };
183     _yuitest_coverline("build/dump/dump.js", 100);
184 Y.dump = dump;
185     _yuitest_coverline("build/dump/dump.js", 101);
186 L.dump = dump;
190 }, '3.7.1', {"requires": ["yui-base"]});