<commit_before>import '../src/polyfills.js';

export * from './constants.js';
export * from './Three.Legacy.js';

export { AnimationAction } from './animation/AnimationAction.js';
export { AnimationClip } from './animation/AnimationClip.js';
export { AnimationMixer } from './animation/AnimationMixer.js';
export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js';
export { AnimationUtils } from './animation/AnimationUtils.js';
export { KeyframeTrack } from './animation/KeyframeTrack.js';
export { KeyframeTrackConstructor } from './animation/KeyframeTrackConstructor.js';
export { KeyframeTrackPrototype } from './animation/KeyframeTrackPrototype.js';
export { PropertyBinding } from './animation/PropertyBinding.js';
export { PropertyMixer } from './animation/PropertyMixer.js';

export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack.js';
export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack.js';
export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack.js';
export { QuaternionKeyframeTrack } from './animation/tracks/QuaternionKeyframeTrack.js';
export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack.js';
export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack.js';

export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube.js';
export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
export { WebGLRenderer } from './renderers/WebGLRenderer.js';
// export { WebGL2Renderer } from './renderers/WebGL2Renderer.js';
export { ShaderLib } from './renderers/shaders/ShaderLib.js';
export { UniformsLib } from './renderers/shaders/UniformsLib.js';
export { UniformsUtils } from './renderers/shaders/UniformsUtils.js';
export { ShaderChunk } from './renderers/shaders/ShaderChunk.js';
export { FogExp2 } from './scenes/FogExp2.js';
export { Fog } from './scenes/Fog.js';
export { Scene } from './scenes/Scene.js';
export { LensFlare } from './objects/LensFlare.js';
export { Sprite } from './objects/Sprite.js';
export { LOD } from './objects/LOD.js';
export { SkinnedMesh } from './objects/SkinnedMesh.js';
export { Skeleton } from './objects/Skeleton.js';
export { Bone } from './objects/Bone.js';
export { Mesh } from './objects/Mesh.js';
export { LineSegments } from './objects/LineSegments.js';
export { Line } from './objects/Line.js';
export { Points } from './objects/Points.js';
export { Group } from './objects/Group.js';
export { VideoTexture } from './textures/VideoTexture.js';
export { DataTexture } from './textures/DataTexture.js';
export { CompressedTexture } from './textures/CompressedTexture.js';
export { CubeTexture } from './textures/CubeTexture.js';
export { CanvasTexture } from './textures/CanvasTexture.js';
export { DepthTexture } from './textures/DepthTexture.js';
export { Texture } from './textures/Texture.js';
export * from './geometries/Geometries.js';
export * from './materials/Materials.js';
export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js';
export { DataTextureLoader } from './loaders/DataTextureLoader.js';
export { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
export { TextureLoader } from './loaders/TextureLoader.js';
export { ObjectLoader } from './loaders/ObjectLoader.js';
export { MaterialLoader } from './loaders/MaterialLoader.js';
export { BufferGeometryLoader } from './loaders/BufferGeometryLoader.js';
export { DefaultLoadingManager, LoadingManager } from './loaders/LoadingManager.js';
export { JSONLoader } from './loaders/JSONLoader.js';
export { ImageLoader } from './loaders/ImageLoader.js';
export { FontLoader } from './loaders/FontLoader.js';
export { FileLoader } from './loaders/FileLoader.js';
export { Loader } from './loaders/Loader.js';
export { Cache } from './loaders/Cache.js';
export { AudioLoader } from './loaders/AudioLoader.js';
export { SpotLightShadow } from './lights/SpotLightShadow.js';
export { SpotLight } from './lights/SpotLight.js';
export { PointLight } from './lights/PointLight.js';
export { RectAreaLight } from './lights/RectAreaLight.js';
export { HemisphereLight } from './lights/HemisphereLight.js';
export { DirectionalLightShadow } from './lights/DirectionalLightShadow.js';
export { DirectionalLight } from './lights/DirectionalLight.js';
export { AmbientLight } from './lights/AmbientLight.js';
export { LightShadow } from './lights/LightShadow.js';
export { Light } from './lights/Light.js';
export { StereoCamera } from './cameras/StereoCamera.js';
export { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
export { OrthographicCamera } from './cameras/OrthographicCamera.js';
export { CubeCamera } from './cameras/CubeCamera.js';
export { Camera } from './cameras/Camera.js';
export { AudioListener } from './audio/AudioListener.js';
export { PositionalAudio } from './audio/PositionalAudio.js';
export { AudioContext } from './audio/AudioContext.js';
export { AudioAnalyser } from './audio/AudioAnalyser.js';
export { Audio } from './audio/Audio.js';
export { Uniform } from './core/Uniform.js';
export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
export { BufferGeometry } from './core/BufferGeometry.js';
export { GeometryIdCount, Geometry } from './core/Geometry.js';
export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js';
export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js';
export { InterleavedBuffer } from './core/InterleavedBuffer.js';
export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js';
export * from './core/BufferAttribute.js';
export { Face3 } from './core/Face3.js';
export { Object3D } from './core/Object3D.js';
export { Raycaster } from './core/Raycaster.js';
export { Layers } from './core/Layers.js';
export { EventDispatcher } from './core/EventDispatcher.js';
export { Clock } from './core/Clock.js';
export { QuaternionLinearInterpolant } from './math/interpolants/QuaternionLinearInterpolant.js';
export { LinearInterpolant } from './math/interpolants/LinearInterpolant.js';
export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js';
export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
export { Interpolant } from './math/Interpolant.js';
export { Triangle } from './math/Triangle.js';
export { _Math as Math } from './math/Math.js';
export { Spherical } from './math/Spherical.js';
export { Cylindrical } from './math/Cylindrical.js';
export { Plane } from './math/Plane.js';
export { Frustum } from './math/Frustum.js';
export { Sphere } from './math/Sphere.js';
export { Ray } from './math/Ray.js';
export { Matrix4 } from './math/Matrix4.js';
export { Matrix3 } from './math/Matrix3.js';
export { Box3 } from './math/Box3.js';
export { Box2 } from './math/Box2.js';
export { Line3 } from './math/Line3.js';
export { Euler } from './math/Euler.js';
export { Vector4 } from './math/Vector4.js';
export { Vector3 } from './math/Vector3.js';
export { Vector2 } from './math/Vector2.js';
export { Quaternion } from './math/Quaternion.js';
export { Color } from './math/Color.js';
export { MorphBlendMesh } from './extras/objects/MorphBlendMesh.js';
export { ImmediateRenderObject } from './extras/objects/ImmediateRenderObject.js';
export { VertexNormalsHelper } from './helpers/VertexNormalsHelper.js';
export { SpotLightHelper } from './helpers/SpotLightHelper.js';
export { SkeletonHelper } from './helpers/SkeletonHelper.js';
export { PointLightHelper } from './helpers/PointLightHelper.js';
export { RectAreaLightHelper } from './helpers/RectAreaLightHelper.js';
export { HemisphereLightHelper } from './helpers/HemisphereLightHelper.js';
export { GridHelper } from './helpers/GridHelper.js';
export { PolarGridHelper } from './helpers/PolarGridHelper.js';
export { FaceNormalsHelper } from './helpers/FaceNormalsHelper.js';
export { DirectionalLightHelper } from './helpers/DirectionalLightHelper.js';
export { CameraHelper } from './helpers/CameraHelper.js';
export { BoxHelper } from './helpers/BoxHelper.js';
export { ArrowHelper } from './helpers/ArrowHelper.js';
export { AxisHelper } from './helpers/AxisHelper.js';
export { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js';
export { CubicBezierCurve3 } from './extras/curves/CubicBezierCurve3.js';
export { QuadraticBezierCurve3 } from './extras/curves/QuadraticBezierCurve3.js';
export { LineCurve3 } from './extras/curves/LineCurve3.js';
export { ArcCurve } from './extras/curves/ArcCurve.js';
export { EllipseCurve } from './extras/curves/EllipseCurve.js';
export { SplineCurve } from './extras/curves/SplineCurve.js';
export { CubicBezierCurve } from './extras/curves/CubicBezierCurve.js';
export { QuadraticBezierCurve } from './extras/curves/QuadraticBezierCurve.js';
export { LineCurve } from './extras/curves/LineCurve.js';
export { Shape } from './extras/core/Shape.js';
export { Path } from './extras/core/Path.js';
export { ShapePath } from './extras/core/ShapePath.js';
export { Font } from './extras/core/Font.js';
export { CurvePath } from './extras/core/CurvePath.js';
export { Curve } from './extras/core/Curve.js';
export { ShapeUtils } from './extras/ShapeUtils.js';
export { SceneUtils } from './extras/SceneUtils.js';

<commit_msg>Update path in Three.Unit.js file due to file move<commit_after>import '../src/polyfills.js';

export * from '../src/constants.js';
export * from '../src/Three.Legacy.js';

export { AnimationAction } from '../src/animation/AnimationAction.js';
export { AnimationClip } from '../src/animation/AnimationClip.js';
export { AnimationMixer } from '../src/animation/AnimationMixer.js';
export { AnimationObjectGroup } from '../src/animation/AnimationObjectGroup.js';
export { AnimationUtils } from '../src/animation/AnimationUtils.js';
export { KeyframeTrack } from '../src/animation/KeyframeTrack.js';
export { KeyframeTrackConstructor } from '../src/animation/KeyframeTrackConstructor.js';
export { KeyframeTrackPrototype } from '../src/animation/KeyframeTrackPrototype.js';
export { PropertyBinding } from '../src/animation/PropertyBinding.js';
export { PropertyMixer } from '../src/animation/PropertyMixer.js';

export { BooleanKeyframeTrack } from '../src/animation/tracks/BooleanKeyframeTrack.js';
export { ColorKeyframeTrack } from '../src/animation/tracks/ColorKeyframeTrack.js';
export { NumberKeyframeTrack } from '../src/animation/tracks/NumberKeyframeTrack.js';
export { QuaternionKeyframeTrack } from '../src/animation/tracks/QuaternionKeyframeTrack.js';
export { StringKeyframeTrack } from '../src/animation/tracks/StringKeyframeTrack.js';
export { VectorKeyframeTrack } from '../src/animation/tracks/VectorKeyframeTrack.js';

export { WebGLRenderTargetCube } from '../src/renderers/WebGLRenderTargetCube.js';
export { WebGLRenderTarget } from '../src/renderers/WebGLRenderTarget.js';
export { WebGLRenderer } from '../src/renderers/WebGLRenderer.js';
// export { WebGL2Renderer } from '../src/renderers/WebGL2Renderer.js';
export { ShaderLib } from '../src/renderers/shaders/ShaderLib.js';
export { UniformsLib } from '../src/renderers/shaders/UniformsLib.js';
export { UniformsUtils } from '../src/renderers/shaders/UniformsUtils.js';
export { ShaderChunk } from '../src/renderers/shaders/ShaderChunk.js';
export { FogExp2 } from '../src/scenes/FogExp2.js';
export { Fog } from '../src/scenes/Fog.js';
export { Scene } from '../src/scenes/Scene.js';
export { LensFlare } from '../src/objects/LensFlare.js';
export { Sprite } from '../src/objects/Sprite.js';
export { LOD } from '../src/objects/LOD.js';
export { SkinnedMesh } from '../src/objects/SkinnedMesh.js';
export { Skeleton } from '../src/objects/Skeleton.js';
export { Bone } from '../src/objects/Bone.js';
export { Mesh } from '../src/objects/Mesh.js';
export { LineSegments } from '../src/objects/LineSegments.js';
export { Line } from '../src/objects/Line.js';
export { Points } from '../src/objects/Points.js';
export { Group } from '../src/objects/Group.js';
export { VideoTexture } from '../src/textures/VideoTexture.js';
export { DataTexture } from '../src/textures/DataTexture.js';
export { CompressedTexture } from '../src/textures/CompressedTexture.js';
export { CubeTexture } from '../src/textures/CubeTexture.js';
export { CanvasTexture } from '../src/textures/CanvasTexture.js';
export { DepthTexture } from '../src/textures/DepthTexture.js';
export { Texture } from '../src/textures/Texture.js';
export * from '../src/geometries/Geometries.js';
export * from '../src/materials/Materials.js';
export { CompressedTextureLoader } from '../src/loaders/CompressedTextureLoader.js';
export { DataTextureLoader } from '../src/loaders/DataTextureLoader.js';
export { CubeTextureLoader } from '../src/loaders/CubeTextureLoader.js';
export { TextureLoader } from '../src/loaders/TextureLoader.js';
export { ObjectLoader } from '../src/loaders/ObjectLoader.js';
export { MaterialLoader } from '../src/loaders/MaterialLoader.js';
export { BufferGeometryLoader } from '../src/loaders/BufferGeometryLoader.js';
export { DefaultLoadingManager, LoadingManager } from '../src/loaders/LoadingManager.js';
export { JSONLoader } from '../src/loaders/JSONLoader.js';
export { ImageLoader } from '../src/loaders/ImageLoader.js';
export { FontLoader } from '../src/loaders/FontLoader.js';
export { FileLoader } from '../src/loaders/FileLoader.js';
export { Loader } from '../src/loaders/Loader.js';
export { Cache } from '../src/loaders/Cache.js';
export { AudioLoader } from '../src/loaders/AudioLoader.js';
export { SpotLightShadow } from '../src/lights/SpotLightShadow.js';
export { SpotLight } from '../src/lights/SpotLight.js';
export { PointLight } from '../src/lights/PointLight.js';
export { RectAreaLight } from '../src/lights/RectAreaLight.js';
export { HemisphereLight } from '../src/lights/HemisphereLight.js';
export { DirectionalLightShadow } from '../src/lights/DirectionalLightShadow.js';
export { DirectionalLight } from '../src/lights/DirectionalLight.js';
export { AmbientLight } from '../src/lights/AmbientLight.js';
export { LightShadow } from '../src/lights/LightShadow.js';
export { Light } from '../src/lights/Light.js';
export { StereoCamera } from '../src/cameras/StereoCamera.js';
export { PerspectiveCamera } from '../src/cameras/PerspectiveCamera.js';
export { OrthographicCamera } from '../src/cameras/OrthographicCamera.js';
export { CubeCamera } from '../src/cameras/CubeCamera.js';
export { Camera } from '../src/cameras/Camera.js';
export { AudioListener } from '../src/audio/AudioListener.js';
export { PositionalAudio } from '../src/audio/PositionalAudio.js';
export { AudioContext } from '../src/audio/AudioContext.js';
export { AudioAnalyser } from '../src/audio/AudioAnalyser.js';
export { Audio } from '../src/audio/Audio.js';
export { Uniform } from '../src/core/Uniform.js';
export { InstancedBufferGeometry } from '../src/core/InstancedBufferGeometry.js';
export { BufferGeometry } from '../src/core/BufferGeometry.js';
export { GeometryIdCount, Geometry } from '../src/core/Geometry.js';
export { InterleavedBufferAttribute } from '../src/core/InterleavedBufferAttribute.js';
export { InstancedInterleavedBuffer } from '../src/core/InstancedInterleavedBuffer.js';
export { InterleavedBuffer } from '../src/core/InterleavedBuffer.js';
export { InstancedBufferAttribute } from '../src/core/InstancedBufferAttribute.js';
export * from '../src/core/BufferAttribute.js';
export { Face3 } from '../src/core/Face3.js';
export { Object3D } from '../src/core/Object3D.js';
export { Raycaster } from '../src/core/Raycaster.js';
export { Layers } from '../src/core/Layers.js';
export { EventDispatcher } from '../src/core/EventDispatcher.js';
export { Clock } from '../src/core/Clock.js';
export { QuaternionLinearInterpolant } from '../src/math/interpolants/QuaternionLinearInterpolant.js';
export { LinearInterpolant } from '../src/math/interpolants/LinearInterpolant.js';
export { DiscreteInterpolant } from '../src/math/interpolants/DiscreteInterpolant.js';
export { CubicInterpolant } from '../src/math/interpolants/CubicInterpolant.js';
export { Interpolant } from '../src/math/Interpolant.js';
export { Triangle } from '../src/math/Triangle.js';
export { _Math as Math } from '../src/math/Math.js';
export { Spherical } from '../src/math/Spherical.js';
export { Cylindrical } from '../src/math/Cylindrical.js';
export { Plane } from '../src/math/Plane.js';
export { Frustum } from '../src/math/Frustum.js';
export { Sphere } from '../src/math/Sphere.js';
export { Ray } from '../src/math/Ray.js';
export { Matrix4 } from '../src/math/Matrix4.js';
export { Matrix3 } from '../src/math/Matrix3.js';
export { Box3 } from '../src/math/Box3.js';
export { Box2 } from '../src/math/Box2.js';
export { Line3 } from '../src/math/Line3.js';
export { Euler } from '../src/math/Euler.js';
export { Vector4 } from '../src/math/Vector4.js';
export { Vector3 } from '../src/math/Vector3.js';
export { Vector2 } from '../src/math/Vector2.js';
export { Quaternion } from '../src/math/Quaternion.js';
export { Color } from '../src/math/Color.js';
export { MorphBlendMesh } from '../src/extras/objects/MorphBlendMesh.js';
export { ImmediateRenderObject } from '../src/extras/objects/ImmediateRenderObject.js';
export { VertexNormalsHelper } from '../src/helpers/VertexNormalsHelper.js';
export { SpotLightHelper } from '../src/helpers/SpotLightHelper.js';
export { SkeletonHelper } from '../src/helpers/SkeletonHelper.js';
export { PointLightHelper } from '../src/helpers/PointLightHelper.js';
export { RectAreaLightHelper } from '../src/helpers/RectAreaLightHelper.js';
export { HemisphereLightHelper } from '../src/helpers/HemisphereLightHelper.js';
export { GridHelper } from '../src/helpers/GridHelper.js';
export { PolarGridHelper } from '../src/helpers/PolarGridHelper.js';
export { FaceNormalsHelper } from '../src/helpers/FaceNormalsHelper.js';
export { DirectionalLightHelper } from '../src/helpers/DirectionalLightHelper.js';
export { CameraHelper } from '../src/helpers/CameraHelper.js';
export { BoxHelper } from '../src/helpers/BoxHelper.js';
export { ArrowHelper } from '../src/helpers/ArrowHelper.js';
export { AxisHelper } from '../src/helpers/AxisHelper.js';
export { CatmullRomCurve3 } from '../src/extras/curves/CatmullRomCurve3.js';
export { CubicBezierCurve3 } from '../src/extras/curves/CubicBezierCurve3.js';
export { QuadraticBezierCurve3 } from '../src/extras/curves/QuadraticBezierCurve3.js';
export { LineCurve3 } from '../src/extras/curves/LineCurve3.js';
export { ArcCurve } from '../src/extras/curves/ArcCurve.js';
export { EllipseCurve } from '../src/extras/curves/EllipseCurve.js';
export { SplineCurve } from '../src/extras/curves/SplineCurve.js';
export { CubicBezierCurve } from '../src/extras/curves/CubicBezierCurve.js';
export { QuadraticBezierCurve } from '../src/extras/curves/QuadraticBezierCurve.js';
export { LineCurve } from '../src/extras/curves/LineCurve.js';
export { Shape } from '../src/extras/core/Shape.js';
export { Path } from '../src/extras/core/Path.js';
export { ShapePath } from '../src/extras/core/ShapePath.js';
export { Font } from '../src/extras/core/Font.js';
export { CurvePath } from '../src/extras/core/CurvePath.js';
export { Curve } from '../src/extras/core/Curve.js';
export { ShapeUtils } from '../src/extras/ShapeUtils.js';
export { SceneUtils } from '../src/extras/SceneUtils.js';

<|endoftext|>


<commit_before>var assert = require('assert');
var Buffer = require('buffer').Buffer;
var fs = require('fs');
var blend = require('..');

if (process.setMaxListeners) process.setMaxListeners(0);

var images = [
    fs.readFileSync('test/fixture/1.png'),
    fs.readFileSync('test/fixture/2.png'),
    fs.readFileSync('test/fixture/3.png'),
    fs.readFileSync('test/fixture/4.png'),
    fs.readFileSync('test/fixture/5.png')
];

exports['test first argument bogus'] = function(beforeExit) {
    var completed = false;
    blend(true, function(err) {
        completed = true;
        assert.ok(err && /First argument must be an array of Buffers/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test first argument empty'] = function(beforeExit) {
    var completed = false;
    blend([], function(err) {
        completed = true;
        assert.ok(err && /First argument must contain at least one Buffer/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test bogus elements in array'] = function(beforeExit) {
    var completed = false;
    blend([1,2,3], function(err) {
        completed = true;
        assert.ok(err && /All elements must be Buffers/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with topmost image having no alpha'] = function(beforeExit) {
    var completed = false;
    blend([ images[1], images[0] ], function(err, data) {
        completed = true;
        if (err) throw err;
        assert.deepEqual(images[0], data);
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with bogus buffer'] = function(beforeExit) {
    var completed = false;
    blend([ new Buffer(1024), new Buffer(1024) ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, "Unknown image format");
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with semi-bogus buffer'] = function(beforeExit) {
    var completed = false;
    var buffer = new Buffer('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A' + Array(48).join('\0'), 'binary');
    blend([ buffer, images[1] ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, 'Error: [00][00][00][00]: invalid chunk type');
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with buffer that only contains the header'] = function(beforeExit) {
    var completed = false;
    var buffer = new Buffer('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A', 'binary');
    blend([ buffer, images[1] ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, 'Read Error');
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function'] = function(beforeExit) {
    var completed = false;

    blend(images, function(err, data) {
        completed = true;
        if (err) throw err;
        // assert.notDeepEqual(images[4], data);
    });

    beforeExit(function() { assert.ok(completed); });
};
<commit_msg>test for correct error message<commit_after>var assert = require('assert');
var Buffer = require('buffer').Buffer;
var fs = require('fs');
var blend = require('..');

if (process.setMaxListeners) process.setMaxListeners(0);

var images = [
    fs.readFileSync('test/fixture/1.png'),
    fs.readFileSync('test/fixture/2.png'),
    fs.readFileSync('test/fixture/3.png'),
    fs.readFileSync('test/fixture/4.png'),
    fs.readFileSync('test/fixture/5.png')
];

exports['test first argument bogus'] = function(beforeExit) {
    var completed = false;
    blend(true, function(err) {
        completed = true;
        assert.ok(err && /First argument must be an array of Buffers/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test first argument empty'] = function(beforeExit) {
    var completed = false;
    blend([], function(err) {
        completed = true;
        assert.ok(err && /First argument must contain at least one Buffer/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test bogus elements in array'] = function(beforeExit) {
    var completed = false;
    blend([1,2,3], function(err) {
        completed = true;
        assert.ok(err && /All elements must be Buffers/.test(err.message));
    });
    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with topmost image having no alpha'] = function(beforeExit) {
    var completed = false;
    blend([ images[1], images[0] ], function(err, data) {
        completed = true;
        if (err) throw err;
        assert.deepEqual(images[0], data);
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with bogus buffer'] = function(beforeExit) {
    var completed = false;
    blend([ new Buffer(1024), new Buffer(1024) ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, "Unknown image format");
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with semi-bogus buffer'] = function(beforeExit) {
    var completed = false;
    var buffer = new Buffer('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A' + Array(48).join('\0'), 'binary');
    blend([ buffer, images[1] ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, '[00][00][00][00]: invalid chunk type');
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function with buffer that only contains the header'] = function(beforeExit) {
    var completed = false;
    var buffer = new Buffer('\x89\x50\x4E\x47\x0D\x0A\x1A\x0A', 'binary');
    blend([ buffer, images[1] ], function(err, data) {
        completed = true;
        assert.ok(err);
        assert.equal(err.message, 'Read Error');
    });

    beforeExit(function() { assert.ok(completed); });
};

exports['test blend function'] = function(beforeExit) {
    var completed = false;

    blend(images, function(err, data) {
        completed = true;
        if (err) throw err;
        // assert.notDeepEqual(images[4], data);
    });

    beforeExit(function() { assert.ok(completed); });
};
<|endoftext|>


<commit_before>var assert = require('assert')
var browserify = tryRequire('browserify')
var methods = null
var path = require('path')
var run = browserify ? describe : describe.skip
var vm = require('vm')

run('when browserified', function () {
  before(function (done) {
    var b = browserify()

    // require methods
    b.require(path.join(__dirname, '..'), {
      expose: 'methods'
    })

    // bundle and eval
    b.bundle(function (err, buf) {
      if (err) return done(err)
      var require = vm.runInNewContext(buf.toString())
      methods = require('methods')
      done()
    })
  })

  describe('methods', function () {
    ['get', 'post', 'put', 'patch', 'delete'].forEach(function (method) {
      it('should contain "' + method + '"', function () {
        assert.notEqual(methods.indexOf(method), -1)
      })
    })

    it('should only have lower-case entries', function () {
      for (var i = 0; i < methods.length; i++) {
        assert(methods[i], methods[i].toLowerCase(), methods[i] + ' is lower-case')
      }
    })
  })
})

function tryRequire (name) {
  try {
    return require(name)
  } catch (e) {
    return undefined
  }
}
<commit_msg>build: instrument browserify tests<commit_after>var assert = require('assert')
var browserify = tryRequire('browserify')
var istanbul = tryRequire('istanbul')
var methods = null
var path = require('path')
var run = browserify ? describe : describe.skip
var stream = require('stream')
var vm = require('vm')

run('when browserified', function () {
  before(function (done) {
    var b = browserify()
    var c = {}

    // instrument
    if (istanbul && getCoverageGlobal()) {
      b.transform(istanbulify(c))
    }

    // require methods
    b.require(path.join(__dirname, '..'), {
      expose: 'methods'
    })

    // bundle and eval
    b.bundle(function (err, buf) {
      if (err) return done(err)
      var require = vm.runInNewContext(buf.toString(), c)
      methods = require('methods')
      done()
    })
  })

  describe('methods', function () {
    ['get', 'post', 'put', 'patch', 'delete'].forEach(function (method) {
      it('should contain "' + method + '"', function () {
        assert.notEqual(methods.indexOf(method), -1)
      })
    })

    it('should only have lower-case entries', function () {
      for (var i = 0; i < methods.length; i++) {
        assert(methods[i], methods[i].toLowerCase(), methods[i] + ' is lower-case')
      }
    })
  })
})

function getCoverageGlobal () {
  for (var key in global) {
    if (key.substr(0, 6) === '$$cov_') {
      return global[key]
    }
  }
}

function istanbulify (context) {
  // link coverage
  context.__coverage__ = getCoverageGlobal()

  // browserify transform
  return function (file) {
    var chunks = []
    var instrumenter = new istanbul.Instrumenter()
    var transformer = new stream.Transform()

    // buffer chunks
    transformer._transform = function _transform (data, encoding, callback) {
      chunks.push(data)
      callback()
    }

    // transform on flush
    transformer._flush = function _flush (callback) {
      var contents = Buffer.concat(chunks).toString()
      instrumenter.instrument(contents, file, function (err, output) {
        if (err) return transformer.emit('error', err)
        transformer.push(output)
        transformer.push(null)
        callback()
      })
    }

    return transformer
  }
}

function tryRequire (name) {
  try {
    return require(name)
  } catch (e) {
    return undefined
  }
}
<|endoftext|>


<commit_before>// nodeunit

if(typeof $object==='undefined'){
    var ns = require('../src/clone.js'),
        $object = ns.prototype;
}

this['test $object'] = {

    clone: function(test){
        var clone = $object.clone({a:1});
            test.ok( clone.hasOwnProperty('a') );
            test.equal( Object.getPrototypeOf(clone), $object);
            test.strictEqual( Object.getOwnPropertyNames(clone).length, 1);

        clone = $object.clone({a:1}, {});
            test.ok( clone.hasOwnProperty('a') );
            test.equal( Object.getPrototypeOf(clone), $object);
            test.strictEqual( Object.getOwnPropertyNames(clone).length, 1);

        clone = $object.clone();
            test.strictEqual( Object.getOwnPropertyNames(clone).length, 0);
            test.equal( Object.getPrototypeOf(clone), $object);

        test.done();
    },

    'clone.call': function(test){
        var $proto = {a: 1};

            var clone = $object.clone.call($proto);
                test.equal( Object.getPrototypeOf(clone), $proto,
                    'check prototype');

            clone = $object.clone.call($proto, {b:2});
                test.ok( clone.hasOwnProperty('b') );

            clone = $object.clone.call($proto, {b:2}, {});
                test.ok( clone.hasOwnProperty('b') );

        test.done();
    },

    'clone.constructor': function(test){
        var constructor = $object.clone({constructor: ''}).constructor;
        var c = $object.clone({constructor: ''});
            test.ok(constructor !== c.constructor);
            test.ok(constructor !== $object.clone().constructor);
            test.equal(typeof constructor, 'function');

        test.done();
    },

    create: {

        '': function(test){
            var customConstructorCalled = false;
            var $myType = $object.clone({
                constructor: function(){
                    customConstructorCalled = true;
                }
            });
            var instance = $myType.create({ignored: true});
                test.ok(customConstructorCalled);
                test.ok(typeof instance.ignored == 'undefined');

    //        instance = $object.create();
    //            test.ok( Object.isSealed(instance), 'the created object should be sealed by default');

            test.done();
        },

        'super property should can be modified': function(test){

            var obj = $object.clone({a: 1}).create();
            obj.a = 2;

                test.equal(obj.a, 2);

            test.done();
        }
    },

    describe: function(test){

        function Constructor(){}

        test.deepEqual(
            $object.describe({
                          _p: undefined,
       '(const) _unwritable': 231,
                   property1: 11,
        '(hidden) property2': 22,
      '(writable) property3': 33,
         '(final) property4': 44,
'(final writable) property5': 55,
                      method: Function,
                 constructor: Constructor
            }),{
                         _p: {value: undefined, enumerable:false},
                _unwritable: {value: 231, enumerable:false, writable: false},
                  property1: {value: 11},
                  property2: {value: 22, enumerable:false},
                  property3: {value: 33, writable:true},
                  property4: {value: 44, writable:false, configurable: false},
                  property5: {value: 55, writable:true, configurable: false},
                     method: {value: Function, enumerable:false},
                constructor: {value: Constructor, enumerable:false}
            }
        );

        /// Constructor:

        var proto = {};
        var descriptors = $object.describe.call(proto, {constructor: 'MyCustomName'});

            var constructor = descriptors.constructor.value;
            test.equal(typeof constructor, 'function');
            test.equal(constructor.name, 'MyCustomName');
            test.equal(constructor.typeName, 'MyCustomName');
            test.strictEqual(constructor.prototype, proto);

        var $obj = $object.clone().clone();
        constructor.call($obj, {key: 11});

            test.equal($obj.key, 11);

        /// TODO: test defaultDescriptor

        test.done();
    },

    'can, cant': function(test){

        var $myObj = $object.clone({
            fly: function(){},
            swim: function(a,b,c){}
        });
        var myObj = $myObj.create();
            test.ok(!!   myObj.can('swim').as($myObj) );
            test.ok(!! $object.can.call(myObj, 'fly').like($myObj) );

            test.ok(!    myObj.cant('swim').as($myObj) );
            test.ok(!  $object.cant.call(myObj, 'fly').like($myObj) );

        test.done();
    },

    copy: function(test){
        var myArray = $object.copy(Array);
        myArray[0] = 11;
        myArray[1] = 22;
            test.deepEqual(myArray, [11 ,22]);

            myArray.defineProperties({test: 'T'});
                test.strictEqual(myArray.test, 'T');

        var $collection = $object.clone({items: []});
        var $users = $collection.clone({name: ''});

            // $users full prototype chain:
            //$users -> $collection -> $object -> Object.prototype -> null

            // see prototype chains produced by copy:

            var userCopy = $users.copy();
            //~$users -> $object
                test.equal(Object.getPrototypeOf(userCopy), $object);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.items === undefined);

            userCopy = $users.copy(Array);
            //~$users -> Array.prototype
                test.equal(Object.getPrototypeOf(userCopy), Array.prototype);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.items === undefined);
                test.ok(userCopy.clone === undefined);

            userCopy = $users.copy(Array, Infinity);
            //~$users -> ~$collection -> ~$object -> Array.prototype
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.getPrototype().hasOwnProperty('items'));
                test.ok(userCopy.getPrototype().getPrototype().hasOwnProperty('clone'));
                test.ok(userCopy.getPrototype().getPrototype().getPrototype() === Array.prototype);

            userCopy = $users.copy(Array, Infinity, true);
            //~($users + $collection + $object) -> Array.prototype
                test.equal(Object.getPrototypeOf(userCopy), Array.prototype);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.hasOwnProperty('items'));
                test.ok(userCopy.hasOwnProperty('clone'));

        //TODO: add tests for deepCopy/deepClone

        test.done();
    },

    deepCopy: function(test){
        var obj = $object.clone({l1: {l2: {l3: null}}});
        var deepCopy = obj.deepCopy();
        test.strictEqual(deepCopy.l1.l2.l3, null);

            obj.l1.l2.l3 = 11;
                test.strictEqual(deepCopy.l1.l2.l3, null);

            deepCopy.l1.l2.l3 = 22;
                test.strictEqual(obj.l1.l2.l3, 11);

        test.done();
    },

    deepClone: function(test){
        var obj = $object.clone({l1: {l2: {l3: null}}});
        var deepClone = obj.deepClone();
            test.strictEqual(deepClone.l1.l2.l3, null);

            obj.l1.l2.l3 = 11;
                test.strictEqual(deepClone.l1.l2.l3, 11);

            deepClone.l1.l2.l3 = 22;
                test.strictEqual(obj.l1.l2.l3, 11);

        test.done();
    },

    'callSuper, applySuper': {
        test: function(test){
            var calls = [];
            var $parent = $object.clone({
                constructor: function(arg){
                    calls.push('collection');
                    this.callSuper('constructor', arg);
                }
            });
            var $child = $parent.clone({
                constructor: function(arg){
                    calls.push('users');
                    this.applySuper(arguments);
                }
            });
            var child = $child.create({setBy$objectConstructor: 11});

                test.deepEqual(calls, ['users','collection']);
                test.equal(child.setBy$objectConstructor, 11);

            test.done();
        },

        'first call applySuper() on sealed object': function(test){
            var $parent = $object.clone({
                method: function(){}
            });
            var $child = $parent.clone({
                method: function(arg){
                    this.applySuper('method');
                }
            });
            var child = $child.clone();

            child.seal();
            child.method();

            test.done();
        }
    },

    createSuperSafeCallback: function(test){

        test.expect(2);

        var $parent = $object.clone({
            constructor: function(){},
            asyncMethod: function(){
                var args = arguments;
                var callback = function(){
                    this.applySuper(args);
                    test.equal(this.__super__, $object);
                }
                setTimeout( this.createSuperSafeCallback(callback, this) );
            }
        });
        var $child = $parent.clone({
            constructor: function(){
                this.applySuper('asyncMethod', [{a:11}]);
                test.equal(this.__super__, $parent);
            }
        });

        var child = $child.create();

        setTimeout(function(){
//            console.log(child.a);
//            test.equal(11, child.a);
            test.done();
        });
    },

    apply: function(test){
        //methodName, args, withObj, asObj
        var asObj = {defineProperties: function(){
            this.called = true;
            return this;
        }};
        var obj = $object.apply(Array(22,33), 'defineProperties',[{a:11}], asObj);
            test.equal(obj.a, undefined);
            test.ok(obj.called);
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        //methodName, args, withObj
        obj = $object.apply(Array(22,33), 'defineProperties',[{a:11}]);
            test.equal(obj.a,  11);
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        //methodName, withObj
        obj = $object.apply(Array(22,33), 'defineProperties');
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        test.done();
    },

    concat: function(test){
        var $parent = $object.clone({a: 1});
        var $child  = $parent.clone({b: 2});
        var toMerge = $child .clone({c: 3, _c: 33});

            var obj = $object.clone().concat(toMerge);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  3);
                test.strictEqual(obj.b,  undefined);
                test.strictEqual(obj.a,  undefined);

            obj = $object.clone().concat(toMerge, ['a','_c']);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  undefined);
                test.strictEqual(obj.b,  undefined);
                test.strictEqual(obj.a,  1);

            obj = $object.clone().concat(toMerge, true);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  3);
                test.strictEqual(obj.b,  2);
                test.strictEqual(obj.a,  1);

        test.done();
    },

    getPrototypes: function(test){
        var ns = clonejs.$namespace.clone();
            ns.extend('level1',{n:1})
              .extend('level1_1',{n:2})
              .extend('level1_1_1',{n:3});

        var $obj = ns.level1.level1_1.$level1_1_1.create();

            test.deepEqual($obj.getPrototypes(), [{n:1}, {n:2}, {n:3}]);
            test.deepEqual($obj.getPrototypes(undefined, true), [{n:3}, {n:2}, {n:1}]);
            test.deepEqual($obj.getPrototypes(Object.prototype), [Object.prototype, {n:1}, {n:2}, {n:3}]);
            //test.deepEqual($obj.getPrototypes(null), [Object.prototype, Object.prototype, {n:1}, {n:2}, {n:3}]);

        test.done();
    },

    getValues: function(test){
        var obj = $object.clone({en:'1 0', _p:'0 0'}).clone({ownEn:'1 1', _own:'0 1'});
        //                      enumerable,   own
        test.deepEqual(obj.getValues(true,   true).sort(), [ '1 1' ]);
        test.deepEqual(obj.getValues(false, false).sort(), [ '0 0', '0 1', '1 0', '1 1' ]);
        test.deepEqual(obj.getValues(false,  true).sort(), [ '0 1', '1 1' ]);
        test.deepEqual(obj.getValues(true,  false).sort(), [ '1 0', '1 1' ]);

        test.done();
    },

    setValues: function(test){
        var obj = $object.clone({en:'1 0', _p:'0 0'}).clone({ownEn:'1 1', _own:'0 1'}), values;

        values = obj.getValues();
            test.deepEqual(obj, obj.copy(Infinity).setValues(values) );

        values = obj.getValues(true);
            test.deepEqual(obj, obj.copy(Infinity).setValues(values, true) );

//        console.log('copy values:', obj.copy(Infinity).getValues(false) );
//        values = obj.getValues(false);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false) );
//        console.log(values);
//
//        values = obj.getValues(true, false);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, true,  false) );
//
//        values = obj.getValues(false, true);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false, true) );
//
//        values = obj.getValues(false, false);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false, false) );

        test.done();
    },

    $namespace: {
        /*

        namespace contents:
            ns = {
                prototype: $ns,
                items: {
                    prototype: $item,
                    subitems: {},
                    $subitem: $subitem,

                    extend: $ns.extend
                },
                $item: $item,

                extend: $ns.extend,
                put: $ns.put
            }

        1) $subitem should be a direct child of $item
        2) items, subitems should be plural

        clone.clone()
        clone.prototype
        */

        extend: function(test){
            var ns1 = clonejs.$namespace.create();
            ns1.extend('collection',          {name: 'collection'})
                   .extend('arrayCollection', {name: 'arrayCollection'});

                _ns_check(ns1, test);

            test.done();
        },

        put: function(test){
            var $collection = $object.clone({constructor: 'Collection'}),
                $arrayCollection = $collection.clone({constructor: 'ArrayCollection'});
            var ns2 = clonejs.$namespace.create();
            ns2.put($arrayCollection);

                _ns_check(ns2, test);

            var ns3 = clonejs.$namespace.create();
            ns3.put('collection.arrayCollection', $arrayCollection);

                _ns_check(ns3, test);

            test.done();
        }
    }
};

function _ns_check(newNS, test){
    test.strictEqual(newNS.prototype, $object);
    test.strictEqual(newNS.extend,    clonejs.$namespace.extend);
    test.strictEqual(newNS.put,       clonejs.$namespace.put);

    test.ok( $object.isPrototypeOf(newNS.$collection) );
    test.equal( newNS.$collection.constructor.typeName, 'Collection');
    test.strictEqual(newNS.collection.prototype, newNS.$collection);
    test.strictEqual(newNS.collection.extend,    clonejs.$namespace.extend);

    test.ok( newNS.$collection.isPrototypeOf(newNS.collection.$arrayCollection) );
    test.equal( newNS.collection.$arrayCollection.constructor.typeName, 'ArrayCollection');
    test.strictEqual(newNS.collection.arrayCollection.prototype, newNS.collection.$arrayCollection);
    test.strictEqual(newNS.collection.arrayCollection.extend,    clonejs.$namespace.extend);
}
<commit_msg>refactor tests<commit_after>// nodeunit

if(typeof $object==='undefined'){
    var clonejs = require('../src/clone.js'),
        $object = clonejs.prototype;
}

this.tests = {

    clone: {
        '': function(test){
            var clone = $object.clone({a:1});
                test.ok( clone.hasOwnProperty('a') );
                test.equal( Object.getPrototypeOf(clone), $object);
                test.strictEqual( Object.getOwnPropertyNames(clone).length, 1);

            clone = $object.clone({a:1}, {});
                test.ok( clone.hasOwnProperty('a') );
                test.equal( Object.getPrototypeOf(clone), $object);
                test.strictEqual( Object.getOwnPropertyNames(clone).length, 1);

            clone = $object.clone();
                test.strictEqual( Object.getOwnPropertyNames(clone).length, 0);
                test.equal( Object.getPrototypeOf(clone), $object);

            test.done();
        },

        call: function(test){
            var $proto = {a: 1};

                var clone = $object.clone.call($proto);
                    test.equal( Object.getPrototypeOf(clone), $proto,
                        'check prototype');

                clone = $object.clone.call($proto, {b:2});
                    test.ok( clone.hasOwnProperty('b') );

                clone = $object.clone.call($proto, {b:2}, {});
                    test.ok( clone.hasOwnProperty('b') );

            test.done();
        },

        constructor: function(test){
            var constructor = $object.clone({constructor: ''}).constructor;
            var c = $object.clone({constructor: ''});
                test.ok(constructor !== c.constructor);
                test.ok(constructor !== $object.clone().constructor);
                test.equal(typeof constructor, 'function');

            test.done();
        }
    },

    create: {

        '': function(test){
            var customConstructorCalled = false;
            var $myType = $object.clone({
                constructor: function(){
                    customConstructorCalled = true;
                }
            });
            var instance = $myType.create({ignored: true});
                test.ok(customConstructorCalled);
                test.ok(typeof instance.ignored == 'undefined');

    //        instance = $object.create();
    //            test.ok( Object.isSealed(instance), 'the created object should be sealed by default');

            test.done();
        },

        'super property should can be modified': function(test){

            var obj = $object.clone({a: 1}).create();
            obj.a = 2;

                test.equal(obj.a, 2);

            test.done();
        }
    },

    describe: function(test){

        function Constructor(){}

        test.deepEqual(
            $object.describe({
                          _p: undefined,
       '(const) _unwritable': 231,
                   property1: 11,
        '(hidden) property2': 22,
      '(writable) property3': 33,
         '(final) property4': 44,
'(final writable) property5': 55,
                      method: Function,
                 constructor: Constructor
            }),{
                         _p: {value: undefined, enumerable:false},
                _unwritable: {value: 231, enumerable:false, writable: false},
                  property1: {value: 11},
                  property2: {value: 22, enumerable:false},
                  property3: {value: 33, writable:true},
                  property4: {value: 44, writable:false, configurable: false},
                  property5: {value: 55, writable:true, configurable: false},
                     method: {value: Function, enumerable:false},
                constructor: {value: Constructor, enumerable:false}
            }
        );

        /// Constructor:

        var proto = {};
        var descriptors = $object.describe.call(proto, {constructor: 'MyCustomName'});

            var constructor = descriptors.constructor.value;
            test.equal(typeof constructor, 'function');
            test.equal(constructor.name, 'MyCustomName');
            test.equal(constructor.typeName, 'MyCustomName');
            test.strictEqual(constructor.prototype, proto);

        var $obj = $object.clone().clone();
        constructor.call($obj, {key: 11});

            test.equal($obj.key, 11);

        /// TODO: test defaultDescriptor

        test.done();
    },

    'can, cant': function(test){

        var $myObj = $object.clone({
            fly: function(){},
            swim: function(a,b,c){}
        });
        var myObj = $myObj.create();
            test.ok(!!   myObj.can('swim').as($myObj) );
            test.ok(!! $object.can.call(myObj, 'fly').like($myObj) );

            test.ok(!    myObj.cant('swim').as($myObj) );
            test.ok(!  $object.cant.call(myObj, 'fly').like($myObj) );

        test.done();
    },

    copy: function(test){
        var myArray = $object.copy(Array);
        myArray[0] = 11;
        myArray[1] = 22;
            test.deepEqual(myArray, [11 ,22]);

            myArray.defineProperties({test: 'T'});
                test.strictEqual(myArray.test, 'T');

        var $collection = $object.clone({items: []});
        var $users = $collection.clone({name: ''});

            // $users full prototype chain:
            //$users -> $collection -> $object -> Object.prototype -> null

            // see prototype chains produced by copy:

            var userCopy = $users.copy();
            //~$users -> $object
                test.equal(Object.getPrototypeOf(userCopy), $object);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.items === undefined);

            userCopy = $users.copy(Array);
            //~$users -> Array.prototype
                test.equal(Object.getPrototypeOf(userCopy), Array.prototype);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.items === undefined);
                test.ok(userCopy.clone === undefined);

            userCopy = $users.copy(Array, Infinity);
            //~$users -> ~$collection -> ~$object -> Array.prototype
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.getPrototype().hasOwnProperty('items'));
                test.ok(userCopy.getPrototype().getPrototype().hasOwnProperty('clone'));
                test.ok(userCopy.getPrototype().getPrototype().getPrototype() === Array.prototype);

            userCopy = $users.copy(Array, Infinity, true);
            //~($users + $collection + $object) -> Array.prototype
                test.equal(Object.getPrototypeOf(userCopy), Array.prototype);
                test.ok(userCopy.hasOwnProperty('name'));
                test.ok(userCopy.hasOwnProperty('items'));
                test.ok(userCopy.hasOwnProperty('clone'));

        //TODO: add tests for deepCopy/deepClone

        test.done();
    },

    deepCopy: function(test){
        var obj = $object.clone({l1: {l2: {l3: null}}});
        var deepCopy = obj.deepCopy();
        test.strictEqual(deepCopy.l1.l2.l3, null);

            obj.l1.l2.l3 = 11;
                test.strictEqual(deepCopy.l1.l2.l3, null);

            deepCopy.l1.l2.l3 = 22;
                test.strictEqual(obj.l1.l2.l3, 11);

        test.done();
    },

    deepClone: function(test){
        var obj = $object.clone({l1: {l2: {l3: null}}});
        var deepClone = obj.deepClone();
            test.strictEqual(deepClone.l1.l2.l3, null);

            obj.l1.l2.l3 = 11;
                test.strictEqual(deepClone.l1.l2.l3, 11);

            deepClone.l1.l2.l3 = 22;
                test.strictEqual(obj.l1.l2.l3, 11);

        test.done();
    },

    '__super__': {
        'callSuper, applySuper': function(test){
            var calls = [];
            var $parent = $object.clone({
                constructor: function(arg){
                    calls.push('collection');
                    this.callSuper('constructor', arg);
                }
            });
            var $child = $parent.clone({
                constructor: function(arg){
                    calls.push('users');
                    this.applySuper(arguments);
                }
            });
            var child = $child.create({setBy$objectConstructor: 11});

                test.deepEqual(calls, ['users','collection']);
                test.equal(child.setBy$objectConstructor, 11);

            test.done();
        },

        'createSuperSafeCallback, __super__': function(test){

            test.expect(3);

            var $parent = $object.clone({
                testSuper: function(){
                    test.strictEqual(this.__super__, $object);
                }
            });
            var $child = $parent.clone({
                constructor: function(){
                    this.applySuper();
                    test.strictEqual(this.__super__, $parent);
                },

                asyncCheck: function(){
                    var callback = this.createSuperSafeCallback(function(){
                        test.strictEqual(this.__super__, $parent);
                        this.applySuper('testSuper');
                    },this);

                    setTimeout(callback, 0);
                }
            });

            var child = $child.create();
            child.asyncCheck();

            setTimeout(function(){
                test.done();
            },0);
        },

        "first call applySuper() on sealed object \
         should doesn't throw an error": function(test){

            var $parent = $object.clone({
                method: function(){}
            });
            var $child = $parent.clone({
                method: function(arg){
                    this.applySuper('method');
                }
            });
            var child = $child.clone();
            child.seal();

                test.doesNotThrow(function(){
                    child.method();
                });

            test.done();
        }
    },

    apply: function(test){
        //methodName, args, withObj, asObj
        var asObj = {defineProperties: function(){
            this.called = true;
            return this;
        }};
        var obj = $object.apply(Array(22,33), 'defineProperties',[{a:11}], asObj);
            test.equal(obj.a, undefined);
            test.ok(obj.called);
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        //methodName, args, withObj
        obj = $object.apply(Array(22,33), 'defineProperties',[{a:11}]);
            test.equal(obj.a,  11);
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        //methodName, withObj
        obj = $object.apply(Array(22,33), 'defineProperties');
            test.equal(obj[0], 22);
            test.equal(Object.getPrototypeOf(obj), Array.prototype);

        test.done();
    },

    concat: function(test){
        var $parent = $object.clone({a: 1});
        var $child  = $parent.clone({b: 2});
        var toMerge = $child .clone({c: 3, _c: 33});

            var obj = $object.clone().concat(toMerge);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  3);
                test.strictEqual(obj.b,  undefined);
                test.strictEqual(obj.a,  undefined);

            obj = $object.clone().concat(toMerge, ['a','_c']);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  undefined);
                test.strictEqual(obj.b,  undefined);
                test.strictEqual(obj.a,  1);

            obj = $object.clone().concat(toMerge, true);
                test.strictEqual(obj._c, 33);
                test.strictEqual(obj.c,  3);
                test.strictEqual(obj.b,  2);
                test.strictEqual(obj.a,  1);

        test.done();
    },

    getPrototypes: function(test){
        var ns = clonejs.$namespace.clone();
            ns.extend('level1',{n:1})
              .extend('level1_1',{n:2})
              .extend('level1_1_1',{n:3});

        var $obj = ns.level1.level1_1.$level1_1_1.create();

            test.deepEqual($obj.getPrototypes(), [{n:1}, {n:2}, {n:3}]);
            test.deepEqual($obj.getPrototypes(undefined, true), [{n:3}, {n:2}, {n:1}]);
            test.deepEqual($obj.getPrototypes(Object.prototype), [Object.prototype, {n:1}, {n:2}, {n:3}]);
            //test.deepEqual($obj.getPrototypes(null), [Object.prototype, Object.prototype, {n:1}, {n:2}, {n:3}]);

        test.done();
    },

    getValues: function(test){
        var obj = $object.clone({en:'1 0', _p:'0 0'}).clone({ownEn:'1 1', _own:'0 1'});
        //                      enumerable,   own
        test.deepEqual(obj.getValues(true,   true).sort(), [ '1 1' ]);
        test.deepEqual(obj.getValues(false, false).sort(), [ '0 0', '0 1', '1 0', '1 1' ]);
        test.deepEqual(obj.getValues(false,  true).sort(), [ '0 1', '1 1' ]);
        test.deepEqual(obj.getValues(true,  false).sort(), [ '1 0', '1 1' ]);

        test.done();
    },

    setValues: function(test){
        var obj = $object.clone({en:'1 0', _p:'0 0'}).clone({ownEn:'1 1', _own:'0 1'}), values;

        values = obj.getValues();
            test.deepEqual(obj, obj.copy(Infinity).setValues(values) );

        values = obj.getValues(true);
            test.deepEqual(obj, obj.copy(Infinity).setValues(values, true) );

        values = obj.getValues(false);
            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false) );

//        values = obj.getValues(true, false);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, true,  false) );

        values = obj.getValues(false, true);
            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false, true) );

//        values = obj.getValues(false, false);
//            test.deepEqual(obj, obj.copy(Infinity).setValues(values, false, false) );

        test.done();
    },

    $namespace: {
        /*

        namespace contents:
            ns = {
                prototype: $ns,
                items: {
                    prototype: $item,
                    subitems: {},
                    $subitem: $subitem,

                    extend: $ns.extend
                },
                $item: $item,

                extend: $ns.extend,
                put: $ns.put
            }

        1) $subitem should be a direct child of $item
        2) items, subitems should be plural

        clone.clone()
        clone.prototype
        */

        extend: function(test){
            var ns1 = clonejs.$namespace.create();
            ns1.extend('collection',          {name: 'collection'})
                   .extend('arrayCollection', {name: 'arrayCollection'});

                _ns_check(ns1, test);

            test.done();
        },

        put: function(test){
            var $collection = $object.clone({constructor: 'Collection'}),
                $arrayCollection = $collection.clone({constructor: 'ArrayCollection'});
            var ns2 = clonejs.$namespace.create();
            ns2.put($arrayCollection);

                _ns_check(ns2, test);

            var ns3 = clonejs.$namespace.create();
            ns3.put('collection.arrayCollection', $arrayCollection);

                _ns_check(ns3, test);

            test.done();
        }
    }
};

function _ns_check(newNS, test){
    test.strictEqual(newNS.prototype, $object);
    test.strictEqual(newNS.extend,    clonejs.$namespace.extend);
    test.strictEqual(newNS.put,       clonejs.$namespace.put);

    test.ok( $object.isPrototypeOf(newNS.$collection) );
    test.equal( newNS.$collection.constructor.typeName, 'Collection');
    test.strictEqual(newNS.collection.prototype, newNS.$collection);
    test.strictEqual(newNS.collection.extend,    clonejs.$namespace.extend);

    test.ok( newNS.$collection.isPrototypeOf(newNS.collection.$arrayCollection) );
    test.equal( newNS.collection.$arrayCollection.constructor.typeName, 'ArrayCollection');
    test.strictEqual(newNS.collection.arrayCollection.prototype, newNS.collection.$arrayCollection);
    test.strictEqual(newNS.collection.arrayCollection.extend,    clonejs.$namespace.extend);
}
<|endoftext|>


<commit_before>"use strict";

// Node.js tests
if (typeof module == "object" && typeof require == "function") {
    var buster = require("buster");
}

var webdriverio = require('webdriverio');
var q = require('q');

var assert = buster.referee.assert;
var expect = buster.referee.expect;
var refute = buster.referee.refute;

//buster.spec.expose(); // Make BDD functions global

var injectEventLogger = function() {

    var DEBUG = false;

    function EventLogger() {
        this.eventNames = ["XDdisconnection", "XDconnection", "XDdevice", "XDroles", "XDsync", "XDserverReady", "XDothersRolesChanged"];
        this.eventCounter = {};

        this.eventNames.forEach((function (event) {
            this.eventCounter[event] = 0;
            XDmvc.on(event, (function (sender) {
                this.eventCounter[event]++;
                if (DEBUG) {
                    console.log(event);
                    console.log(sender);
                    console.log(this.eventCounter);
                }
            }).bind(this))
        }).bind(this));
    }

    window.eventLogger = new EventLogger();
    return 0;
};

var getEventCounter = function() {
    return window.eventLogger.eventCounter;
};

var setupConnectedBrowsers = function() {
    var setup = q.defer();

    var self = this;

    return self.browserA.url(self.baseUrl).then(function () {
        console.log('A: init');
    }).execute(function () {
        return 1 + 2;
    }).then(function(ret) {

        console.log('A: executed script');
        console.log(ret.value);
        expect(ret.value).toBe(3);
    }).execute(injectEventLogger).then(function() {
        console.log('A: injected event logger');
    }).getUrl().then(function(url) {
        return self.browserB.url(url).then(function () {
            console.log('B: init');

            return self.browserA.waitUntil(function() {
                return self.browserA.execute(getEventCounter).then(function(ret) {
                    console.log('A: got eventCounter: ');
                    console.log(ret.value);
                    return ret.value.XDconnection > 0;
                });
            });
        });
    })

};

//var specs = describe("XD-Test-gallery", function() {
buster.testCase("XD-MVC Example Gallery", {

    //before(function() {
    setUp: function () {
        this.baseUrl = "http://me.local:8082/gallery.html";

        // Bind function to this reference
        this.setupConnectedBrowsers = setupConnectedBrowsers.bind(this);

        // Set timeout
        this.timeout = 1000 * 30; // 30s

        // New browser instance with WebdriverIO
        var options = {desiredCapabilities: {browserName: 'chrome'}};
        var clientA = webdriverio.remote(options);
        var clientB = webdriverio.remote(options);

        this.browserA = clientA.init();
        this.browserA
            .windowHandleSize({width: 800, height: 600})
            .windowHandlePosition({x: 0, y: 0});
        this.browserB = clientB.init()
            .windowHandleSize({width: 800, height: 600})
            .windowHandlePosition({x: 800, y: 0});

    },

    //after(function () {
    tearDown: function () {
        // Close browser before completing a test
        this.browserA.end();
        this.browserB.end();
    },

    // it('eventLogger', function() {
    'eventLogger': {
        'should count XDconnection events': function() {
            var self = this;

            return self.setupConnectedBrowsers().then(function() {
                return self.browserA.execute(getEventCounter).then(function(ret) {
                    console.log('A: got eventCounter: ');
                    console.log(ret.value);
                    expect(ret.value.XDconnection).toBe(1);
                });
            });
        }
    },

    //it('should not share cookies across browser sessions', function (done) {
    'should not share cookies across browser sessions': function () {
        var self = this;

        return self.browserA.url(this.baseUrl).then(function () {
            return self.browserB.url(self.baseUrl);
        }).setCookie({name: 'test_cookieA', value: 'A'})
        .getCookie('test_cookieA').then(function (cookie) {

            refute.isNull(cookie);
            assert.equals(cookie.name, 'test_cookieA');
            assert.equals(cookie.value, 'A');

            return self.browserB.setCookie({name: 'test_cookieB', value: 'B'})
            .getCookie('test_cookieB').then(function (cookie) {

                refute.isNull(cookie);
                assert.equals(cookie.name, 'test_cookieB');
                assert.equals(cookie.value, 'B');

            }).getCookie('test_cookieA').then(function (cookie) {
                assert.isNull(cookie);
            });
        });
    },
//});

//it('should not share local storage across browser sessions', function (done) {
    'should not share local storage across browser sessions': function () {
        var self = this;

        var getItem = function(key) {
            console.log('localStorage.getItem ' + key);
            return localStorage.getItem(key);
        };

        var setItem = function(key, value) {
            localStorage.setItem(key, value);
        };

        return self.browserA.url(self.baseUrl).then(function () {
            return self.browserB.url(self.baseUrl);
        }).execute(setItem, 'test_storageA', 'A')
        .execute(getItem, 'test_storageA').then(function (ret) {
            assert.equals(ret.value, 'A');

            return self.browserB.execute(getItem, 'test_storageA').then(function (ret) {
                assert.isNull(ret.value);
            });
        });
    //});
    },

    'should show the selected image on the second device': function () {
    //it('should show the selected image on the second device', function () {

        var self = this;

        var imageUrlA;

        return this.setupConnectedBrowsers().then(function () {
            console.log('setup two connected browsers');
        }).waitForVisible('h2.gallery-overview').then(function () {
            console.log('A: h2.gallery-overview is visible');
        }).click('//*[text()="Bike Tours"]').then(function () {
            console.log('A: clicked Bike Tours');
        }).waitForVisible('#gallery img:nth-of-type(1)').then(function () {
            console.log('A: first image is visible');
        }).click('#gallery img:nth-of-type(1)').then(function () {
            console.log('A: clicked first image in galery');
        }).waitForVisible('#image img').then(function () {
            console.log('A: #image img is visible');
        }).scroll(0, 1000).then(function () {
            console.log('A: scrolled down to the end');
        }).getAttribute('#image img', 'src').then(function (src) {
            imageUrlA = src;
            console.log('A: image src ' + src);
        }).getUrl().then(function (url) {
            return self.browserB.waitForVisible('#image img', 3000).then(function () {
                console.log('B: image found');
            }).getAttribute('#image img', 'src').then(function (src) {
                console.log('A: imageUrlA ' + imageUrlA);
                console.log('B: image src ' + src);

                assert.equals(src, imageUrlA);

                if (src == imageUrlA) {
                    console.log('SUCCESS, images are equal!');
                } else {
                    console.log('ERROR! different images.');
                }
            }).saveScreenshot('./screenshots/browserB.png', function (err, screenshot, response) {
                console.log('B: save screenshot');
                console.log('err: ' + err);
            });
        }).saveScreenshot('./screenshots/browserA.png', function (err, screenshot, response) {
            console.log('A: save screenshot');
            console.log('err: ' + err);
        }).endAll();
    //});
    }
});
<commit_msg>Improve support for multiple devices<commit_after>"use strict";

// Node.js tests
if (typeof module == "object" && typeof require == "function") {
    var buster = require("buster");
}

var webdriverio = require('webdriverio');
var q = require('q');
//q.longStackSupport = true;

var assert = buster.referee.assert;
var expect = buster.referee.expect;
var refute = buster.referee.refute;

//buster.spec.expose(); // Make BDD functions global

var injectEventLogger = function() {

    var DEBUG = false;

    function EventLogger() {
        this.eventNames = ["XDdisconnection", "XDconnection", "XDdevice", "XDroles", "XDsync", "XDserverReady", "XDothersRolesChanged"];
        this.eventCounter = {};

        this.eventNames.forEach((function (event) {
            this.eventCounter[event] = 0;
            XDmvc.on(event, (function (sender) {
                this.eventCounter[event]++;
                if (DEBUG) {
                    console.log(event);
                    console.log(sender);
                    console.log(this.eventCounter);
                }
            }).bind(this))
        }).bind(this));
    }

    window.eventLogger = new EventLogger();
    return 0;
};

var getEventCounter = function() {
    return window.eventLogger.eventCounter;
};

var setupConnectedBrowsers = function() {
    var setup = q.defer();

    var self = this;
    var deviceA = self.devices.select('A');

    return deviceA.url(self.baseUrl).then(function () {
        console.log('A: init');
    }).execute(function () {
        return 1 + 2;
    }).then(function(ret) {

        console.log('A: executed script');
        console.log(ret.value);
        expect(ret.value).toBe(3);
    }).execute(injectEventLogger).then(function() {
        console.log('A: injected event logger');
    }).getUrl().then(function(url) {
        //return self.deviceB.url(url).then(function () {

        var allButA = Object.keys(self.deviceOptions).filter(function(deviceName) {
            return deviceName != 'A';
        });
        return multiAction(self.devices, allButA, function(device) {
            return device.url(url);
        }).then(function() {
            console.log('init urls');

            return deviceA.waitUntil(function() {
                return deviceA.execute(getEventCounter).then(function(ret) {
                    console.log('A: got eventCounter: ');
                    console.log(ret.value);
                    console.log('devices.length: ' + self.devicesCount());
                    return ret.value.XDconnection == self.devicesCount() - 1;
                    //return ret.value.XDconnection == devicesButA.count();
                });
            });
        });

        //var devicesButA = self.devices.select('B');
        ////var devicesButA = self.devices.but('A');
        //return devicesButA.url(url).then(function () {
        //    console.log('but A: init');
        //
        //    return deviceA.waitUntil(function() {
        //        return deviceA.execute(getEventCounter).then(function(ret) {
        //            console.log('A: got eventCounter: ');
        //            console.log(ret.value);
        //            return ret.value.XDconnection > 0;
        //            //return ret.value.XDconnection == devicesButA.count();
        //        });
        //    });
        //});
    })

};

var devicesCount = function() {
    var self = this;
    return Object.keys(self.deviceOptions).length;
};

// Custom function: Do function/callback/promise for multiple browsers, except A

/**
 * Executes callback on devices matching deviceNames.
 * Returns an promise.
 * @param devices
 * @param deviceNames
 * @param callback
 * @returns
 */
function multiAction (devices, deviceNames, callback) {
    var promises = [];
    deviceNames.forEach(function(name) {
        promises.push(callback(devices.select(name)));
    });
    return q.all(promises);
}

//var specs = describe("XD-Test-gallery", function() {
buster.testCase("XD-MVC Example Gallery", {

    //before(function() {
    setUp: function () {
        this.baseUrl = "http://me.local:8082/gallery.html";

        // Bind function to this reference
        this.setupConnectedBrowsers = setupConnectedBrowsers.bind(this);
        this.devicesCount = devicesCount.bind(this);

        // Set timeout
        this.timeout = 1000 * 30; // 30s

        // New browser instance with WebdriverIO

        this.deviceOptions = {
            A: {
                desiredCapabilities: {browserName: 'chrome'}
            },
            B: {
                desiredCapabilities: {browserName: 'chrome'}
            },
            C: {
                desiredCapabilities: {browserName: 'chrome'}
            }
        };
        this.devices = webdriverio.multiremote(this.deviceOptions);
        //attachCustomFunctions(this.devices);

        var self = this;

        return this.devices.init()
            .windowHandleSize({width: 500, height: 600})
            .then(function() {
                self.deviceA = self.devices.select('A');
                self.deviceB = self.devices.select('B');
            });

        //var options = {desiredCapabilities: {browserName: 'chrome'}};
        //var clientA = webdriverio.remote(options);
        //var clientB = webdriverio.remote(options);

        //this.deviceA = this.devices.select('A');
        //this.deviceA
        //    .windowHandleSize({width: 500, height: 600});
        //    .windowHandlePosition({x: 0, y: 0});
        //this.deviceB = this.devices.select('B');
        //this.deviceB
        //    .windowHandleSize({width: 500, height: 600})
        //    .windowHandlePosition({x: 500, y: 0});
        //this.deviceC = this.devices.select('C');
        //this.deviceC
        //    .windowHandleSize({width: 500, height: 600})
        //    .windowHandlePosition({x: 1000, y: 0});

    },

    //after(function () {
    tearDown: function () {
        // Close browser before completing a test
        return this.devices.end();
        //this.deviceB.end();
    },

    // it('eventLogger', function() {
    'eventLogger': {
        'should count XDconnection events': function() {
            var self = this;

            return self.setupConnectedBrowsers().then(function() {
                return self.deviceA.execute(getEventCounter).then(function(ret) {
                    console.log('A: got eventCounter: ');
                    console.log(ret.value);
                    expect(ret.value.XDconnection).toBe(self.devicesCount() - 1);
                });
            });
        }
    },

    //it('should not share cookies across browser sessions', function (done) {
    'should not share cookies across browser sessions': function () {
        var self = this;

        return self.deviceA.url(this.baseUrl).then(function () {
            return self.deviceB.url(self.baseUrl);
        }).setCookie({name: 'test_cookieA', value: 'A'})
        .getCookie('test_cookieA').then(function (cookie) {

            refute.isNull(cookie);
            assert.equals(cookie.name, 'test_cookieA');
            assert.equals(cookie.value, 'A');

            return self.deviceB.setCookie({name: 'test_cookieB', value: 'B'})
            .getCookie('test_cookieB').then(function (cookie) {

                refute.isNull(cookie);
                assert.equals(cookie.name, 'test_cookieB');
                assert.equals(cookie.value, 'B');

            }).getCookie('test_cookieA').then(function (cookie) {
                assert.isNull(cookie);
            });
        });
    },
//});

//it('should not share local storage across browser sessions', function (done) {
    'should not share local storage across browser sessions': function () {
        var self = this;

        var getItem = function(key) {
            console.log('localStorage.getItem ' + key);
            return localStorage.getItem(key);
        };

        var setItem = function(key, value) {
            localStorage.setItem(key, value);
        };

        return self.deviceA.url(self.baseUrl).then(function () {
            return self.deviceB.url(self.baseUrl);
        }).execute(setItem, 'test_storageA', 'A')
        .execute(getItem, 'test_storageA').then(function (ret) {
            assert.equals(ret.value, 'A');

            return self.deviceB.execute(getItem, 'test_storageA').then(function (ret) {
                assert.isNull(ret.value);
            });
        });
    //});
    },

    'should show the selected image on the other devices': function () {
    //it('should show the selected image on the second device', function () {

        var self = this;

        var imageUrlA;

        return this.setupConnectedBrowsers().then(function () {
            console.log('setup two connected browsers');
        }).waitForVisible('h2.gallery-overview').then(function () {
            console.log('A: h2.gallery-overview is visible');
        }).click('//*[text()="Bike Tours"]').then(function () {
            console.log('A: clicked Bike Tours');
        }).waitForVisible('#gallery img:nth-of-type(1)').then(function () {
            console.log('A: first image is visible');
        }).click('#gallery img:nth-of-type(1)').then(function () {
            console.log('A: clicked first image in galery');
        }).waitForVisible('#image img').then(function () {
            console.log('A: #image img is visible');
        }).scroll(0, 1000).then(function () {
            console.log('A: scrolled down to the end');
        }).getAttribute('#image img', 'src').then(function (src) {
            imageUrlA = src;
            console.log('A: image src ' + src);
        }).getUrl().then(function (url) {
            return self.deviceB.waitForVisible('#image img', 3000).then(function () {
                console.log('B: image found');
            }).getAttribute('#image img', 'src').then(function (src) {
                console.log('A: imageUrlA ' + imageUrlA);
                console.log('B: image src ' + src);

                assert.equals(src, imageUrlA);

                if (src == imageUrlA) {
                    console.log('SUCCESS, images are equal!');
                } else {
                    console.log('ERROR! different images.');
                }
            }).saveScreenshot('./screenshots/deviceB.png', function (err, screenshot, response) {
                console.log('B: save screenshot');
                console.log('err: ' + err);
            });
        }).saveScreenshot('./screenshots/deviceA.png', function (err, screenshot, response) {
            console.log('A: save screenshot');
            console.log('err: ' + err);
        }).endAll();
    //});
    }
});
<|endoftext|>


<commit_before>function test() {
  return "test";
}
<commit_msg>test with es6<commit_after>function test() {
  return ["a", "b"].map((val) => {
    return `${val}-`;
  });
}
<|endoftext|>