Permalink
Browse files

Fixed json test after master -> ie10 merge

  • Loading branch information...
2 parents ae609ab + f968f0f commit 05f25fa8ef15f896b4526eff7b49ef52adc0939a @davglass committed Oct 6, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -13,7 +13,7 @@ YUI.add('json-parse', function (Y, NAME) {
*
* <p>The <code>json</code> module is a rollup of <code>json-parse</code> and
* <code>json-stringify</code>.</p>
- *
+ *
* <p>As their names suggest, <code>json-parse</code> adds support for parsing
* JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing
* JavaScript data into JSON strings (Y.JSON.stringify). You may choose to
@@ -39,7 +39,8 @@ YUI.add('json-parse', function (Y, NAME) {
// All internals kept private for security reasons
function fromGlobal(ref) {
- return (Y.config.win || this || {})[ref];
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
}
@@ -109,7 +110,7 @@ var _JSON = fromGlobal('JSON'),
* @private
*/
_UNSAFE = /[^\],:{}\s]/,
-
+
/**
* Replaces specific unicode characters with their appropriate \unnnn
* format. Some browsers ignore certain characters during eval.
@@ -175,7 +176,7 @@ var _JSON = fromGlobal('JSON'),
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
-
+
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
@@ -188,7 +189,7 @@ var _JSON = fromGlobal('JSON'),
throw new SyntaxError('JSON.parse');
};
-
+
Y.namespace('JSON').parse = function (s,reviver) {
if (typeof s !== 'string') {
s += '';

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -13,7 +13,7 @@ YUI.add('json-parse', function (Y, NAME) {
*
* <p>The <code>json</code> module is a rollup of <code>json-parse</code> and
* <code>json-stringify</code>.</p>
- *
+ *
* <p>As their names suggest, <code>json-parse</code> adds support for parsing
* JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing
* JavaScript data into JSON strings (Y.JSON.stringify). You may choose to
@@ -39,7 +39,8 @@ YUI.add('json-parse', function (Y, NAME) {
// All internals kept private for security reasons
function fromGlobal(ref) {
- return (Y.config.win || this || {})[ref];
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
}
@@ -109,7 +110,7 @@ var _JSON = fromGlobal('JSON'),
* @private
*/
_UNSAFE = /[^\],:{}\s]/,
-
+
/**
* Replaces specific unicode characters with their appropriate \unnnn
* format. Some browsers ignore certain characters during eval.
@@ -175,7 +176,7 @@ var _JSON = fromGlobal('JSON'),
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
-
+
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
@@ -188,7 +189,7 @@ var _JSON = fromGlobal('JSON'),
throw new SyntaxError('JSON.parse');
};
-
+
Y.namespace('JSON').parse = function (s,reviver) {
if (typeof s !== 'string') {
s += '';

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -8,7 +8,12 @@ YUI.add('json-stringify', function (Y, NAME) {
* @for JSON
* @static
*/
-var _JSON = (Y.config.win || {}).JSON,
+// All internals kept private for security reasons
+function fromGlobal(ref) {
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
+}
+var _JSON = fromGlobal('JSON'),
Lang = Y.Lang,
isFunction= Lang.isFunction,
isObject = Lang.isObject,

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -8,7 +8,12 @@ YUI.add('json-stringify', function (Y, NAME) {
* @for JSON
* @static
*/
-var _JSON = (Y.config.win || {}).JSON,
+// All internals kept private for security reasons
+function fromGlobal(ref) {
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
+}
+var _JSON = fromGlobal('JSON'),
Lang = Y.Lang,
isFunction= Lang.isFunction,
isObject = Lang.isObject,
View
@@ -1,6 +1,26 @@
JSON Utility Change History
===========================
+3.7.3
+-----
+
+* Updated to use native JSON when in Node.js
+
+3.7.2
+-----
+
+* No changes.
+
+3.7.1
+-----
+
+* No changes.
+
+3.7.0
+-----
+
+* No changes.
+
3.6.0
-----
View
@@ -11,7 +11,7 @@
*
* <p>The <code>json</code> module is a rollup of <code>json-parse</code> and
* <code>json-stringify</code>.</p>
- *
+ *
* <p>As their names suggest, <code>json-parse</code> adds support for parsing
* JSON data (Y.JSON.parse) and <code>json-stringify</code> for serializing
* JavaScript data into JSON strings (Y.JSON.stringify). You may choose to
@@ -37,7 +37,8 @@
// All internals kept private for security reasons
function fromGlobal(ref) {
- return (Y.config.win || this || {})[ref];
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
}
@@ -107,7 +108,7 @@ var _JSON = fromGlobal('JSON'),
* @private
*/
_UNSAFE = /[^\],:{}\s]/,
-
+
/**
* Replaces specific unicode characters with their appropriate \unnnn
* format. Some browsers ignore certain characters during eval.
@@ -173,7 +174,7 @@ var _JSON = fromGlobal('JSON'),
// incorrectly by some browser implementations.
// NOTE: This modifies the input if such characters are found!
s = s.replace(_UNICODE_EXCEPTIONS, _escapeException);
-
+
// Test for any remaining invalid characters
if (!_UNSAFE.test(s.replace(_ESCAPES,'@').
replace(_VALUES,']').
@@ -186,7 +187,7 @@ var _JSON = fromGlobal('JSON'),
throw new SyntaxError('JSON.parse');
};
-
+
Y.namespace('JSON').parse = function (s,reviver) {
if (typeof s !== 'string') {
s += '';
View
@@ -6,7 +6,12 @@
* @for JSON
* @static
*/
-var _JSON = (Y.config.win || {}).JSON,
+// All internals kept private for security reasons
+function fromGlobal(ref) {
+ var g = ((typeof global === 'object') ? global : undefined);
+ return ((Y.UA.nodejs && g) ? g : (Y.config.win || {}))[ref];
+}
+var _JSON = fromGlobal('JSON'),
Lang = Y.Lang,
isFunction= Lang.isFunction,
isObject = Lang.isObject,
View
@@ -5,7 +5,7 @@
"json-stringify"
],
"submodules": {
- "json-parse": { "requires": [ "yui-base" ] },
+ "json-parse": { "requires": [ "yui-base" ] },
"json-stringify": { "requires": [ "yui-base" ] }
}
}
@@ -0,0 +1,18 @@
+YUI.add('node-tests', function (Y) {
+
+ var Assert = Y.Assert,
+ suite = new Y.Test.Suite('json Node.js tests');
+
+ suite.add(new Y.Test.Case({
+ name: 'Check native in Node.js',
+ 'should be using native parse': function() {
+ Assert.isTrue(Y.JSON.useNativeParse, 'should be true here');
+ },
+ 'should be using native stringify': function() {
+ Assert.isTrue(Y.JSON.useNativeStringify, 'should be true here');
+ }
+ }));
+
+ Y.Test.Runner.add(suite);
+
+});
@@ -0,0 +1,33 @@
+#!/usr/bin/env node
+
+process.chdir(__dirname);
+
+var YUITest = require('yuitest'),
+ path = require('path'),
+ fs = require('fs'),
+ dir = path.join(__dirname, '../../../../build-npm/'),
+ YUI = require(dir).YUI,
+ json;
+
+
+YUI({useSync: true }).use('test', function(Y) {
+ Y.Test.Runner = YUITest.TestRunner;
+ Y.Test.Case = YUITest.TestCase;
+ Y.Test.Suite = YUITest.TestSuite;
+ Y.Assert = YUITest.Assert;
+
+ Y.applyConfig({
+ modules: {
+ 'json-tests': {
+ fullpath: path.join(__dirname, '../unit/assets/json-tests.js'),
+ requires: ['json', 'test']
+ }
+ }
+ });
+
+ Y.use('json-tests');
+
+ Y.Test.Runner.setName('json cli tests');
+
+});
+
@@ -0,0 +1,33 @@
+#!/usr/bin/env node
+
+process.chdir(__dirname);
+
+var YUITest = require('yuitest'),
+ path = require('path'),
+ fs = require('fs'),
+ dir = path.join(__dirname, '../../../../build-npm/'),
+ YUI = require(dir).YUI,
+ json;
+
+
+YUI({useSync: true }).use('test', function(Y) {
+ Y.Test.Runner = YUITest.TestRunner;
+ Y.Test.Case = YUITest.TestCase;
+ Y.Test.Suite = YUITest.TestSuite;
+ Y.Assert = YUITest.Assert;
+
+ Y.applyConfig({
+ modules: {
+ 'node-tests': {
+ fullpath: path.join(__dirname, './lib/node.js'),
+ requires: ['json', 'test']
+ }
+ }
+ });
+
+ Y.use('node-tests');
+
+ Y.Test.Runner.setName('json cli tests');
+
+});
+
Oops, something went wrong.

0 comments on commit 05f25fa

Please sign in to comment.