From 3adb8be65949cdb0274f6da6033be44fa12ef136 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 16 Jan 2017 11:02:13 +0100 Subject: [PATCH] Add an interesting bi-di sample to js samples --- test/samples-all.generated.js | 2 +- test/samples/run-editor-sample-js.txt | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/samples-all.generated.js b/test/samples-all.generated.js index 6a91948b..6eb9035c 100644 --- a/test/samples-all.generated.js +++ b/test/samples-all.generated.js @@ -46,7 +46,7 @@ define([], function() { return[ }, { "name": "run-editor-sample-js.txt", - "content": "/*\r\n © Microsoft. All rights reserved.\r\n\r\nhttps://microsoft.com\r\nblablahttp://en.wikipedia.org/wiki/Timisoara bla bla\r\nblabla\thttp://en.wikipedia.org/wiki/Timisoara bla bla\r\n\r\n This library is supported for use in Windows Tailored Apps only.\r\n\r\n Build: 6.2.8100.0 \r\n Version: 0.5 \r\n*/\r\n'a string\\\r\non multiple lines';\r\n(function (global, undefined) {\r\n\t\"use strict\";\r\n\tundefinedVariable = {}; undefinedVariable.bar = 5;\r\n\tundefinedVariable.foo = 5; undefinedVariable.baz = 10;\r\n\r\n function initializeProperties(target, members) { \r\n var keys = Object.keys(members);\r\n var properties;\t\t\t\r\n var i, len;\r\n for (i = 0, len = keys.length; i < len; i++) { \r\n var key = keys[i];\r\n var enumerable = key.charCodeAt(0) !== /*_*/95;\r\n var member = members[key];\r\n if (member && typeof member === 'object') {\r\n if (member.value !== undefined || typeof member.get === 'function' || typeof member.set === 'function') {\t\t\r\n if (member.enumerable === undefined) {\r\n member.enumerable = enumerable;\r\n }\r\n properties = properties || {};\r\n properties[key] = member;\r\n continue;\r\n } \r\n }\r\n if (!enumerable) {\r\n properties = properties || {};\r\n properties[key] = { value: member, enumerable: enumerable, configurable: true, writable: true }\r\n continue;\r\n }\r\n target[key] = member;\r\n }\r\n if (properties) {\r\n Object.defineProperties(target, properties);\r\n }\r\n }\r\n\r\n (function (rootNamespace) {\r\n\r\n // Create the rootNamespace in the global namespace\r\n if (!global[rootNamespace]) {\r\n global[rootNamespace] = Object.create(Object.prototype);\r\n }\r\n\r\n // Cache the rootNamespace we just created in a local variable\r\n var _rootNamespace = global[rootNamespace];\r\n if (!_rootNamespace.Namespace) {\r\n _rootNamespace.Namespace = Object.create(Object.prototype);\r\n }\r\n\r\n function defineWithParent(parentNamespace, name, members) {\r\n /// \r\n /// Defines a new namespace with the specified name, under the specified parent namespace.\r\n /// \r\n /// \r\n /// The parent namespace which will contain the new namespace.\r\n /// \r\n /// \r\n /// Name of the new namespace.\r\n /// \r\n /// \r\n /// Members in the new namespace.\r\n /// \r\n /// \r\n /// The newly defined namespace.\r\n /// \r\n var currentNamespace = parentNamespace,\r\n namespaceFragments = name.split(\".\");\r\n\r\n for (var i = 0, len = namespaceFragments.length; i < len; i++) {\r\n var namespaceName = namespaceFragments[i];\r\n if (!currentNamespace[namespaceName]) {\r\n Object.defineProperty(currentNamespace, namespaceName, \r\n { value: {}, writable: false, enumerable: true, configurable: true }\r\n );\r\n }\r\n currentNamespace = currentNamespace[namespaceName];\r\n }\r\n\r\n if (members) {\r\n initializeProperties(currentNamespace, members);\r\n }\r\n\r\n return currentNamespace;\r\n };\r\n\r\n function define(name, members) {\r\n /// \r\n /// Defines a new namespace with the specified name.\r\n /// \r\n /// \r\n /// Name of the namespace. This could be a dot-separated nested name.\r\n /// \r\n /// \r\n /// Members in the new namespace.\r\n /// \r\n /// \r\n /// The newly defined namespace.\r\n /// \r\n return defineWithParent(global, name, members);\r\n }\r\n\r\n // Establish members of the \"WinJS.Namespace\" namespace\r\n Object.defineProperties(_rootNamespace.Namespace, {\r\n\r\n defineWithParent: { value: defineWithParent, writable: true, enumerable: true },\r\n\r\n define: { value: define, writable: true, enumerable: true }\r\n\r\n });\r\n\r\n })(\"WinJS\");\r\n\r\n (function (WinJS) {\r\n\r\n function define(constructor, instanceMembers, staticMembers) {\r\n /// \r\n /// Defines a class using the given constructor and with the specified instance members.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The set of instance fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The set of static fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n constructor = constructor || function () { };\r\n if (instanceMembers) {\r\n initializeProperties(constructor.prototype, instanceMembers);\r\n }\r\n if (staticMembers) {\r\n initializeProperties(constructor, staticMembers);\r\n }\r\n return constructor;\r\n }\r\n\r\n function derive(baseClass, constructor, instanceMembers, staticMembers) {\r\n /// \r\n /// Uses prototypal inheritance to create a sub-class based on the supplied baseClass parameter.\r\n /// \r\n /// \r\n /// The class to inherit from.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The set of instance fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The set of static fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n if (baseClass) {\r\n constructor = constructor || function () { };\r\n var basePrototype = baseClass.prototype;\r\n constructor.prototype = Object.create(basePrototype);\r\n Object.defineProperty(constructor.prototype, \"_super\", { value: basePrototype });\r\n Object.defineProperty(constructor.prototype, \"constructor\", { value: constructor });\r\n if (instanceMembers) {\r\n initializeProperties(constructor.prototype, instanceMembers);\r\n }\r\n if (staticMembers) {\r\n initializeProperties(constructor, staticMembers);\r\n }\r\n return constructor;\r\n } else {\r\n return define(constructor, instanceMembers, staticMembers);\r\n }\r\n }\r\n\r\n function mix(constructor) {\r\n /// \r\n /// Defines a class using the given constructor and the union of the set of instance members\r\n /// specified by all the mixin objects. The mixin parameter list can be of variable length.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n constructor = constructor || function () { };\r\n var i, len;\r\n for (i = 0, len = arguments.length; i < len; i++) {\r\n initializeProperties(constructor.prototype, arguments[i]);\r\n }\r\n return constructor;\r\n }\r\n\r\n // Establish members of \"WinJS.Class\" namespace\r\n WinJS.Namespace.define(\"WinJS.Class\", {\r\n define: define,\r\n derive: derive,\r\n mix: mix\r\n });\r\n\r\n })(WinJS);\r\n\r\n})(this);" + "content": "/*\r\n © Microsoft. All rights reserved.\r\n\r\nhttps://microsoft.com\r\nblablahttp://en.wikipedia.org/wiki/Timisoara bla bla\r\nblabla\thttp://en.wikipedia.org/wiki/Timisoara bla bla\r\n\r\n This library is supported for use in Windows Tailored Apps only.\r\n\r\n Build: 6.2.8100.0\r\n Version: 0.5\r\n*/\r\n\r\nvar קודמות = \"מיותר קודמות צ'ט של, אם לשון העברית שינויים ויש, אם\";\r\n\r\n'a string\\\r\non multiple lines';\r\n(function (global, undefined) {\r\n\t\"use strict\";\r\n\tundefinedVariable = {}; undefinedVariable.bar = 5;\r\n\tundefinedVariable.foo = 5; undefinedVariable.baz = 10;\r\n\r\n function initializeProperties(target, members) {\r\n var keys = Object.keys(members);\r\n var properties;\r\n var i, len;\r\n for (i = 0, len = keys.length; i < len; i++) {\r\n var key = keys[i];\r\n var enumerable = key.charCodeAt(0) !== /*_*/95;\r\n var member = members[key];\r\n if (member && typeof member === 'object') {\r\n if (member.value !== undefined || typeof member.get === 'function' || typeof member.set === 'function') {\r\n if (member.enumerable === undefined) {\r\n member.enumerable = enumerable;\r\n }\r\n properties = properties || {};\r\n properties[key] = member;\r\n continue;\r\n }\r\n }\r\n if (!enumerable) {\r\n properties = properties || {};\r\n properties[key] = { value: member, enumerable: enumerable, configurable: true, writable: true }\r\n continue;\r\n }\r\n target[key] = member;\r\n }\r\n if (properties) {\r\n Object.defineProperties(target, properties);\r\n }\r\n }\r\n\r\n (function (rootNamespace) {\r\n\r\n // Create the rootNamespace in the global namespace\r\n if (!global[rootNamespace]) {\r\n global[rootNamespace] = Object.create(Object.prototype);\r\n }\r\n\r\n // Cache the rootNamespace we just created in a local variable\r\n var _rootNamespace = global[rootNamespace];\r\n if (!_rootNamespace.Namespace) {\r\n _rootNamespace.Namespace = Object.create(Object.prototype);\r\n }\r\n\r\n function defineWithParent(parentNamespace, name, members) {\r\n /// \r\n /// Defines a new namespace with the specified name, under the specified parent namespace.\r\n /// \r\n /// \r\n /// The parent namespace which will contain the new namespace.\r\n /// \r\n /// \r\n /// Name of the new namespace.\r\n /// \r\n /// \r\n /// Members in the new namespace.\r\n /// \r\n /// \r\n /// The newly defined namespace.\r\n /// \r\n var currentNamespace = parentNamespace,\r\n namespaceFragments = name.split(\".\");\r\n\r\n for (var i = 0, len = namespaceFragments.length; i < len; i++) {\r\n var namespaceName = namespaceFragments[i];\r\n if (!currentNamespace[namespaceName]) {\r\n Object.defineProperty(currentNamespace, namespaceName,\r\n { value: {}, writable: false, enumerable: true, configurable: true }\r\n );\r\n }\r\n currentNamespace = currentNamespace[namespaceName];\r\n }\r\n\r\n if (members) {\r\n initializeProperties(currentNamespace, members);\r\n }\r\n\r\n return currentNamespace;\r\n };\r\n\r\n function define(name, members) {\r\n /// \r\n /// Defines a new namespace with the specified name.\r\n /// \r\n /// \r\n /// Name of the namespace. This could be a dot-separated nested name.\r\n /// \r\n /// \r\n /// Members in the new namespace.\r\n /// \r\n /// \r\n /// The newly defined namespace.\r\n /// \r\n return defineWithParent(global, name, members);\r\n }\r\n\r\n // Establish members of the \"WinJS.Namespace\" namespace\r\n Object.defineProperties(_rootNamespace.Namespace, {\r\n\r\n defineWithParent: { value: defineWithParent, writable: true, enumerable: true },\r\n\r\n define: { value: define, writable: true, enumerable: true }\r\n\r\n });\r\n\r\n })(\"WinJS\");\r\n\r\n (function (WinJS) {\r\n\r\n function define(constructor, instanceMembers, staticMembers) {\r\n /// \r\n /// Defines a class using the given constructor and with the specified instance members.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The set of instance fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The set of static fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n constructor = constructor || function () { };\r\n if (instanceMembers) {\r\n initializeProperties(constructor.prototype, instanceMembers);\r\n }\r\n if (staticMembers) {\r\n initializeProperties(constructor, staticMembers);\r\n }\r\n return constructor;\r\n }\r\n\r\n function derive(baseClass, constructor, instanceMembers, staticMembers) {\r\n /// \r\n /// Uses prototypal inheritance to create a sub-class based on the supplied baseClass parameter.\r\n /// \r\n /// \r\n /// The class to inherit from.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The set of instance fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The set of static fields, properties and methods to be made available on the class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n if (baseClass) {\r\n constructor = constructor || function () { };\r\n var basePrototype = baseClass.prototype;\r\n constructor.prototype = Object.create(basePrototype);\r\n Object.defineProperty(constructor.prototype, \"_super\", { value: basePrototype });\r\n Object.defineProperty(constructor.prototype, \"constructor\", { value: constructor });\r\n if (instanceMembers) {\r\n initializeProperties(constructor.prototype, instanceMembers);\r\n }\r\n if (staticMembers) {\r\n initializeProperties(constructor, staticMembers);\r\n }\r\n return constructor;\r\n } else {\r\n return define(constructor, instanceMembers, staticMembers);\r\n }\r\n }\r\n\r\n function mix(constructor) {\r\n /// \r\n /// Defines a class using the given constructor and the union of the set of instance members\r\n /// specified by all the mixin objects. The mixin parameter list can be of variable length.\r\n /// \r\n /// \r\n /// A constructor function that will be used to instantiate this class.\r\n /// \r\n /// \r\n /// The newly defined class.\r\n /// \r\n constructor = constructor || function () { };\r\n var i, len;\r\n for (i = 0, len = arguments.length; i < len; i++) {\r\n initializeProperties(constructor.prototype, arguments[i]);\r\n }\r\n return constructor;\r\n }\r\n\r\n // Establish members of \"WinJS.Class\" namespace\r\n WinJS.Namespace.define(\"WinJS.Class\", {\r\n define: define,\r\n derive: derive,\r\n mix: mix\r\n });\r\n\r\n })(WinJS);\r\n\r\n})(this);" }, { "name": "run-editor-sample-msn-js.txt", diff --git a/test/samples/run-editor-sample-js.txt b/test/samples/run-editor-sample-js.txt index ce726bd3..8080c17a 100644 --- a/test/samples/run-editor-sample-js.txt +++ b/test/samples/run-editor-sample-js.txt @@ -7,9 +7,12 @@ blabla http://en.wikipedia.org/wiki/Timisoara bla bla This library is supported for use in Windows Tailored Apps only. - Build: 6.2.8100.0 - Version: 0.5 + Build: 6.2.8100.0 + Version: 0.5 */ + +var קודמות = "מיותר קודמות צ'ט של, אם לשון העברית שינויים ויש, אם"; + 'a string\ on multiple lines'; (function (global, undefined) { @@ -17,23 +20,23 @@ on multiple lines'; undefinedVariable = {}; undefinedVariable.bar = 5; undefinedVariable.foo = 5; undefinedVariable.baz = 10; - function initializeProperties(target, members) { + function initializeProperties(target, members) { var keys = Object.keys(members); - var properties; + var properties; var i, len; - for (i = 0, len = keys.length; i < len; i++) { + for (i = 0, len = keys.length; i < len; i++) { var key = keys[i]; var enumerable = key.charCodeAt(0) !== /*_*/95; var member = members[key]; if (member && typeof member === 'object') { - if (member.value !== undefined || typeof member.get === 'function' || typeof member.set === 'function') { + if (member.value !== undefined || typeof member.get === 'function' || typeof member.set === 'function') { if (member.enumerable === undefined) { member.enumerable = enumerable; } properties = properties || {}; properties[key] = member; continue; - } + } } if (!enumerable) { properties = properties || {}; @@ -82,7 +85,7 @@ on multiple lines'; for (var i = 0, len = namespaceFragments.length; i < len; i++) { var namespaceName = namespaceFragments[i]; if (!currentNamespace[namespaceName]) { - Object.defineProperty(currentNamespace, namespaceName, + Object.defineProperty(currentNamespace, namespaceName, { value: {}, writable: false, enumerable: true, configurable: true } ); }