How to use split method in Playwright Internal

Best JavaScript code snippet using playwright-internal

split-pane.js

Source:split-pane.js Github

copy

Full Screen

1/*!2Split Pane v0.9.33Copyright (c) 2014 - 2016 Simon Hagström4Released under the MIT license5https://raw.github.com/shagstrom/split-pane/master/LICENSE6*/7(function ($) {8 'use strict';9 var methods = {};10 methods.init = function() {11 var $splitPanes = this;12 $splitPanes.each(setMinHeightAndMinWidth);13 $splitPanes.children('.split-pane-divider').html('<div class="split-pane-divider-inner"></div>');14 $splitPanes.children('.split-pane-divider').on('touchstart mousedown', mousedownHandler);15 setTimeout(function() {16 // Doing this later because of an issue with Chrome (v23.0.1271.64) returning split-pane width = 017 // and triggering multiple resize events when page is being opened from an <a target="_blank"> .18 $splitPanes.each(attachResizeHandler);19 $(window).trigger('resize');20 }, 100);21 };22 methods.firstComponentSize = function(value) {23 this.each(function() {24 var $splitPane = $(this),25 components = getComponents($splitPane);26 if ($splitPane.is('.fixed-top')) {27 fixedTopHandler(components, components.divider.offsetTop)({pageY: value});28 } else if ($splitPane.is('.fixed-bottom')) {29 value = components.splitPane.offsetHeight -components.divider.offsetHeight - value;30 fixedBottomHandler(components, -components.last.offsetHeight)({pageY: -value});31 } else if ($splitPane.is('.horizontal-percent')) {32 value = components.splitPane.offsetHeight -components.divider.offsetHeight - value;33 horizontalPercentHandler(components, -components.last.offsetHeight)({pageY: -value});34 } else if ($splitPane.is('.fixed-left')) {35 fixedLeftHandler(components, components.divider.offsetLeft)({pageX: value});36 } else if ($splitPane.is('.fixed-right')) {37 value = components.splitPane.offsetWidth -components.divider.offsetWidth - value;38 fixedRightHandler(components, -components.last.offsetWidth)({pageX: -value});39 } else if ($splitPane.is('.vertical-percent')) {40 value = components.splitPane.offsetWidth -components.divider.offsetWidth - value;41 verticalPercentHandler(components, -components.last.offsetWidth)({pageX: -value});42 }43 });44 };45 methods.lastComponentSize = function(value) {46 this.each(function() {47 var $splitPane = $(this),48 components = getComponents($splitPane);49 if ($splitPane.is('.fixed-top')) {50 value = components.splitPane.offsetHeight -components.divider.offsetHeight - value;51 fixedTopHandler(components, components.divider.offsetTop)({pageY: value});52 } else if ($splitPane.is('.fixed-bottom')) {53 fixedBottomHandler(components, -components.last.offsetHeight)({pageY: -value});54 } else if ($splitPane.is('.horizontal-percent')) {55 horizontalPercentHandler(components, -components.last.offsetHeight)({pageY: -value});56 } else if ($splitPane.is('.fixed-left')) {57 value = components.splitPane.offsetWidth -components.divider.offsetWidth - value;58 fixedLeftHandler(components, components.divider.offsetLeft)({pageX: value});59 } else if ($splitPane.is('.fixed-right')) {60 fixedRightHandler(components, -components.last.offsetWidth)({pageX: -value});61 } else if ($splitPane.is('.vertical-percent')) {62 verticalPercentHandler(components, -components.last.offsetWidth)({pageX: -value});63 }64 });65 };66 $.fn.splitPane = function(method) {67 methods[method || 'init'].apply(this, $.grep(arguments, function(it, i) { return i > 0; }));68 };69 function setMinHeightAndMinWidth() {70 var $splitPane = $(this),71 components = getComponents($splitPane);72 if ($splitPane.is('.fixed-top, .fixed-bottom, .horizontal-percent')) {73 $splitPane.css('min-height', (minHeight(components.first) + minHeight(components.last) + $(components.divider).height()) + 'px');74 } else {75 $splitPane.css('min-width', (minWidth(components.first) + minWidth(components.last) + $(components.divider).width()) + 'px');76 }77 }78 function mousedownHandler(event) {79 event.preventDefault();80 var $divider = $(this),81 $splitPane = $divider.parent();82 $divider.addClass('dragged');83 if (event.type.match(/^touch/)) {84 $divider.addClass('touch');85 }86 var moveEventHandler = createMousemove($splitPane, pageXof(event), pageYof(event));87 $(document).on('touchmove mousemove', moveEventHandler);88 $(document).one('touchend mouseup', function(event) {89 $(document).off('touchmove mousemove', moveEventHandler);90 $divider.removeClass('dragged touch');91 $splitPane.trigger('dividerdragend', [ getComponentsSizes($splitPane) ]);92 });93 $splitPane.trigger('dividerdragstart', [ getComponentsSizes($splitPane) ]);94 }95 function getComponentsSizes($splitPane) {96 var property = $splitPane.is('.fixed-top, .fixed-bottom, .horizontal-percent') ?97 'height' : 'width';98 return {99 firstComponentSize: $splitPane.find('.split-pane-component:first')[property](),100 lastComponentSize: $splitPane.find('.split-pane-component:last')[property]()101 };102 }103 function attachResizeHandler() {104 var $splitPane = $(this),105 internalHandler = createParentresizeHandler($splitPane),106 parent = $splitPane.parent().closest('.split-pane')[0] || window;107 $(parent).on(parent === window ? 'resize' : 'splitpaneresize', function(event) {108 var target = event.target === document ? window : event.target;109 if (target === parent) {110 internalHandler(event);111 }112 });113 }114 function createParentresizeHandler($splitPane) {115 var components = getComponents($splitPane);116 if ($splitPane.is('.fixed-top')) {117 return function(event) {118 var lastComponentMinHeight = minHeight(components.last),119 maxfirstComponentHeight = components.splitPane.offsetHeight - lastComponentMinHeight - components.divider.offsetHeight;120 if (components.first.offsetHeight > maxfirstComponentHeight) {121 setTop(components, maxfirstComponentHeight + 'px');122 }123 $splitPane.trigger('splitpaneresize');124 };125 } else if ($splitPane.is('.fixed-bottom')) {126 return function(event) {127 var firstComponentMinHeight = minHeight(components.first),128 maxLastComponentHeight = components.splitPane.offsetHeight - firstComponentMinHeight - components.divider.offsetHeight;129 if (components.last.offsetHeight > maxLastComponentHeight) {130 setBottom(components, maxLastComponentHeight + 'px');131 }132 $splitPane.trigger('splitpaneresize');133 };134 } else if ($splitPane.is('.horizontal-percent')) {135 return function(event) {136 var lastComponentMinHeight = minHeight(components.last),137 firstComponentMinHeight = minHeight(components.first),138 maxLastComponentHeight = components.splitPane.offsetHeight - firstComponentMinHeight - components.divider.offsetHeight;139 if (components.last.offsetHeight > maxLastComponentHeight) {140 setBottom(components, (maxLastComponentHeight / components.splitPane.offsetHeight * 100) + '%');141 } else {142 if (components.splitPane.offsetHeight - components.first.offsetHeight - components.divider.offsetHeight < lastComponentMinHeight) {143 setBottom(components, (lastComponentMinHeight / components.splitPane.offsetHeight * 100) + '%');144 }145 }146 $splitPane.trigger('splitpaneresize');147 };148 } else if ($splitPane.is('.fixed-left')) {149 return function(event) {150 var lastComponentMinWidth = minWidth(components.last),151 maxFirstComponentWidth = components.splitPane.offsetWidth - lastComponentMinWidth - components.divider.offsetWidth;152 if (components.first.offsetWidth > maxFirstComponentWidth) {153 setLeft(components, maxFirstComponentWidth + 'px');154 }155 $splitPane.trigger('splitpaneresize');156 };157 } else if ($splitPane.is('.fixed-right')) {158 return function(event) {159 var firstComponentMinWidth = minWidth(components.first),160 maxLastComponentWidth = components.splitPane.offsetWidth - firstComponentMinWidth - components.divider.offsetWidth;161 if (components.last.offsetWidth > maxLastComponentWidth) {162 setRight(components, maxLastComponentWidth + 'px');163 }164 $splitPane.trigger('splitpaneresize');165 };166 } else if ($splitPane.is('.vertical-percent')) {167 return function(event) {168 var lastComponentMinWidth = minWidth(components.last),169 firstComponentMinWidth = minWidth(components.first),170 maxLastComponentWidth = components.splitPane.offsetWidth - firstComponentMinWidth - components.divider.offsetWidth;171 if (components.last.offsetWidth > maxLastComponentWidth) {172 setRight(components, (maxLastComponentWidth / components.splitPane.offsetWidth * 100) + '%');173 } else {174 if (components.splitPane.offsetWidth - components.first.offsetWidth - components.divider.offsetWidth < lastComponentMinWidth) {175 setRight(components, (lastComponentMinWidth / components.splitPane.offsetWidth * 100) + '%');176 }177 }178 $splitPane.trigger('splitpaneresize');179 };180 }181 }182 function createMousemove($splitPane, pageX, pageY) {183 var components = getComponents($splitPane);184 if ($splitPane.is('.fixed-top')) {185 return fixedTopHandler(components, pageY);186 } else if ($splitPane.is('.fixed-bottom')) {187 return fixedBottomHandler(components, pageY);188 } else if ($splitPane.is('.horizontal-percent')) {189 return horizontalPercentHandler(components, pageY);190 } else if ($splitPane.is('.fixed-left')) {191 return fixedLeftHandler(components, pageX);192 } else if ($splitPane.is('.fixed-right')) {193 return fixedRightHandler(components, pageX);194 } else if ($splitPane.is('.vertical-percent')) {195 return verticalPercentHandler(components, pageX);196 }197 }198 function fixedTopHandler(components, pageY) {199 var firstComponentMinHeight = minHeight(components.first),200 maxFirstComponentHeight = components.splitPane.offsetHeight - minHeight(components.last) - components.divider.offsetHeight,201 topOffset = components.divider.offsetTop - pageY;202 return function(event) {203 event.preventDefault && event.preventDefault();204 var top = newTop(firstComponentMinHeight, maxFirstComponentHeight, topOffset + pageYof(event));205 setTop(components, top + 'px');206 $(components.splitPane).trigger('splitpaneresize');207 };208 }209 function fixedBottomHandler(components, pageY) {210 var lastComponentMinHeight = minHeight(components.last),211 maxLastComponentHeight = components.splitPane.offsetHeight - minHeight(components.first) - components.divider.offsetHeight,212 bottomOffset = components.last.offsetHeight + pageY;213 return function(event) {214 event.preventDefault && event.preventDefault();215 var bottom = Math.min(Math.max(lastComponentMinHeight, bottomOffset - pageYof(event)), maxLastComponentHeight);216 setBottom(components, bottom + 'px');217 $(components.splitPane).trigger('splitpaneresize');218 };219 }220 function horizontalPercentHandler(components, pageY) {221 var splitPaneHeight = components.splitPane.offsetHeight,222 lastComponentMinHeight = minHeight(components.last),223 maxLastComponentHeight = splitPaneHeight - minHeight(components.first) - components.divider.offsetHeight,224 bottomOffset = components.last.offsetHeight + pageY;225 return function(event) {226 event.preventDefault && event.preventDefault();227 var bottom = Math.min(Math.max(lastComponentMinHeight, bottomOffset - pageYof(event)), maxLastComponentHeight);228 setBottom(components, (bottom / splitPaneHeight * 100) + '%');229 $(components.splitPane).trigger('splitpaneresize');230 };231 }232 function fixedLeftHandler(components, pageX) {233 var firstComponentMinWidth = minWidth(components.first),234 maxFirstComponentWidth = components.splitPane.offsetWidth - minWidth(components.last) - components.divider.offsetWidth,235 leftOffset = components.divider.offsetLeft - pageX;236 return function(event) {237 event.preventDefault && event.preventDefault();238 var left = newLeft(firstComponentMinWidth, maxFirstComponentWidth, leftOffset + pageXof(event));239 setLeft(components, left + 'px');240 $(components.splitPane).trigger('splitpaneresize');241 };242 }243 function fixedRightHandler(components, pageX) {244 var lastComponentMinWidth = minWidth(components.last),245 maxLastComponentWidth = components.splitPane.offsetWidth - minWidth(components.first) - components.divider.offsetWidth,246 rightOffset = components.last.offsetWidth + pageX;247 return function(event) {248 event.preventDefault && event.preventDefault();249 var right = Math.min(Math.max(lastComponentMinWidth, rightOffset - pageXof(event)), maxLastComponentWidth);250 setRight(components, right + 'px');251 $(components.splitPane).trigger('splitpaneresize');252 };253 }254 function verticalPercentHandler(components, pageX) {255 var splitPaneWidth = components.splitPane.offsetWidth,256 lastComponentMinWidth = minWidth(components.last),257 maxLastComponentWidth = splitPaneWidth - minWidth(components.first) - components.divider.offsetWidth,258 rightOffset = components.last.offsetWidth + pageX;259 return function(event) {260 event.preventDefault && event.preventDefault();261 var right = Math.min(Math.max(lastComponentMinWidth, rightOffset - pageXof(event)), maxLastComponentWidth);262 setRight(components, (right / splitPaneWidth * 100) + '%');263 $(components.splitPane).trigger('splitpaneresize');264 };265 }266 function getComponents($splitPane) {267 return {268 splitPane: $splitPane[0],269 first: $splitPane.children('.split-pane-component:first')[0],270 divider: $splitPane.children('.split-pane-divider')[0],271 last: $splitPane.children('.split-pane-component:last')[0]272 };273 }274 function pageXof(event) {275 if (event.pageX !== undefined) {276 return event.pageX;277 } else if (event.originalEvent.pageX !== undefined) {278 return event.originalEvent.pageX;279 } else if (event.originalEvent.touches) {280 return event.originalEvent.touches[0].pageX;281 }282 }283 function pageYof(event) {284 if (event.pageY !== undefined) {285 return event.pageY;286 } else if (event.originalEvent.pageY !== undefined) {287 return event.originalEvent.pageY;288 } else if (event.originalEvent.touches) {289 return event.originalEvent.touches[0].pageY;290 }291 }292 function minHeight(element) {293 return parseInt($(element).css('min-height'), 10) || 0;294 }295 function minWidth(element) {296 return parseInt($(element).css('min-width'), 10) || 0;297 }298 function maxHeight(element) {299 return parseInt($(element).css('max-height'), 10);300 }301 function maxWidth(element) {302 return parseInt($(element).css('max-width'), 10);303 }304 function newTop(firstComponentMinHeight, maxFirstComponentHeight, value) {305 return Math.min(Math.max(firstComponentMinHeight, value), maxFirstComponentHeight);306 }307 function newLeft(firstComponentMinWidth, maxFirstComponentWidth, value) {308 return Math.min(Math.max(firstComponentMinWidth, value), maxFirstComponentWidth);309 }310 function setTop(components, top) {311 components.first.style.height = top;312 components.divider.style.top = top;313 components.last.style.top = top;314 }315 function setBottom(components, bottom) {316 components.first.style.bottom = bottom;317 components.divider.style.bottom = bottom;318 components.last.style.height = bottom;319 }320 function setLeft(components, left) {321 components.first.style.width = left;322 components.divider.style.left = left;323 components.last.style.left = left;324 }325 function setRight(components, right) {326 components.first.style.right = right;327 components.divider.style.right = right;328 components.last.style.width = right;329 }...

Full Screen

Full Screen

s-string.js

Source:s-string.js Github

copy

Full Screen

...9 });10 describe("split", function() {11 var test = "ab";12 it('If "separator" is undefined must return Array with one String - "this" string', function() {13 expect(test.split()).toEqual([test]);14 expect(test.split(void 0)).toEqual([test]);15 });16 it('If "separator" is undefined and "limit" set to 0 must return Array[]', function() {17 expect(test.split(void 0, 0)).toEqual([]);18 });19 describe('Tests from Steven Levithan', function () {20 it("''.split() results in ['']", function () {21 expect(''.split()).toEqual(['']);22 });23 it("''.split(/./) results in ['']", function () {24 expect(''.split(/./)).toEqual(['']);25 });26 it("''.split(/.?/) results in []", function () {27 expect(''.split(/.?/)).toEqual([]);28 });29 it("''.split(/.??/) results in []", function () {30 expect(''.split(/.??/)).toEqual([]);31 });32 it("'ab'.split(/a*/) results in ['', 'b']", function () {33 expect('ab'.split(/a*/)).toEqual(['', 'b']);34 });35 it("'ab'.split(/a*?/) results in ['a', 'b']", function () {36 expect('ab'.split(/a*?/)).toEqual(['a', 'b']);37 });38 it("'ab'.split(/(?:ab)/) results in ['', '']", function () {39 expect('ab'.split(/(?:ab)/)).toEqual(['', '']);40 });41 it("'ab'.split(/(?:ab)*/) results in ['', '']", function () {42 expect('ab'.split(/(?:ab)*/)).toEqual(['', '']);43 });44 it("'ab'.split(/(?:ab)*?/) results in ['a', 'b']", function () {45 expect('ab'.split(/(?:ab)*?/)).toEqual(['a', 'b']);46 });47 it("'test'.split('') results in ['t', 'e', 's', 't']", function () {48 expect('test'.split('')).toEqual(['t', 'e', 's', 't']);49 });50 it("'test'.split() results in ['test']", function () {51 expect('test'.split()).toEqual(['test']);52 });53 it("'111'.split(1) results in ['', '', '', '']", function () {54 expect('111'.split(1)).toEqual(['', '', '', '']);55 });56 it("'test'.split(/(?:)/, 2) results in ['t', 'e']", function () {57 expect('test'.split(/(?:)/, 2)).toEqual(['t', 'e']);58 });59 it("'test'.split(/(?:)/, -1) results in ['t', 'e', 's', 't']", function () {60 expect('test'.split(/(?:)/, -1)).toEqual(['t', 'e', 's', 't']);61 });62 it("'test'.split(/(?:)/, undefined) results in ['t', 'e', 's', 't']", function () {63 expect('test'.split(/(?:)/, undefined)).toEqual(['t', 'e', 's', 't']);64 });65 it("'test'.split(/(?:)/, null) results in []", function () {66 expect('test'.split(/(?:)/, null)).toEqual([]);67 });68 it("'test'.split(/(?:)/, NaN) results in []", function () {69 expect('test'.split(/(?:)/, NaN)).toEqual([]);70 });71 it("'test'.split(/(?:)/, true) results in ['t']", function () {72 expect('test'.split(/(?:)/, true)).toEqual(['t']);73 });74 it("'test'.split(/(?:)/, '2') results in ['t', 'e']", function () {75 expect('test'.split(/(?:)/, '2')).toEqual(['t', 'e']);76 });77 it("'test'.split(/(?:)/, 'two') results in []", function () {78 expect('test'.split(/(?:)/, 'two')).toEqual([]);79 });80 it("'a'.split(/-/) results in ['a']", function () {81 expect('a'.split(/-/)).toEqual(['a']);82 });83 it("'a'.split(/-?/) results in ['a']", function () {84 expect('a'.split(/-?/)).toEqual(['a']);85 });86 it("'a'.split(/-??/) results in ['a']", function () {87 expect('a'.split(/-??/)).toEqual(['a']);88 });89 it("'a'.split(/a/) results in ['', '']", function () {90 expect('a'.split(/a/)).toEqual(['', '']);91 });92 it("'a'.split(/a?/) results in ['', '']", function () {93 expect('a'.split(/a?/)).toEqual(['', '']);94 });95 it("'a'.split(/a??/) results in ['a']", function () {96 expect('a'.split(/a??/)).toEqual(['a']);97 });98 it("'ab'.split(/-/) results in ['ab']", function () {99 expect('ab'.split(/-/)).toEqual(['ab']);100 });101 it("'ab'.split(/-?/) results in ['a', 'b']", function () {102 expect('ab'.split(/-?/)).toEqual(['a', 'b']);103 });104 it("'ab'.split(/-??/) results in ['a', 'b']", function () {105 expect('ab'.split(/-??/)).toEqual(['a', 'b']);106 });107 it("'a-b'.split(/-/) results in ['a', 'b']", function () {108 expect('a-b'.split(/-/)).toEqual(['a', 'b']);109 });110 it("'a-b'.split(/-?/) results in ['a', 'b']", function () {111 expect('a-b'.split(/-?/)).toEqual(['a', 'b']);112 });113 it("'a-b'.split(/-??/) results in ['a', '-', 'b']", function () {114 expect('a-b'.split(/-??/)).toEqual(['a', '-', 'b']);115 });116 it("'a--b'.split(/-/) results in ['a', '', 'b']", function () {117 expect('a--b'.split(/-/)).toEqual(['a', '', 'b']);118 });119 it("'a--b'.split(/-?/) results in ['a', '', 'b']", function () {120 expect('a--b'.split(/-?/)).toEqual(['a', '', 'b']);121 });122 it("'a--b'.split(/-??/) results in ['a', '-', '-', 'b']", function () {123 expect('a--b'.split(/-??/)).toEqual(['a', '-', '-', 'b']);124 });125 it("''.split(/()()/) results in []", function () {126 expect(''.split(/()()/)).toEqual([]);127 });128 it("'.'.split(/()()/) results in ['.']", function () {129 expect('.'.split(/()()/)).toEqual(['.']);130 });131 it("'.'.split(/(.?)(.?)/) results in ['', '.', '', '']", function () {132 expect('.'.split(/(.?)(.?)/)).toEqual(['', '.', '', '']);133 });134 it("'.'.split(/(.??)(.??)/) results in ['.']", function () {135 expect('.'.split(/(.??)(.??)/)).toEqual(['.']);136 });137 it("'.'.split(/(.)?(.)?/) results in ['', '.', undefined, '']", function () {138 expect('.'.split(/(.)?(.)?/)).toEqual(['', '.', undefined, '']);139 });140 it("'A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\\/)?([^<>]+)>/) results in ['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']", function () {141 expect('A<B>bold</B>and<CODE>coded</CODE>'.split(/<(\/)?([^<>]+)>/)).toEqual(['A', undefined, 'B', 'bold', '/', 'B', 'and', undefined, 'CODE', 'coded', '/', 'CODE', '']);142 });143 it("'tesst'.split(/(s)*/) results in ['t', undefined, 'e', 's', 't']", function () {144 expect('tesst'.split(/(s)*/)).toEqual(['t', undefined, 'e', 's', 't']);145 });146 it("'tesst'.split(/(s)*?/) results in ['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']", function () {147 expect('tesst'.split(/(s)*?/)).toEqual(['t', undefined, 'e', undefined, 's', undefined, 's', undefined, 't']);148 });149 it("'tesst'.split(/(s*)/) results in ['t', '', 'e', 'ss', 't']", function () {150 expect('tesst'.split(/(s*)/)).toEqual(['t', '', 'e', 'ss', 't']);151 });152 it("'tesst'.split(/(s*?)/) results in ['t', '', 'e', '', 's', '', 's', '', 't']", function () {153 expect('tesst'.split(/(s*?)/)).toEqual(['t', '', 'e', '', 's', '', 's', '', 't']);154 });155 it("'tesst'.split(/(?:s)*/) results in ['t', 'e', 't']", function () {156 expect('tesst'.split(/(?:s)*/)).toEqual(['t', 'e', 't']);157 });158 it("'tesst'.split(/(?=s+)/) results in ['te', 's', 'st']", function () {159 expect('tesst'.split(/(?=s+)/)).toEqual(['te', 's', 'st']);160 });161 it("'test'.split('t') results in ['', 'es', '']", function () {162 expect('test'.split('t')).toEqual(['', 'es', '']);163 });164 it("'test'.split('es') results in ['t', 't']", function () {165 expect('test'.split('es')).toEqual(['t', 't']);166 });167 it("'test'.split(/t/) results in ['', 'es', '']", function () {168 expect('test'.split(/t/)).toEqual(['', 'es', '']);169 });170 it("'test'.split(/es/) results in ['t', 't']", function () {171 expect('test'.split(/es/)).toEqual(['t', 't']);172 });173 it("'test'.split(/(t)/) results in ['', 't', 'es', 't', '']", function () {174 expect('test'.split(/(t)/)).toEqual(['', 't', 'es', 't', '']);175 });176 it("'test'.split(/(es)/) results in ['t', 'es', 't']", function () {177 expect('test'.split(/(es)/)).toEqual(['t', 'es', 't']);178 });179 it("'test'.split(/(t)(e)(s)(t)/) results in ['', 't', 'e', 's', 't', '']", function () {180 expect('test'.split(/(t)(e)(s)(t)/)).toEqual(['', 't', 'e', 's', 't', '']);181 });182 it("'.'.split(/(((.((.??)))))/) results in ['', '.', '.', '.', '', '', '']", function () {183 expect('.'.split(/(((.((.??)))))/)).toEqual(['', '.', '.', '.', '', '', '']);184 });185 it("'.'.split(/(((((.??)))))/) results in ['.']", function () {186 expect('.'.split(/(((((.??)))))/)).toEqual(['.']);187 });188 it("'a b c d'.split(/ /, -(Math.pow(2, 32) - 1)) results in ['a']", function () {189 expect('a b c d'.split(/ /, -(Math.pow(2, 32) - 1))).toEqual(['a']);190 });191 it("'a b c d'.split(/ /, Math.pow(2, 32) + 1) results in ['a']", function () {192 expect('a b c d'.split(/ /, Math.pow(2, 32) + 1)).toEqual(['a']);193 });194 it("'a b c d'.split(/ /, Infinity) results in []", function () {195 expect('a b c d'.split(/ /, Infinity)).toEqual([]);196 });197 });198 });...

Full Screen

Full Screen

15.5.4.8-1.js

Source:15.5.4.8-1.js Github

copy

Full Screen

...37 * ***** END LICENSE BLOCK ***** */38gTestfile = '15.5.4.8-1.js';39/**40 File Name: 15.5.4.8-1.js41 ECMA Section: 15.5.4.8 String.prototype.split( separator )42 Description:43 Returns an Array object into which substrings of the result of converting44 this object to a string have been stored. The substrings are determined by45 searching from left to right for occurrences of the given separator; these46 occurrences are not part of any substring in the returned array, but serve47 to divide up this string value. The separator may be a string of any length.48 As a special case, if the separator is the empty string, the string is split49 up into individual characters; the length of the result array equals the50 length of the string, and each substring contains one character.51 If the separator is not supplied, then the result array contains just one52 string, which is the string.53 Author: christine@netscape.com, pschwartau@netscape.com54 Date: 12 November 199755 Modified: 14 July 200256 Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=15528957 ECMA-262 Ed.3 Section 15.5.4.1458 The length property of the split method is 259 *60 */61var SECTION = "15.5.4.8-1";62var VERSION = "ECMA_1";63startTest();64var TITLE = "String.prototype.split";65writeHeaderToLog( SECTION + " "+ TITLE);66new TestCase( SECTION, "String.prototype.split.length", 2, String.prototype.split.length );67new TestCase( SECTION, "delete String.prototype.split.length", false, delete String.prototype.split.length );68new TestCase( SECTION, "delete String.prototype.split.length; String.prototype.split.length", 2, eval("delete String.prototype.split.length; String.prototype.split.length") );69// test cases for when split is called with no arguments.70// this is a string object71new TestCase( SECTION,72 "var s = new String('this is a string object'); typeof s.split()",73 "object",74 eval("var s = new String('this is a string object'); typeof s.split()") );75new TestCase( SECTION,76 "var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()",77 "[object Array]",78 eval("var s = new String('this is a string object'); Array.prototype.getClass = Object.prototype.toString; (s.split()).getClass()") );79new TestCase( SECTION,80 "var s = new String('this is a string object'); s.split().length",81 1,82 eval("var s = new String('this is a string object'); s.split().length") );83new TestCase( SECTION,84 "var s = new String('this is a string object'); s.split()[0]",85 "this is a string object",86 eval("var s = new String('this is a string object'); s.split()[0]") );87// this is an object object88new TestCase( SECTION,89 "var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()",90 "object",91 eval("var obj = new Object(); obj.split = String.prototype.split; typeof obj.split()") );92new TestCase( SECTION,93 "var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",94 "[object Array]",95 eval("var obj = new Object(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );96new TestCase( SECTION,97 "var obj = new Object(); obj.split = String.prototype.split; obj.split().length",98 1,99 eval("var obj = new Object(); obj.split = String.prototype.split; obj.split().length") );100new TestCase( SECTION,101 "var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]",102 "[object Object]",103 eval("var obj = new Object(); obj.split = String.prototype.split; obj.split()[0]") );104// this is a function object105new TestCase( SECTION,106 "var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()",107 "object",108 eval("var obj = new Function(); obj.split = String.prototype.split; typeof obj.split()") );109new TestCase( SECTION,110 "var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",111 "[object Array]",112 eval("var obj = new Function(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );113new TestCase( SECTION,114 "var obj = new Function(); obj.split = String.prototype.split; obj.split().length",115 1,116 eval("var obj = new Function(); obj.split = String.prototype.split; obj.split().length") );117new TestCase( SECTION,118 "var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]",119 "[object Function]",120 eval("var obj = new Function(); obj.split = String.prototype.split; obj.toString = Object.prototype.toString; obj.split()[0]") );121// this is a number object122new TestCase( SECTION,123 "var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()",124 "object",125 eval("var obj = new Number(NaN); obj.split = String.prototype.split; typeof obj.split()") );126new TestCase( SECTION,127 "var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",128 "[object Array]",129 eval("var obj = new Number(Infinity); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );130new TestCase( SECTION,131 "var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length",132 1,133 eval("var obj = new Number(-1234567890); obj.split = String.prototype.split; obj.split().length") );134new TestCase( SECTION,135 "var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]",136 "-1e+21",137 eval("var obj = new Number(-1e21); obj.split = String.prototype.split; obj.split()[0]") );138// this is the Math object139new TestCase( SECTION,140 "var obj = Math; obj.split = String.prototype.split; typeof obj.split()",141 "object",142 eval("var obj = Math; obj.split = String.prototype.split; typeof obj.split()") );143new TestCase( SECTION,144 "var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",145 "[object Array]",146 eval("var obj = Math; obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );147new TestCase( SECTION,148 "var obj = Math; obj.split = String.prototype.split; obj.split().length",149 1,150 eval("var obj = Math; obj.split = String.prototype.split; obj.split().length") );151new TestCase( SECTION,152 "var obj = Math; obj.split = String.prototype.split; obj.split()[0]",153 "[object Math]",154 eval("var obj = Math; obj.split = String.prototype.split; obj.split()[0]") );155// this is an array object156new TestCase( SECTION,157 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()",158 "object",159 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; typeof obj.split()") );160new TestCase( SECTION,161 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",162 "[object Array]",163 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );164new TestCase( SECTION,165 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length",166 1,167 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split().length") );168new TestCase( SECTION,169 "var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]",170 "1,2,3,4,5",171 eval("var obj = new Array(1,2,3,4,5); obj.split = String.prototype.split; obj.split()[0]") );172// this is a Boolean object173new TestCase( SECTION,174 "var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()",175 "object",176 eval("var obj = new Boolean(); obj.split = String.prototype.split; typeof obj.split()") );177new TestCase( SECTION,178 "var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.getClass()",179 "[object Array]",180 eval("var obj = new Boolean(); obj.split = String.prototype.split; Array.prototype.getClass = Object.prototype.toString; obj.split().getClass()") );181new TestCase( SECTION,182 "var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length",183 1,184 eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split().length") );185new TestCase( SECTION,186 "var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]",187 "false",188 eval("var obj = new Boolean(); obj.split = String.prototype.split; obj.split()[0]") );...

Full Screen

Full Screen

split-002.js

Source:split-002.js Github

copy

Full Screen

...23 *24 */25 var SECTION = "ecma_2/String/split-002.js";26 var VERSION = "ECMA_2";27 var TITLE = "String.prototype.split( regexp, [,limit] )";28 startTest();29 // the separator is not supplied30 // separator is undefined31 // separator is an empty string32// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] );33// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] );34 // separator is an empty regexp35 // separator is not supplied36 CompareSplit( "hello", "ll" );37 CompareSplit( "hello", "l" );38 CompareSplit( "hello", "x" );39 CompareSplit( "hello", "h" );40 CompareSplit( "hello", "o" );41 CompareSplit( "hello", "hello" );42 CompareSplit( "hello", undefined );43 CompareSplit( "hello", "");44 CompareSplit( "hello", "hellothere" );45 CompareSplit( new String("hello" ) );46 Number.prototype.split = String.prototype.split;47 CompareSplit( new Number(100111122133144155), 1 );48 CompareSplitWithLimit(new Number(100111122133144155), 1, 1 );49 CompareSplitWithLimit(new Number(100111122133144155), 1, 2 );50 CompareSplitWithLimit(new Number(100111122133144155), 1, 0 );51 CompareSplitWithLimit(new Number(100111122133144155), 1, 100 );52 CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 );53 CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 );54 CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" );55 CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) );56 CompareSplitWithLimit( "hello", "l", NaN );57 CompareSplitWithLimit( "hello", "l", 0 );58 CompareSplitWithLimit( "hello", "l", 1 );59 CompareSplitWithLimit( "hello", "l", 2 );60 CompareSplitWithLimit( "hello", "l", 3 );61 CompareSplitWithLimit( "hello", "l", 4 );62/*63 CompareSplitWithLimit( "hello", "ll", 0 );64 CompareSplitWithLimit( "hello", "ll", 1 );65 CompareSplitWithLimit( "hello", "ll", 2 );66 CompareSplit( "", " " );67 CompareSplit( "" );68*/69 // separartor is a regexp70 // separator regexp value global setting is set71 // string is an empty string72 // if separator is an empty string, split each by character73 // this is not a String object74 // limit is not a number75 // limit is undefined76 // limit is larger than 2^32-177 // limit is a negative number78 test();79function CompareSplit( string, separator ) {80 split_1 = string.split( separator );81 split_2 = string_split( string, separator );82 AddTestCase(83 "( " + string +".split(" + separator + ") ).length" ,84 split_2.length,85 split_1.length );86 var limit = split_1.length > split_2.length ?87 split_1.length : split_2.length;88 for ( var split_item = 0; split_item < limit; split_item++ ) {89 AddTestCase(90 string + ".split(" + separator + ")["+split_item+"]",91 split_2[split_item],92 split_1[split_item] );93 }94}95function CompareSplitWithLimit( string, separator, splitlimit ) {96 split_1 = string.split( separator, splitlimit );97 split_2 = string_split( string, separator, splitlimit );98 AddTestCase(99 "( " + string +".split(" + separator + ", " + splitlimit+") ).length" ,100 split_2.length,101 split_1.length );102 var limit = split_1.length > split_2.length ?103 split_1.length : split_2.length;104 for ( var split_item = 0; split_item < limit; split_item++ ) {105 AddTestCase(106 string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]",107 split_2[split_item],108 split_1[split_item] );109 }110}111function string_split ( __this, separator, limit ) {112 var S = String(__this ); // 1113 var A = new Array(); // 2114 if ( limit == undefined ) { // 3115 lim = Math.pow(2, 31 ) -1;116 } else {117 lim = ToUint32( limit );118 }119 var s = S.length; // 4120 var p = 0; // 5...

Full Screen

Full Screen

RadarView.js

Source:RadarView.js Github

copy

Full Screen

1define(function (require) {2 var AxisBuilder = require('../axis/AxisBuilder');3 var zrUtil = require('zrender/core/util');4 var graphic = require('../../util/graphic');5 var axisBuilderAttrs = [6 'axisLine', 'axisLabel', 'axisTick', 'axisName'7 ];8 return require('../../echarts').extendComponentView({9 type: 'radar',10 render: function (radarModel, ecModel, api) {11 var group = this.group;12 group.removeAll();13 this._buildAxes(radarModel);14 this._buildSplitLineAndArea(radarModel);15 },16 _buildAxes: function (radarModel) {17 var radar = radarModel.coordinateSystem;18 var indicatorAxes = radar.getIndicatorAxes();19 var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {20 var axisBuilder = new AxisBuilder(indicatorAxis.model, {21 position: [radar.cx, radar.cy],22 rotation: indicatorAxis.angle,23 labelDirection: -1,24 tickDirection: -1,25 nameDirection: 126 });27 return axisBuilder;28 });29 zrUtil.each(axisBuilders, function (axisBuilder) {30 zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);31 this.group.add(axisBuilder.getGroup());32 }, this);33 },34 _buildSplitLineAndArea: function (radarModel) {35 var radar = radarModel.coordinateSystem;36 var splitNumber = radarModel.get('splitNumber');37 var indicatorAxes = radar.getIndicatorAxes();38 if (!indicatorAxes.length) {39 return;40 }41 var shape = radarModel.get('shape');42 var splitLineModel = radarModel.getModel('splitLine');43 var splitAreaModel = radarModel.getModel('splitArea');44 var lineStyleModel = splitLineModel.getModel('lineStyle');45 var areaStyleModel = splitAreaModel.getModel('areaStyle');46 var showSplitLine = splitLineModel.get('show');47 var showSplitArea = splitAreaModel.get('show');48 var splitLineColors = lineStyleModel.get('color');49 var splitAreaColors = areaStyleModel.get('color');50 splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];51 splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];52 var splitLines = [];53 var splitAreas = [];54 function getColorIndex(areaOrLine, areaOrLineColorList, idx) {55 var colorIndex = idx % areaOrLineColorList.length;56 areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];57 return colorIndex;58 }59 if (shape === 'circle') {60 var ticksRadius = indicatorAxes[0].getTicksCoords();61 var cx = radar.cx;62 var cy = radar.cy;63 for (var i = 0; i < ticksRadius.length; i++) {64 if (showSplitLine) {65 var colorIndex = getColorIndex(splitLines, splitLineColors, i);66 splitLines[colorIndex].push(new graphic.Circle({67 shape: {68 cx: cx,69 cy: cy,70 r: ticksRadius[i]71 }72 }));73 }74 if (showSplitArea && i < ticksRadius.length - 1) {75 var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);76 splitAreas[colorIndex].push(new graphic.Ring({77 shape: {78 cx: cx,79 cy: cy,80 r0: ticksRadius[i],81 r: ticksRadius[i + 1]82 }83 }));84 }85 }86 }87 // Polyyon88 else {89 var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {90 var ticksCoords = indicatorAxis.getTicksCoords();91 return zrUtil.map(ticksCoords, function (tickCoord) {92 return radar.coordToPoint(tickCoord, idx);93 });94 });95 var prevPoints = [];96 for (var i = 0; i <= splitNumber; i++) {97 var points = [];98 for (var j = 0; j < indicatorAxes.length; j++) {99 points.push(axesTicksPoints[j][i]);100 }101 // Close102 points.push(points[0].slice());103 if (showSplitLine) {104 var colorIndex = getColorIndex(splitLines, splitLineColors, i);105 splitLines[colorIndex].push(new graphic.Polyline({106 shape: {107 points: points108 }109 }));110 }111 if (showSplitArea && prevPoints) {112 var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);113 splitAreas[colorIndex].push(new graphic.Polygon({114 shape: {115 points: points.concat(prevPoints)116 }117 }));118 }119 prevPoints = points.slice().reverse();120 }121 }122 var lineStyle = lineStyleModel.getLineStyle();123 var areaStyle = areaStyleModel.getAreaStyle();124 // Add splitArea before splitLine125 zrUtil.each(splitAreas, function (splitAreas, idx) {126 this.group.add(graphic.mergePath(127 splitAreas, {128 style: zrUtil.defaults({129 stroke: 'none',130 fill: splitAreaColors[idx % splitAreaColors.length]131 }, areaStyle),132 silent: true133 }134 ));135 }, this);136 zrUtil.each(splitLines, function (splitLines, idx) {137 this.group.add(graphic.mergePath(138 splitLines, {139 style: zrUtil.defaults({140 fill: 'none',141 stroke: splitLineColors[idx % splitLineColors.length]142 }, lineStyle),143 silent: true144 }145 ));146 }, this);147 }148 });...

Full Screen

Full Screen

split-003.js

Source:split-003.js Github

copy

Full Screen

...23 *24 */25 var SECTION = "ecma_2/String/split-003.js";26 var VERSION = "ECMA_2";27 var TITLE = "String.prototype.split( regexp, [,limit] )";28 startTest();29 // separartor is a regexp30 // separator regexp value global setting is set31 // string is an empty string32 // if separator is an empty string, split each by character33 AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] );34 AddSplitCases( "hello", /l/, "/l/", ["he","","o"] );35 AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] );36 AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] );37 AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] );38 AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] );39 AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] );40 AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] );41 AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] );42 AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] );43 AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] );44 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] );45 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] );46 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] );47 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] );48 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] );49 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] );50 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] );51 AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] );52 test();53function AddSplitCases( string, separator, str_sep, split_array ) {54 // verify that the result of split is an object of type Array55 AddTestCase(56 "( " + string + " ).split(" + str_sep +").constructor == Array",57 true,58 string.split(separator).constructor == Array );59 // check the number of items in the array60 AddTestCase(61 "( " + string + " ).split(" + str_sep +").length",62 split_array.length,63 string.split(separator).length );64 // check the value of each array item65 var limit = (split_array.length > string.split(separator).length )66 ? split_array.length : string.split(separator).length;67 for ( var matches = 0; matches < split_array.length; matches++ ) {68 AddTestCase(69 "( " + string + " ).split(" + str_sep +")[" + matches +"]",70 split_array[matches],71 string.split( separator )[matches] );72 }73}74function AddLimitedSplitCases(75 string, separator, str_sep, limit, split_array ) {76 // verify that the result of split is an object of type Array77 AddTestCase(78 "( " + string + " ).split(" + str_sep +", " + limit +79 " ).constructor == Array",80 true,81 string.split(separator, limit).constructor == Array );82 // check the length of the array83 AddTestCase(84 "( " + string + " ).split(" + str_sep +", " + limit + " ).length",85 split_array.length,86 string.split(separator, limit).length );87 // check the value of each array item88 var slimit = (split_array.length > string.split(separator).length )89 ? split_array.length : string.split(separator, limit).length;90 for ( var matches = 0; matches < slimit; matches++ ) {91 AddTestCase(92 "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]",93 split_array[matches],94 string.split( separator, limit )[matches] );95 }...

Full Screen

Full Screen

string-split-conformance.js

Source:string-split-conformance.js Github

copy

Full Screen

...3);4// The following JavaScript code (including "".split tests) is copyright by Steven Levithan,5// and released under the MIT License6var testCode = [7 ["''.split()", [""]],8 ["''.split(/./)", [""]],9 ["''.split(/.?/)", []],10 ["''.split(/.??/)", []],11 ["'ab'.split(/a*/)", ["", "b"]],12 ["'ab'.split(/a*?/)", ["a", "b"]],13 ["'ab'.split(/(?:ab)/)", ["", ""]],14 ["'ab'.split(/(?:ab)*/)", ["", ""]],15 ["'ab'.split(/(?:ab)*?/)", ["a", "b"]],16 ["'test'.split('')", ["t", "e", "s", "t"]],17 ["'test'.split()", ["test"]],18 ["'111'.split(1)", ["", "", "", ""]],19 ["'test'.split(/(?:)/, 2)", ["t", "e"]],20 ["'test'.split(/(?:)/, -1)", ["t", "e", "s", "t"]],21 ["'test'.split(/(?:)/, undefined)", ["t", "e", "s", "t"]],22 ["'test'.split(/(?:)/, null)", []],23 ["'test'.split(/(?:)/, NaN)", []],24 ["'test'.split(/(?:)/, true)", ["t"]],25 ["'test'.split(/(?:)/, '2')", ["t", "e"]],26 ["'test'.split(/(?:)/, 'two')", []],27 ["'a'.split(/-/)", ["a"]],28 ["'a'.split(/-?/)", ["a"]],29 ["'a'.split(/-??/)", ["a"]],30 ["'a'.split(/a/)", ["", ""]],31 ["'a'.split(/a?/)", ["", ""]],32 ["'a'.split(/a??/)", ["a"]],33 ["'ab'.split(/-/)", ["ab"]],34 ["'ab'.split(/-?/)", ["a", "b"]],35 ["'ab'.split(/-??/)", ["a", "b"]],36 ["'a-b'.split(/-/)", ["a", "b"]],37 ["'a-b'.split(/-?/)", ["a", "b"]],38 ["'a-b'.split(/-??/)", ["a", "-", "b"]],39 ["'a--b'.split(/-/)", ["a", "", "b"]],40 ["'a--b'.split(/-?/)", ["a", "", "b"]],41 ["'a--b'.split(/-??/)", ["a", "-", "-", "b"]],42 ["''.split(/()()/)", []],43 ["'.'.split(/()()/)", ["."]],44 ["'.'.split(/(.?)(.?)/)", ["", ".", "", ""]],45 ["'.'.split(/(.??)(.??)/)", ["."]],46 ["'.'.split(/(.)?(.)?/)", ["", ".", undefined, ""]],47 ["'A<B>bold</B>and<CODE>coded</CODE>'.split(ecmaSampleRe)", ["A", undefined, "B", "bold", "/", "B", "and", undefined, "CODE", "coded", "/", "CODE", ""]],48 ["'tesst'.split(/(s)*/)", ["t", undefined, "e", "s", "t"]],49 ["'tesst'.split(/(s)*?/)", ["t", undefined, "e", undefined, "s", undefined, "s", undefined, "t"]],50 ["'tesst'.split(/(s*)/)", ["t", "", "e", "ss", "t"]],51 ["'tesst'.split(/(s*?)/)", ["t", "", "e", "", "s", "", "s", "", "t"]],52 ["'tesst'.split(/(?:s)*/)", ["t", "e", "t"]],53 ["'tesst'.split(/(?=s+)/)", ["te", "s", "st"]],54 ["'test'.split('t')", ["", "es", ""]],55 ["'test'.split('es')", ["t", "t"]],56 ["'test'.split(/t/)", ["", "es", ""]],57 ["'test'.split(/es/)", ["t", "t"]],58 ["'test'.split(/(t)/)", ["", "t", "es", "t", ""]],59 ["'test'.split(/(es)/)", ["t", "es", "t"]],60 ["'test'.split(/(t)(e)(s)(t)/)",["", "t", "e", "s", "t", ""]],61 ["'.'.split(/(((.((.??)))))/)", ["", ".", ".", ".", "", "", ""]],62 ["'.'.split(/(((((.??)))))/)", ["."]]63];64var ecmaSampleRe = /<(\/)?([^<>]+)>/;65for (var i in testCode)66 shouldBe(testCode[i][0], 'testCode[i][1]');67// Check that split works with object separators, and that steps 8 & 9 are performed in the correct order.68var separatorToStringCalled = "ToString not called on the separator";69shouldBe("'hello'.split({toString:function(){return 'e';}})", '["h", "llo"]');...

Full Screen

Full Screen

SplitButton.js

Source:SplitButton.js Github

copy

Full Screen

1(function() {2 module("tinymce.ui.SplitButton", {3 setup: function() {4 document.getElementById('view').innerHTML = '';5 },6 teardown: function() {7 tinymce.dom.Event.clean(document.getElementById('view'));8 }9 });10 function createSplitButton(settings) {11 return tinymce.ui.Factory.create(tinymce.extend({12 type: 'splitbutton'13 }, settings)).renderTo(document.getElementById('view'));14 }15 test("splitbutton text, size default", function() {16 var splitButton = createSplitButton({text: 'X'});17 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 42, 30], 4);18 });19 test("splitbutton text, size large", function() {20 var splitButton = createSplitButton({text: 'X', size: 'large'});21 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 44, 39], 4);22 });23 test("splitbutton text, size small", function() {24 var splitButton = createSplitButton({text: 'X', size: 'small'});25 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 36, 23], 4);26 });27 test("splitbutton text, width 100, height 100", function() {28 var splitButton = createSplitButton({text: 'X', width: 100, height: 100});29 deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);30 deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);31 });32 test("splitbutton icon, size default", function() {33 var splitButton = createSplitButton({icon: 'test'});34 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 50, 30], 4);35 });36 test("splitbutton icon, size small", function() {37 var splitButton = createSplitButton({icon: 'test', size: 'small'});38 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 45, 24], 4);39 });40 test("splitbutton icon, size large", function() {41 var splitButton = createSplitButton({icon: 'test', size: 'large'});42 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 49, 40], 4);43 });44 test("splitbutton icon, width 100, height 100", function() {45 var splitButton = createSplitButton({icon: 'test', width: 100, height: 100});46 deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);47 deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);48 });49 test("splitbutton text & icon, size default", function() {50 var splitButton = createSplitButton({text: 'X', icon: 'test'});51 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 62, 30], 4);52 });53 test("splitbutton text & icon, size large", function() {54 var splitButton = createSplitButton({text: 'X', icon: 'test', size: 'large'});55 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 64, 40], 4);56 });57 test("splitbutton text & icon, size small", function() {58 var splitButton = createSplitButton({text: 'X', icon: 'test', size: 'small'});59 Utils.nearlyEqualRects(Utils.rect(splitButton), [0, 0, 55, 24], 4);60 });61 test("splitbutton text & icon, width 100, height 100", function() {62 var splitButton = createSplitButton({text: 'X', icon: 'test', width: 100, height: 100});63 deepEqual(Utils.rect(splitButton), [0, 0, 100, 100]);64 deepEqual(Utils.rect(splitButton.getEl().firstChild), [1, 1, 83, 98]);65 });66 test("splitbutton click event", function() {67 var splitButton, clicks = {};68 splitButton = createSplitButton({text: 'X', onclick: function() {clicks.a = 'a';}});69 splitButton.fire('click', {target: splitButton.getEl().firstChild});70 deepEqual(clicks, {a: 'a'});71 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const split = await page._delegate.split();7 console.log(split);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 const split = await page._delegate.split();16 const createBrowserFetcher = await split.createBrowserFetcher();17 console.log(createBrowserFetcher);18 await browser.close();19})();20const { chromium } = require('playwright');21(async () => {22 const browser = await chromium.launch();23 const context = await browser.newContext();24 const page = await context.newPage();25 const split = await page._delegate.split();26 const createBrowserServer = await split.createBrowserServer();27 console.log(createBrowserServer);28 await browser.close();29})();30const { chromium } = require('playwright');31(async () => {32 const browser = await chromium.launch();33 const context = await browser.newContext();34 const page = await context.newPage();35 const split = await page._delegate.split();36 const launch = await split.launch();37 console.log(launch);38 await browser.close();39})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const title = await page.title();7 console.log(title);8 await browser.close();9})();10const {chromium} = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 const title = await page.title();16 console.log(title);17 await browser.close();18})();19const {chromium} = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 const title = await page.title();25 console.log(title);26 await browser.close();27})();28const {chromium} = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 const title = await page.title();34 console.log(title);35 await browser.close();36})();37const {chromium} = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 const title = await page.title();43 console.log(title);44 await browser.close();45})();46const {chromium} = require('playwright');47(async () => {48 const browser = await chromium.launch();49 const context = await browser.newContext();50 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text=Split');7 await page.waitForTimeout(1000);8 await browser.close();9})();10const { chromium } = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.click('text=Split');16 await page.waitForTimeout(1000);17 await browser.close();18})();19const { chromium } = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.click('text=Split');25 await page.waitForTimeout(1000);26 await browser.close();27})();28const { chromium } = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.click('text=Split');34 await page.waitForTimeout(1000);35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 await page.click('text=Split');43 await page.waitForTimeout(1000);44 await browser.close();45})();46const { chromium } = require('playwright');47(async () => {48 const browser = await chromium.launch();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: `example.png` });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: `example.png` });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: `example.png` });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: `example.png` });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test } = require('@playwright/test');2test('My first test', async ({ page }) => {3 const title = page.locator('.navbar__inner .navbar__title');4 const titleText = await title.textContent();5 const titleWords = titleText.split(' ');6 expect(titleWords).toContain('Playwright');7});8{9 "scripts": {10 },11 "dependencies": {12 }13}14 ✓ [chromium] › test.js:4:1 › My first test (4s)15 ✓ [firefox] › test.js:4:1 › My first test (4s)16 ✓ [webkit] › test.js:4:1 › My first test (4s)17 1 passed (13s)18const { test } = require('@playwright/test');19test('My first test', async ({ page }) => {20 const title = page.locator('.navbar__inner .navbar__title');21 const titleText = await title.textContent();22 const titleWords = titleText.split(' ');23 expect(titleWords).toContain('Playwright');24});25{26 "scripts": {27 },28 "dependencies": {29 }30}31 ✓ [chromium] › test.js:4:1 › My first test (4s)32 ✓ [firefox] › test.js:4:1 › My first test (4s)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { devices } = require('playwright');2const iPhone = devices['iPhone 6'];3(async () => {4 const browser = await webkit.launch();5 const context = await browser.newContext({6 geolocation: { longitude: 12.492507, latitude: 41.889938 },7 });8 const page = await context.newPage();9 if (button) {10 await button.click();11 }12 await page.waitForTimeout(5000);13 await browser.close();14})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('Test 1', async ({ page }) => {3 const title = await page.title();4 const titleSplit = title.split(' ');5 expect(titleSplit[0]).toBe('Playwright');6});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Internal } = require('@playwright/test');2const { test } = require('@playwright/test');3const { expect } = require('@playwright/test');4test('test', async ({ page }) => {5 expect(Internal.splitStringByRegexGroups('abc', /(?<first>ab)(?<second>c)/)).toEqual({6 });7});8{9 "scripts": {10 },11 "devDependencies": {12 }13}

Full Screen

Using AI Code Generation

copy

Full Screen

1const str = "Hello World";2const words = str.split(" ");3console.log(words.length);4const str = "Hello World";5const words = str.split(" ");6console.log(words.join(" "));7const str = " Hello World ";8console.log(str.trim());9const str = "Hello World";10console.log(str.replace("Hello", "Hi"));11const str = "Hello World";12console.log(str.substring(0, 5));13const str = "Hello World";14console.log(str.toLowerCase());15const str = "Hello World";16console.log(str.toUpperCase());17const str = "Hello World";18console.log(str.toLocaleLowerCase());19const str = "Hello World";20console.log(str.toLocaleUpperCase());

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful