~rharding/loggerhead/yui3.7.1

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/querystring-stringify/querystring-stringify-coverage.js

  • Committer: Rick Harding
  • Date: 2012-11-07 15:51:42 UTC
  • Revision ID: rick.harding@canonical.com-20121107155142-56lxp77hopixc9xf
Fix the collapsable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
    };
 
24
}
 
25
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"] = {
 
26
    lines: {},
 
27
    functions: {},
 
28
    coveredLines: 0,
 
29
    calledLines: 0,
 
30
    coveredFunctions: 0,
 
31
    calledFunctions: 0,
 
32
    path: "build/querystring-stringify/querystring-stringify.js",
 
33
    code: []
 
34
};
 
35
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].code=["YUI.add('querystring-stringify', function (Y, NAME) {","","/**"," * Provides Y.QueryString.stringify method for converting objects to Query Strings."," *"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," */","","var QueryString = Y.namespace(\"QueryString\"),","    stack = [],","    L = Y.Lang;","","/**"," * Provides Y.QueryString.escape method to be able to override default encoding"," * method.  This is important in cases where non-standard delimiters are used, if"," * the delimiters would not normally be handled properly by the builtin"," * (en|de)codeURIComponent functions."," * Default: encodeURIComponent"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," **/","QueryString.escape = encodeURIComponent;","","/**"," * <p>Converts an arbitrary value to a Query String representation.</p>"," *"," * <p>Objects with cyclical references will trigger an exception.</p>"," *"," * @method stringify"," * @public"," * @param obj {Variant} any arbitrary value to convert to query string"," * @param cfg {Object} (optional) Configuration object.  The three"," * supported configurations are:"," * <ul><li>sep: When defined, the value will be used as the key-value"," * separator.  The default value is \"&\".</li>"," * <li>eq: When defined, the value will be used to join the key to"," * the value.  The default value is \"=\".</li>"," * <li>arrayKey: When set to true, the key of an array will have the"," * '[]' notation appended to the key.  The default value is false."," * </li></ul>"," * @param name {String} (optional) Name of the current key, for handling children recursively."," * @static"," */","QueryString.stringify = function (obj, c, name) {","    var begin, end, i, l, n, s,","        sep = c && c.sep ? c.sep : \"&\",","        eq = c && c.eq ? c.eq : \"=\",","        aK = c && c.arrayKey ? c.arrayKey : false;","","    if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {","        return name ? QueryString.escape(name) + eq : '';","    }","","    if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {","        obj =+ obj;","    }","","    if (L.isNumber(obj) || L.isString(obj)) {","        return QueryString.escape(name) + eq + QueryString.escape(obj);","    }","","    if (L.isArray(obj)) {","        s = [];","        name = aK ? name + '[]' : name;","        l = obj.length;","        for (i = 0; i < l; i++) {","            s.push( QueryString.stringify(obj[i], c, name) );","        }","","        return s.join(sep);","    }","    // now we know it's an object.","","    // Check for cyclical references in nested objects","    for (i = stack.length - 1; i >= 0; --i) {","        if (stack[i] === obj) {","            throw new Error(\"QueryString.stringify. Cyclical reference\");","        }","    }","","    stack.push(obj);","    s = [];","    begin = name ? name + '[' : '';","    end = name ? ']' : '';","    for (i in obj) {","        if (obj.hasOwnProperty(i)) {","            n = begin + i + end;","            s.push(QueryString.stringify(obj[i], c, n));","        }","    }","","    stack.pop();","    s = s.join(sep);","    if (!s && name) {","        return name + \"=\";","    }","","    return s;","};","","","}, '3.7.1', {\"requires\": [\"yui-base\"]});"];
 
36
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].lines = {"1":0,"12":0,"27":0,"49":0,"50":0,"55":0,"56":0,"59":0,"60":0,"63":0,"64":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"75":0,"80":0,"81":0,"82":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"97":0,"98":0,"99":0,"100":0,"103":0};
 
37
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].functions = {"stringify:49":0,"(anonymous 1):1":0};
 
38
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredLines = 34;
 
39
_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredFunctions = 2;
 
40
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 1);
 
41
YUI.add('querystring-stringify', function (Y, NAME) {
 
42
 
 
43
/**
 
44
 * Provides Y.QueryString.stringify method for converting objects to Query Strings.
 
45
 *
 
46
 * @module querystring
 
47
 * @submodule querystring-stringify
 
48
 * @for QueryString
 
49
 * @static
 
50
 */
 
51
 
 
52
_yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "(anonymous 1)", 1);
 
53
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 12);
 
54
var QueryString = Y.namespace("QueryString"),
 
55
    stack = [],
 
56
    L = Y.Lang;
 
57
 
 
58
/**
 
59
 * Provides Y.QueryString.escape method to be able to override default encoding
 
60
 * method.  This is important in cases where non-standard delimiters are used, if
 
61
 * the delimiters would not normally be handled properly by the builtin
 
62
 * (en|de)codeURIComponent functions.
 
63
 * Default: encodeURIComponent
 
64
 * @module querystring
 
65
 * @submodule querystring-stringify
 
66
 * @for QueryString
 
67
 * @static
 
68
 **/
 
69
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 27);
 
70
QueryString.escape = encodeURIComponent;
 
71
 
 
72
/**
 
73
 * <p>Converts an arbitrary value to a Query String representation.</p>
 
74
 *
 
75
 * <p>Objects with cyclical references will trigger an exception.</p>
 
76
 *
 
77
 * @method stringify
 
78
 * @public
 
79
 * @param obj {Variant} any arbitrary value to convert to query string
 
80
 * @param cfg {Object} (optional) Configuration object.  The three
 
81
 * supported configurations are:
 
82
 * <ul><li>sep: When defined, the value will be used as the key-value
 
83
 * separator.  The default value is "&".</li>
 
84
 * <li>eq: When defined, the value will be used to join the key to
 
85
 * the value.  The default value is "=".</li>
 
86
 * <li>arrayKey: When set to true, the key of an array will have the
 
87
 * '[]' notation appended to the key.  The default value is false.
 
88
 * </li></ul>
 
89
 * @param name {String} (optional) Name of the current key, for handling children recursively.
 
90
 * @static
 
91
 */
 
92
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 49);
 
93
QueryString.stringify = function (obj, c, name) {
 
94
    _yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "stringify", 49);
 
95
_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 50);
 
96
var begin, end, i, l, n, s,
 
97
        sep = c && c.sep ? c.sep : "&",
 
98
        eq = c && c.eq ? c.eq : "=",
 
99
        aK = c && c.arrayKey ? c.arrayKey : false;
 
100
 
 
101
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 55);
 
102
if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {
 
103
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 56);
 
104
return name ? QueryString.escape(name) + eq : '';
 
105
    }
 
106
 
 
107
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 59);
 
108
if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {
 
109
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 60);
 
110
obj =+ obj;
 
111
    }
 
112
 
 
113
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 63);
 
114
if (L.isNumber(obj) || L.isString(obj)) {
 
115
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 64);
 
116
return QueryString.escape(name) + eq + QueryString.escape(obj);
 
117
    }
 
118
 
 
119
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 67);
 
120
if (L.isArray(obj)) {
 
121
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 68);
 
122
s = [];
 
123
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 69);
 
124
name = aK ? name + '[]' : name;
 
125
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 70);
 
126
l = obj.length;
 
127
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 71);
 
128
for (i = 0; i < l; i++) {
 
129
            _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 72);
 
130
s.push( QueryString.stringify(obj[i], c, name) );
 
131
        }
 
132
 
 
133
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 75);
 
134
return s.join(sep);
 
135
    }
 
136
    // now we know it's an object.
 
137
 
 
138
    // Check for cyclical references in nested objects
 
139
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 80);
 
140
for (i = stack.length - 1; i >= 0; --i) {
 
141
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 81);
 
142
if (stack[i] === obj) {
 
143
            _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 82);
 
144
throw new Error("QueryString.stringify. Cyclical reference");
 
145
        }
 
146
    }
 
147
 
 
148
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 86);
 
149
stack.push(obj);
 
150
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 87);
 
151
s = [];
 
152
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 88);
 
153
begin = name ? name + '[' : '';
 
154
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 89);
 
155
end = name ? ']' : '';
 
156
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 90);
 
157
for (i in obj) {
 
158
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 91);
 
159
if (obj.hasOwnProperty(i)) {
 
160
            _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 92);
 
161
n = begin + i + end;
 
162
            _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 93);
 
163
s.push(QueryString.stringify(obj[i], c, n));
 
164
        }
 
165
    }
 
166
 
 
167
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 97);
 
168
stack.pop();
 
169
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 98);
 
170
s = s.join(sep);
 
171
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 99);
 
172
if (!s && name) {
 
173
        _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 100);
 
174
return name + "=";
 
175
    }
 
176
 
 
177
    _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 103);
 
178
return s;
 
179
};
 
180
 
 
181
 
 
182
}, '3.7.1', {"requires": ["yui-base"]});