<commit_before>/**
 * Created by yevhen.zavhorodnii on 20/12/2016.
 */

function LabeledRectangle(cfg) {
    this.id  = cfg.id;
    this.label = cfg.label;
    this.position = cfg.position;
    this.size = cfg.size;
    this.backgroundColor = cfg.backgroundColor ? cfg.backgroundColor : "#FF0000";
    this.borderColor = cfg.borderColor ? cfg.borderColor : "#000000";
    this.fontColor = cfg.fontColor ? cfg.fontColor : "#000000";

    this.draw = function (ctx, deltaX, deltaY) {
        debugger;
        if (!deltaX) {
            deltaX = 0;
        }
        if (!deltaY) {
            deltaY = 0;
        }
        if (ctx) {
            var rectanglePositionX = this.position.x + deltaX;
            var rectanglePositionY = this.position.y + deltaY;
            ctx.fillStyle = this.backgroundColor;
            ctx.fillRect(rectanglePositionX, rectanglePositionY, this.size.width, this.size.height);

            var fontPosition = new Position({
                    x: rectanglePositionX + this.size.width / 2,
                    y: rectanglePositionY + this.size.height / 2
                });
            ctx.fillStyle = this.fontColor;
            ctx.fillText(this.label, fontPosition.x, fontPosition.y);
        }
        else {
            throw UserException("context is undefined for draw labeled rectangle");
        }
    }
}
<commit_msg>Remove debugger statements<commit_after>/**
 * Created by yevhen.zavhorodnii on 20/12/2016.
 */

function LabeledRectangle(cfg) {
    this.id  = cfg.id;
    this.label = cfg.label;
    this.position = cfg.position;
    this.size = cfg.size;
    this.backgroundColor = cfg.backgroundColor ? cfg.backgroundColor : "#FF0000";
    this.borderColor = cfg.borderColor ? cfg.borderColor : "#000000";
    this.fontColor = cfg.fontColor ? cfg.fontColor : "#000000";

    this.draw = function (ctx, deltaX, deltaY) {
        if (!deltaX) {
            deltaX = 0;
        }
        if (!deltaY) {
            deltaY = 0;
        }
        if (ctx) {
            var rectanglePositionX = this.position.x + deltaX;
            var rectanglePositionY = this.position.y + deltaY;
            ctx.fillStyle = this.backgroundColor;
            ctx.fillRect(rectanglePositionX, rectanglePositionY, this.size.width, this.size.height);

            var fontPosition = new Position({
                    x: rectanglePositionX + this.size.width / 2,
                    y: rectanglePositionY + this.size.height / 2
                });
            ctx.fillStyle = this.fontColor;
            ctx.fillText(this.label, fontPosition.x, fontPosition.y);
        }
        else {
            throw UserException("context is undefined for draw labeled rectangle");
        }
    }
}
<|endoftext|>


<commit_before>;(function() {
  'use strict';

  var ecstatic = require('ecstatic'),
      http = require('http'),
      path = require('path'),
      request = require('request'),
      SauceTunnel = require('sauce-tunnel'),
      url = require('url');

  var attempts = -1,
      prevLine = '';

  var port = 8081,
      username = process.env.SAUCE_USERNAME,
      accessKey = process.env.SAUCE_ACCESS_KEY,
      tunnelId = 'lodash_' + process.env.TRAVIS_JOB_NUMBER;

  var runnerPathname = (function() {
    var args = process.argv;
    return args.length > 2
      ? '/' + args[args.length - 1].replace(/^\W+/, '')
      : '/test/index.html';
  }());

  var platforms = [
    ['Windows 7', 'chrome', ''],
    ['Windows 7', 'firefox', '25'],
    ['Windows 7', 'firefox', '20'],
    ['Windows 7', 'firefox', '10'],
    ['Windows 7', 'firefox', '6'],
    ['Windows 7', 'firefox', '4'],
    ['Windows 7', 'firefox', '3'],
    ['WIN8.1', 'internet explorer', '11'],
    ['Windows 7', 'internet explorer', '10'],
    ['Windows 7', 'internet explorer', '9'],
    ['Windows 7', 'internet explorer', '8'],
    ['Windows XP', 'internet explorer', '7'],
    ['Windows XP', 'internet explorer', '6'],
    ['OS X 10.8', 'safari', '6'],
    ['Windows 7', 'safari', '5']
  ];

  if (url.parse(runnerPathname, true).query.compat) {
    platforms = [
      ['WIN8.1', 'internet explorer', '11'],
      ['Windows 7', 'internet explorer', '10'],
      ['Windows 7', 'internet explorer', '9'],
      ['Windows 7', 'internet explorer', '8']
    ];
  }

  // create a web server for the local dir
  var mount = ecstatic({
    root: path.resolve(__dirname, '..'),
    cache: false
  });

  http.createServer(function(req, res) {
    var parsedUrl = url.parse(req.url, true);
    var compat = parsedUrl.query.compat;
    if (compat) {
      // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx
      res.setHeader('X-UA-Compatible', 'IE=' + compat);
    }
    mount(req, res);
  }).listen(port);

  // set up sauce connect so we can use this server from saucelabs
  var tunnelTimeout = 10000,
      tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout);

  console.log('Opening sauce connect tunnel...');

  tunnel.start(function(success) {
    if (success) {
      console.log('Sauce connect tunnel opened');
      runTests();
    } else {
      // fail without an exit code for pull requests
      console.error('Failed to open sauce connect tunnel');
      process.exit(0);
    }
  });

  /*--------------------------------------------------------------------------*/

  function logInline(text) {
    var blankLine = repeat(' ', prevLine.length);
    if (text.length > 40) {
      text = text.slice(0, 37) + '...';
    }
    prevLine = text;
    process.stdout.write(text + blankLine.slice(text.length) + '\r');
  }

  function repeat(text, times) {
    return Array(times + 1).join(text);
  }

  /*--------------------------------------------------------------------------*/

  function runTests() {
    var testDefinition = {
      'framework': 'qunit',
      'platforms': platforms,
      'tunnel': 'tunnel-identifier:' + tunnelId,
      'url': 'http://localhost:' + port + runnerPathname
    };

    console.log('Starting saucelabs tests: ' + JSON.stringify(testDefinition));

    request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', {
      'auth': { 'user': username, 'pass': accessKey },
      'json': testDefinition
    }, function(error, response, body) {
      if (response.statusCode == 200) {
        waitForTestCompletion(body);
      } else {
        console.error('Failed to submit test to Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body));
        process.exit(3);
      }
    });
  }

  function waitForTestCompletion(testIdentifier) {
    request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests/status', {
      'auth': { 'user': username, 'pass': accessKey },
      'json': testIdentifier
    }, function(error, response, body) {
        if (response.statusCode == 200) {
          if (body.completed) {
            logInline('');
            handleTestResults(body['js tests']);
          }
          else {
            logInline('Please wait' + repeat('.', (++attempts % 3) + 1));
            setTimeout(function() {
              waitForTestCompletion(testIdentifier);
            }, 5000);
          }
        } else {
          logInline('');
          console.error('Failed to check test status on Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body));
          process.exit(4);
        }
    });
  }

  function handleTestResults(results) {
    var failingTests = results.filter(function(test) {
      var result = test.result;
      return !result || result.failed || /\berror\b/i.test(result.message);
    });

    var failingPlatforms = failingTests.map(function(test) {
      return test.platform;
    });

    if (!failingTests.length) {
      console.log('Tests passed');
    }
    else {
      console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms));

      failingTests.forEach(function(test) {
        var details =  'See ' + test.url + ' for details.',
            platform = JSON.stringify(test.platform),
            result = test.result;

        if (result && result.failed) {
          console.error(result.failed + ' failures on ' + platform + '. ' + details);
        } else {
          console.error('Testing on ' + platform + ' failed; no results available. ' + details);
        }
      });
    }

    console.log('Shutting down sauce connect tunnel...');

    tunnel.stop(function() {
      process.exit(failingTests.length ? 1 : 0);
    });
  }
}());
<commit_msg>Auto create platforms list based on test url params.<commit_after>;(function() {
  'use strict';

  var ecstatic = require('ecstatic'),
      http = require('http'),
      path = require('path'),
      request = require('request'),
      SauceTunnel = require('sauce-tunnel'),
      url = require('url');

  var attempts = -1,
      prevLine = '';

  var port = 8081,
      username = process.env.SAUCE_USERNAME,
      accessKey = process.env.SAUCE_ACCESS_KEY,
      tunnelId = 'lodash_' + process.env.TRAVIS_JOB_NUMBER;

  var runnerPathname = (function() {
    var args = process.argv;
    return args.length > 2
      ? '/' + args[args.length - 1].replace(/^\W+/, '')
      : '/test/index.html';
  }());

  var runnerQuery = url.parse(runnerPathname, true).query,
      isMobile = /\bmobile\b/i.test(runnerQuery.build),
      isModern = /\bmodern\b/i.test(runnerQuery.build);

  var platforms = [
    ['Windows 7', 'chrome', ''],
    ['Windows 7', 'firefox', '25'],
    ['Windows 7', 'firefox', '20'],
    ['Windows 7', 'firefox', '10'],
    ['Windows 7', 'firefox', '6'],
    ['Windows 7', 'firefox', '4'],
    ['Windows 7', 'firefox', '3'],
    ['WIN8.1', 'internet explorer', '11'],
    ['Windows 7', 'internet explorer', '10'],
    ['Windows 7', 'internet explorer', '9'],
    ['Windows 7', 'internet explorer', '8'],
    ['Windows XP', 'internet explorer', '7'],
    ['Windows XP', 'internet explorer', '6'],
    ['OS X 10.8', 'safari', '6'],
    ['Windows 7', 'safari', '5']
  ];

  // test IE compat mode
  if (runnerQuery.compat) {
    platforms = [
      ['WIN8.1', 'internet explorer', '11'],
      ['Windows 7', 'internet explorer', '10'],
      ['Windows 7', 'internet explorer', '9'],
      ['Windows 7', 'internet explorer', '8']
    ];
  }
  // test mobile & modern browsers
  if (isMobile || isModern) {
    platforms = platforms.filter(function(platform) {
      var browser = platform[1],
          version = +platform[2];

      switch (browser) {
        case 'firefox': return version >= 10;
        case 'internet explorer': return version >= 9;
        case 'safari': return version >= (isMobile ? 5 : 6);
      }
      return true
    });
  }

  // create a web server for the local dir
  var mount = ecstatic({
    root: path.resolve(__dirname, '..'),
    cache: false
  });

  http.createServer(function(req, res) {
    var parsedUrl = url.parse(req.url, true);
    var compat = parsedUrl.query.compat;
    if (compat) {
      // see http://msdn.microsoft.com/en-us/library/ff955275(v=vs.85).aspx
      res.setHeader('X-UA-Compatible', 'IE=' + compat);
    }
    mount(req, res);
  }).listen(port);

  // set up sauce connect so we can use this server from saucelabs
  var tunnelTimeout = 10000,
      tunnel = new SauceTunnel(username, accessKey, tunnelId, true, tunnelTimeout);

  console.log('Opening sauce connect tunnel...');

  tunnel.start(function(success) {
    if (success) {
      console.log('Sauce connect tunnel opened');
      runTests();
    } else {
      // fail without an exit code for pull requests
      console.error('Failed to open sauce connect tunnel');
      process.exit(0);
    }
  });

  /*--------------------------------------------------------------------------*/

  function logInline(text) {
    var blankLine = repeat(' ', prevLine.length);
    if (text.length > 40) {
      text = text.slice(0, 37) + '...';
    }
    prevLine = text;
    process.stdout.write(text + blankLine.slice(text.length) + '\r');
  }

  function repeat(text, times) {
    return Array(times + 1).join(text);
  }

  /*--------------------------------------------------------------------------*/

  function runTests() {
    var testDefinition = {
      'framework': 'qunit',
      'platforms': platforms,
      'tunnel': 'tunnel-identifier:' + tunnelId,
      'url': 'http://localhost:' + port + runnerPathname
    };

    console.log('Starting saucelabs tests: ' + JSON.stringify(testDefinition));

    request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests', {
      'auth': { 'user': username, 'pass': accessKey },
      'json': testDefinition
    }, function(error, response, body) {
      if (response.statusCode == 200) {
        waitForTestCompletion(body);
      } else {
        console.error('Failed to submit test to Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body));
        process.exit(3);
      }
    });
  }

  function waitForTestCompletion(testIdentifier) {
    request.post('https://saucelabs.com/rest/v1/' + username + '/js-tests/status', {
      'auth': { 'user': username, 'pass': accessKey },
      'json': testIdentifier
    }, function(error, response, body) {
        if (response.statusCode == 200) {
          if (body.completed) {
            logInline('');
            handleTestResults(body['js tests']);
          }
          else {
            logInline('Please wait' + repeat('.', (++attempts % 3) + 1));
            setTimeout(function() {
              waitForTestCompletion(testIdentifier);
            }, 5000);
          }
        } else {
          logInline('');
          console.error('Failed to check test status on Sauce Labs; status ' + response.statusCode + ', body:\n' + JSON.stringify(body));
          process.exit(4);
        }
    });
  }

  function handleTestResults(results) {
    var failingTests = results.filter(function(test) {
      var result = test.result;
      return !result || result.failed || /\berror\b/i.test(result.message);
    });

    var failingPlatforms = failingTests.map(function(test) {
      return test.platform;
    });

    if (!failingTests.length) {
      console.log('Tests passed');
    }
    else {
      console.error('Tests failed on platforms: ' + JSON.stringify(failingPlatforms));

      failingTests.forEach(function(test) {
        var details =  'See ' + test.url + ' for details.',
            platform = JSON.stringify(test.platform),
            result = test.result;

        if (result && result.failed) {
          console.error(result.failed + ' failures on ' + platform + '. ' + details);
        } else {
          console.error('Testing on ' + platform + ' failed; no results available. ' + details);
        }
      });
    }

    console.log('Shutting down sauce connect tunnel...');

    tunnel.stop(function() {
      process.exit(failingTests.length ? 1 : 0);
    });
  }
}());
<|endoftext|>


<commit_before>/*eslint-env node*/

var m = require("mithril");
var THREE = require("three");

module.exports = {
    rX: 0,
    rZ: 0,
    mD: false
};

module.exports.view = function(args) {
    return m(".canvas-wapper", {
        oncreate: function(vnode) {
            var w = vnode.dom.clientWidth;
            var h = vnode.dom.clientHeight;
            var ref = args.attrs.ref;

            var scene = new THREE.Scene();
            ref.on("value", function(res) {
                while (scene.children.length > 0) {
                    scene.remove(scene.children[0]);
                }
                var model = res.val();
                var material = new THREE.LineBasicMaterial();
                Object.values(model.lines).forEach(function(line) {
                    var n1 = model.nodes[line.n1];
                    var n2 = model.nodes[line.n2];
                    var geometry = new THREE.Geometry();
                    geometry.vertices.push(new THREE.Vector3(n1.x, n1.y, n1.z));
                    geometry.vertices.push(new THREE.Vector3(n2.x, n2.y, n2.z));
                    var lineObject = new THREE.Line(geometry, material);
                    scene.add(lineObject);
                });
                var material = new THREE.PointsMaterial({color: 0xff0000});
                Object.values(model.nodes).forEach(function(node) {
                    var geometry = new THREE.Geometry();
                    geometry.vertices.push(new THREE.Vector3(node.x, node.y, node.z));
                    var points = new THREE.Points(geometry, material);
                    scene.add(points);
                });
            });

            var renderer = new THREE.WebGLRenderer();
            renderer.setSize( w, h );
            vnode.dom.appendChild( renderer.domElement );

            var camera = new THREE.PerspectiveCamera( 75, w / h, 0.1, 1000 );
            camera.position.y = -10;
            camera.lookAt(new THREE.Vector3(0, 0, 0));

            function render() {
            	requestAnimationFrame( render );
            	scene.rotation.x = args.state.rX;
				scene.rotation.z = args.state.rZ;
            	renderer.render( scene, camera );
            }
            render();
        },
        onmousemove: function(e) {
            if (args.state.mD) {
                args.state.rZ += e.movementX * 0.01;
                args.state.rX += e.movementY * 0.01;
            }
        },
        onmousedown: function(e) {
            args.state.mD = true;
        },
        onmouseup: function(e) {
            args.state.mD = false;
        }
    });
};<commit_msg>変数"material"を二重に定義していました。<commit_after>/*eslint-env node*/

var m = require("mithril");
var THREE = require("three");

module.exports = {
    rX: 0,
    rZ: 0,
    mD: false
};

module.exports.view = function(args) {
    return m(".canvas-wapper", {
        oncreate: function(vnode) {
            var w = vnode.dom.clientWidth;
            var h = vnode.dom.clientHeight;
            var ref = args.attrs.ref;

            var scene = new THREE.Scene();
            ref.on("value", function(res) {
                while (scene.children.length > 0) {
                    scene.remove(scene.children[0]);
                }
                var model = res.val();
                var material = new THREE.LineBasicMaterial();
                Object.values(model.lines).forEach(function(line) {
                    var n1 = model.nodes[line.n1];
                    var n2 = model.nodes[line.n2];
                    var geometry = new THREE.Geometry();
                    geometry.vertices.push(new THREE.Vector3(n1.x, n1.y, n1.z));
                    geometry.vertices.push(new THREE.Vector3(n2.x, n2.y, n2.z));
                    var lineObject = new THREE.Line(geometry, material);
                    scene.add(lineObject);
                });
                material = new THREE.PointsMaterial({color: 0xff0000});
                Object.values(model.nodes).forEach(function(node) {
                    var geometry = new THREE.Geometry();
                    geometry.vertices.push(new THREE.Vector3(node.x, node.y, node.z));
                    var points = new THREE.Points(geometry, material);
                    scene.add(points);
                });
            });

            var renderer = new THREE.WebGLRenderer();
            renderer.setSize( w, h );
            vnode.dom.appendChild( renderer.domElement );

            var camera = new THREE.PerspectiveCamera( 75, w / h, 0.1, 1000 );
            camera.position.y = -10;
            camera.lookAt(new THREE.Vector3(0, 0, 0));

            function render() {
            	requestAnimationFrame( render );
            	scene.rotation.x = args.state.rX;
				scene.rotation.z = args.state.rZ;
            	renderer.render( scene, camera );
            }
            render();
        },
        onmousemove: function(e) {
            if (args.state.mD) {
                args.state.rZ += e.movementX * 0.01;
                args.state.rX += e.movementY * 0.01;
            }
        },
        onmousedown: function(e) {
            args.state.mD = true;
        },
        onmouseup: function(e) {
            args.state.mD = false;
        }
    });
};
<|endoftext|>


<commit_before>(function()
{
  View = function(id, name, container_class)
  {
    /* a quick hack */

    var self = this;

    var __frame_index = -1;

    var __console_output = null;
    var __console_input = null;
    var __prefix = null;

    var handleEval = function(xml, runtime_id)
    {
      var value_type = xml.getNodeData('data-type');
      var status = xml.getNodeData('status');
      if( status == 'completed' )
      {
        var return_value = xml.getElementsByTagName('string')[0];
        if(return_value)
        {
          __console_output.render(['pre', return_value.firstChild.nodeValue]);
          var container = __console_output.parentNode.parentNode;
          container.scrollTop = container.scrollHeight;
        }
        else if (return_value = xml.getElementsByTagName('object-id')[0])
        {
          var object_id = return_value.textContent;
          var object_ref_name = "$" + object_id;
          var tag = tagManager.setCB(null, handleEval, [runtime_id] );
          var script_string  = "return " + object_ref_name + ".toString()";
          services['ecmascript-debugger'].eval(
            tag, runtime_id, '', '', "<![CDATA["+script_string+"]]>", [object_ref_name, object_id]);
        }
      }
      else
      {
        var error_id = xml.getNodeData('object-id');
        if( error_id )
        {
          var tag = tagManager.setCB(null, handleError);
          services['ecmascript-debugger'].examineObjects(tag, runtime_id, error_id);
        }
      }

    }

    var handleError = function(xml)
    {
      var return_value = xml.getElementsByTagName('string')[0];
      if(return_value)
      {
        __console_output.render(['pre', return_value.firstChild.nodeValue]);
        var container = __console_output.parentNode.parentNode;
        container.scrollTop = container.scrollHeight;
      }
    }

    var markup = "\

\

\

\
          >>> \

<textarea handler='commandline' rows='1' title='hold shift to add a new line'></textarea>
\

\

";

    var templates = {};

    templates.consoleInput = function(entry)
    {
      var lines_count = entry.msg.split(/\r?\n/).length;
      var line_head = '>>>';
      while( --lines_count > 1 )
      {
        line_head += '\n...';
      }
      return [['div', line_head], ['pre', entry.msg]];
    }

    eventHandlers.click['console-focus-input'] = function(event, ele)
    {
      ele.getElementsByTagName('textarea')[0].focus();
    }

    var submit = function(input)
    {
      var
      rt_id = runtimes.getSelectedRuntimeId(),
      frame_id = '',
      thread_id = '';

      if(rt_id)
      {
        if( __frame_index > -1 )
        {
          frame_id = __frame_index;
          thread_id = stop_at.getThreadId();
        }
        var tag = tagManager.setCB(null, handleEval, [rt_id] );
        var script_string  = submit_buffer.join('');
        services['ecmascript-debugger'].eval(tag, rt_id, thread_id, frame_id, "<![CDATA["+script_string+"]]>");
        submit_buffer = [];
      }
      else
      {
        alert('select a runtime');
      }
    }

    var submit_buffer = [];
    var line_buffer = [];
    var line_buffer_cursor = 0;

    var line_buffer_push = function(line)
    {
      line_buffer[line_buffer.length] = line.replace(/\r\n/g, "");
      if( line_buffer.length > 100 )
      {
        line_buffer = line_buffer.slice(line_buffer.length - 100);
      }
      line_buffer_cursor = line_buffer.length;
    }

    eventHandlers.keyup['commandline'] = function(event)
    {
      if(event.keyCode == 38 || event.keyCode == 40)
      {

        line_buffer_cursor += event.keyCode == 38 ? -1 : 1;
        line_buffer_cursor =
          line_buffer_cursor < 0 ? line_buffer.length-1 : line_buffer_cursor > line_buffer.length-1 ? 0 : line_buffer_cursor;
        event.target.value = (line_buffer.length ? line_buffer[line_buffer_cursor] : '').replace(/\r\n/g, '');
        event.preventDefault();
        return;
      }
      const CRLF = "\r\n";
      var value = event.target.value;
      var lastCRLFIndex = value.lastIndexOf(CRLF);
      if(lastCRLFIndex != -1)
      {
        if ( value.length -2 != lastCRLFIndex )
        {
          value = value.slice(0, lastCRLFIndex) + value.slice(lastCRLFIndex + 2) + CRLF;
        }
        __console_output.render(
          ['div', ( submit_buffer.length ? "... " : ">>> " ) + value, 'class', 'log-entry']);
        line_buffer_push( submit_buffer[submit_buffer.length] = value );
        if(!event.shiftKey)
        {
          submit();
        }
        __prefix.textContent = submit_buffer.length ? "... " : ">>> ";
        event.target.value = '';
      }

    }

    this.createView = function(container)
    {
      container.innerHTML = markup;
      container.scrollTop = container.scrollHeight;
      __console_output = container.getElementsByTagName('div')[1];
      __console_input = container.getElementsByTagName('div')[2];
      __prefix = __console_input.getElementsByTagName('span')[0];
    }

    this.ondestroy = function()
    {
      __console_output = null;
      __console_input = null;
      __prefix = null;
    }

    var onFrameSelected = function(msg)
    {
      __frame_index = msg.frame_index;
    }

    messages.addListener('frame-selected', onFrameSelected);

    this.init(id, name, container_class);

  }

  View.prototype = ViewBase;
  new View('command_line', ui_strings.VIEW_LABEL_COMMAND_LINE, 'scroll');
})()<commit_msg>fix to handle empty string properly<commit_after>(function()
{
  View = function(id, name, container_class)
  {
    /* a quick hack */

    var self = this;

    var __frame_index = -1;

    var __console_output = null;
    var __console_input = null;
    var __prefix = null;

    var handleEval = function(xml, runtime_id)
    {
      var value_type = xml.getNodeData('data-type');
      var status = xml.getNodeData('status');
      if( status == 'completed' )
      {
        var return_value = xml.getElementsByTagName('string')[0];
        if(return_value)
        {
          __console_output.render(['pre', return_value.firstChild && return_value.firstChild.nodeValue || '']);
          var container = __console_output.parentNode.parentNode;
          container.scrollTop = container.scrollHeight;
        }
        else if (return_value = xml.getElementsByTagName('object-id')[0])
        {
          var object_id = return_value.textContent;
          var object_ref_name = "$" + object_id;
          var tag = tagManager.setCB(null, handleEval, [runtime_id] );
          var script_string  = "return " + object_ref_name + ".toString()";
          services['ecmascript-debugger'].eval(
            tag, runtime_id, '', '', "<![CDATA["+script_string+"]]>", [object_ref_name, object_id]);
        }
      }
      else
      {
        var error_id = xml.getNodeData('object-id');
        if( error_id )
        {
          var tag = tagManager.setCB(null, handleError);
          services['ecmascript-debugger'].examineObjects(tag, runtime_id, error_id);
        }
      }

    }

    var handleError = function(xml)
    {
      var return_value = xml.getElementsByTagName('string')[0];
      if(return_value)
      {
        __console_output.render(['pre', return_value.firstChild.nodeValue]);
        var container = __console_output.parentNode.parentNode;
        container.scrollTop = container.scrollHeight;
      }
    }

    var markup = "\

\

\

\
          >>> \

<textarea handler='commandline' rows='1' title='hold shift to add a new line'></textarea>
\

\

";

    var templates = {};

    templates.consoleInput = function(entry)
    {
      var lines_count = entry.msg.split(/\r?\n/).length;
      var line_head = '>>>';
      while( --lines_count > 1 )
      {
        line_head += '\n...';
      }
      return [['div', line_head], ['pre', entry.msg]];
    }

    eventHandlers.click['console-focus-input'] = function(event, ele)
    {
      ele.getElementsByTagName('textarea')[0].focus();
    }

    var submit = function(input)
    {
      var
      rt_id = runtimes.getSelectedRuntimeId(),
      frame_id = '',
      thread_id = '';

      if(rt_id)
      {
        if( __frame_index > -1 )
        {
          frame_id = __frame_index;
          thread_id = stop_at.getThreadId();
        }
        var tag = tagManager.setCB(null, handleEval, [rt_id] );
        var script_string  = submit_buffer.join('');
        services['ecmascript-debugger'].eval(tag, rt_id, thread_id, frame_id, "<![CDATA["+script_string+"]]>");
        submit_buffer = [];
      }
      else
      {
        alert('select a runtime');
      }
    }

    var submit_buffer = [];
    var line_buffer = [];
    var line_buffer_cursor = 0;

    var line_buffer_push = function(line)
    {
      line_buffer[line_buffer.length] = line.replace(/\r\n/g, "");
      if( line_buffer.length > 100 )
      {
        line_buffer = line_buffer.slice(line_buffer.length - 100);
      }
      line_buffer_cursor = line_buffer.length;
    }

    eventHandlers.keyup['commandline'] = function(event)
    {
      if(event.keyCode == 38 || event.keyCode == 40)
      {

        line_buffer_cursor += event.keyCode == 38 ? -1 : 1;
        line_buffer_cursor =
          line_buffer_cursor < 0 ? line_buffer.length-1 : line_buffer_cursor > line_buffer.length-1 ? 0 : line_buffer_cursor;
        event.target.value = (line_buffer.length ? line_buffer[line_buffer_cursor] : '').replace(/\r\n/g, '');
        event.preventDefault();
        return;
      }
      const CRLF = "\r\n";
      var value = event.target.value;
      var lastCRLFIndex = value.lastIndexOf(CRLF);
      if(lastCRLFIndex != -1)
      {
        if ( value.length -2 != lastCRLFIndex )
        {
          value = value.slice(0, lastCRLFIndex) + value.slice(lastCRLFIndex + 2) + CRLF;
        }
        __console_output.render(
          ['div', ( submit_buffer.length ? "... " : ">>> " ) + value, 'class', 'log-entry']);
        line_buffer_push( submit_buffer[submit_buffer.length] = value );
        if(!event.shiftKey)
        {
          submit();
        }
        __prefix.textContent = submit_buffer.length ? "... " : ">>> ";
        event.target.value = '';
      }

    }

    this.createView = function(container)
    {
      container.innerHTML = markup;
      container.scrollTop = container.scrollHeight;
      __console_output = container.getElementsByTagName('div')[1];
      __console_input = container.getElementsByTagName('div')[2];
      __prefix = __console_input.getElementsByTagName('span')[0];
    }

    this.ondestroy = function()
    {
      __console_output = null;
      __console_input = null;
      __prefix = null;
    }

    var onFrameSelected = function(msg)
    {
      __frame_index = msg.frame_index;
    }

    messages.addListener('frame-selected', onFrameSelected);

    this.init(id, name, container_class);

  }

  View.prototype = ViewBase;
  new View('command_line', ui_strings.VIEW_LABEL_COMMAND_LINE, 'scroll');
})()<|endoftext|>


<commit_before>
var http = require('http').Server;
var io = require('..');
var ioc = require('socket.io-client');
var request = require('supertest');
var expect = require('expect.js');

// creates a socket.io client for the given server
function client(srv, nsp, opts){
  if ('object' == typeof nsp) {
    opts = nsp;
    nsp = null;
  }
  var addr = srv.address();
  if (!addr) addr = srv.listen().address();
  var url = 'ws://' + addr.address + ':' + addr.port + (nsp || '');
  return ioc(url, opts);
}

describe('socket.io', function(){
  describe('server attachment', function(){
    describe('http.Server', function(){
      it('should serve static files', function(done){
        var srv = http();
        io(srv);
        request(srv)
        .get('/socket.io/socket.io.js')
        .buffer(true)
        .end(function(err, res){
          if (err) return done(err);
          var ctype = res.headers['content-type'];
          expect(ctype).to.be('application/javascript');
          expect(res.text).to.match(/engine\.io/);
          expect(res.status).to.be(200);
          done();
        });
      });

      it('should not serve static files', function(done){
        var srv = http();
        io(srv, { static: false });
        request(srv)
        .get('/socket.io/socket.io.js')
        .expect(400, done);
      });

      it('should work with #attach', function(done){
        var srv = http(function(req, res){
          res.writeHead(404);
          res.end();
        });
        var sockets = io();
        sockets.attach(srv);
        request(srv)
        .get('/socket.io/socket.io.js')
        .end(function(err, res){
          if (err) return done(err);
          expect(res.status).to.be(200);
          done();
        });
      });
    });

    describe('port', function(done){
      it('should be bound', function(done){
        var sockets = io(54010);
        request('http://localhost:54010')
        .get('/socket.io/socket.io.js')
        .expect(200, done);
      });
    });
  });

  describe('namespaces', function(){
    var Socket = require('../lib/socket');
    var Namespace = require('../lib/namespace');

    describe('default', function(){
      it('should be accessible through .sockets', function(){
        var sio = io();
        expect(sio.sockets).to.be.a(Namespace);
      });

      it('should be aliased', function(){
        var sio = io();
        expect(sio.use).to.be.a('function');
        expect(sio.to).to.be.a('function');
        expect(sio.in).to.be.a('function');
        expect(sio.emit).to.be.a('function');
        expect(sio.send).to.be.a('function');
        expect(sio.write).to.be.a('function');
      });

      it('should automatically connect', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          socket.on('connect', function(){
            done();
          });
        });
      });

      it('should fire a `connection` event', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          sio.on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            done();
          });
        });
      });

      it('should fire a `connect` event', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          sio.on('connect', function(socket){
            expect(socket).to.be.a(Socket);
            done();
          });
        });
      });

      it('should work with many sockets', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          chat.on('connect', function(){
            --total || done();
          });
          news.on('connect', function(){
            --total || done();
          });
        });
      });

      it('should work with `of` and many sockets', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          sio.of('/news').on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
          sio.of('/news').on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
        });
      });

      it('should work with `of` second param', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          sio.of('/news', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
          sio.of('/news', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
        });
      });

      it('should disconnect upon transport disconnection', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          var totald = 2;
          var s;
          sio.of('/news', function(socket){
            socket.on('disconnect', function(reason){
              --totald || done();
            });
            --total || close();
          });
          sio.of('/chat', function(socket){
            s = socket;
            socket.on('disconnect', function(reason){
              --totald || done();
            });
            --total || close();
          });
          function close(){
            s.disconnect(true);
          }
        });
      });
    });
  });

  describe('socket', function(){
    it('should receive events', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('random', function(a, b, c){
            expect(a).to.be(1);
            expect(b).to.be('2');
            expect(c).to.eql([3]);
            done();
          });
          socket.emit('random', 1, '2', [3]);
        });
      });
    });

    it('should receive message events through `send`', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('message', function(a){
            expect(a).to.be(1337);
            done();
          });
          socket.send(1337);
        });
      });
    });

    it('should emit events', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        socket.on('woot', function(a){
          expect(a).to.be('tobi');
          done();
        });
        sio.on('connection', function(s){
          s.emit('woot', 'tobi');
        });
      });
    });

    it('should emit message events through `send`', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        socket.on('message', function(a){
          expect(a).to.be('a');
          done();
        });
        sio.on('connection', function(s){
          s.send('a');
        });
      });
    });

    it('should receive event with callbacks', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('woot', function(fn){
            fn(1, 2);
          });
          socket.emit('woot', function(a, b){
            expect(a).to.be(1);
            expect(b).to.be(2);
            done();
          });
        });
      });
    });

    it('should emit events with callbacks', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          socket.on('hi', function(fn){
            fn();
          });
          s.emit('hi', function(){
            done();
          });
        });
      });
    });

    it('should receive events with args and callback', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('woot', function(a, b, fn){
            expect(a).to.be(1);
            expect(b).to.be(2);
            fn();
          });
          socket.emit('woot', 1, 2, function(){
            done();
          });
        });
      });
    });

    it('should emit events with args and callback', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          socket.on('hi', function(a, b, fn){
            expect(a).to.be(1);
            expect(b).to.be(2);
            fn();
          });
          s.emit('hi', 1, 2, function(){
            done();
          });
        });
      });
    });
  });
});
<commit_msg>test: added broadcasting / namespace emit tests<commit_after>
var http = require('http').Server;
var io = require('..');
var ioc = require('socket.io-client');
var request = require('supertest');
var expect = require('expect.js');

// creates a socket.io client for the given server
function client(srv, nsp, opts){
  if ('object' == typeof nsp) {
    opts = nsp;
    nsp = null;
  }
  var addr = srv.address();
  if (!addr) addr = srv.listen().address();
  var url = 'ws://' + addr.address + ':' + addr.port + (nsp || '');
  return ioc(url, opts);
}

describe('socket.io', function(){
  describe('server attachment', function(){
    describe('http.Server', function(){
      it('should serve static files', function(done){
        var srv = http();
        io(srv);
        request(srv)
        .get('/socket.io/socket.io.js')
        .buffer(true)
        .end(function(err, res){
          if (err) return done(err);
          var ctype = res.headers['content-type'];
          expect(ctype).to.be('application/javascript');
          expect(res.text).to.match(/engine\.io/);
          expect(res.status).to.be(200);
          done();
        });
      });

      it('should not serve static files', function(done){
        var srv = http();
        io(srv, { static: false });
        request(srv)
        .get('/socket.io/socket.io.js')
        .expect(400, done);
      });

      it('should work with #attach', function(done){
        var srv = http(function(req, res){
          res.writeHead(404);
          res.end();
        });
        var sockets = io();
        sockets.attach(srv);
        request(srv)
        .get('/socket.io/socket.io.js')
        .end(function(err, res){
          if (err) return done(err);
          expect(res.status).to.be(200);
          done();
        });
      });
    });

    describe('port', function(done){
      it('should be bound', function(done){
        var sockets = io(54010);
        request('http://localhost:54010')
        .get('/socket.io/socket.io.js')
        .expect(200, done);
      });
    });
  });

  describe('namespaces', function(){
    var Socket = require('../lib/socket');
    var Namespace = require('../lib/namespace');

    describe('default', function(){
      it('should be accessible through .sockets', function(){
        var sio = io();
        expect(sio.sockets).to.be.a(Namespace);
      });

      it('should be aliased', function(){
        var sio = io();
        expect(sio.use).to.be.a('function');
        expect(sio.to).to.be.a('function');
        expect(sio.in).to.be.a('function');
        expect(sio.emit).to.be.a('function');
        expect(sio.send).to.be.a('function');
        expect(sio.write).to.be.a('function');
      });

      it('should automatically connect', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          socket.on('connect', function(){
            done();
          });
        });
      });

      it('should fire a `connection` event', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          sio.on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            done();
          });
        });
      });

      it('should fire a `connect` event', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var socket = client(srv);
          sio.on('connect', function(socket){
            expect(socket).to.be.a(Socket);
            done();
          });
        });
      });

      it('should work with many sockets', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          chat.on('connect', function(){
            --total || done();
          });
          news.on('connect', function(){
            --total || done();
          });
        });
      });

      it('should work with `of` and many sockets', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          sio.of('/news').on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
          sio.of('/news').on('connection', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
        });
      });

      it('should work with `of` second param', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          sio.of('/news', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
          sio.of('/news', function(socket){
            expect(socket).to.be.a(Socket);
            --total || done();
          });
        });
      });

      it('should disconnect upon transport disconnection', function(done){
        var srv = http();
        var sio = io(srv);
        srv.listen(function(){
          var chat = client(srv, '/chat');
          var news = client(srv, '/news');
          var total = 2;
          var totald = 2;
          var s;
          sio.of('/news', function(socket){
            socket.on('disconnect', function(reason){
              --totald || done();
            });
            --total || close();
          });
          sio.of('/chat', function(socket){
            s = socket;
            socket.on('disconnect', function(reason){
              --totald || done();
            });
            --total || close();
          });
          function close(){
            s.disconnect(true);
          }
        });
      });
    });
  });

  describe('socket', function(){
    it('should receive events', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('random', function(a, b, c){
            expect(a).to.be(1);
            expect(b).to.be('2');
            expect(c).to.eql([3]);
            done();
          });
          socket.emit('random', 1, '2', [3]);
        });
      });
    });

    it('should receive message events through `send`', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('message', function(a){
            expect(a).to.be(1337);
            done();
          });
          socket.send(1337);
        });
      });
    });

    it('should emit events', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        socket.on('woot', function(a){
          expect(a).to.be('tobi');
          done();
        });
        sio.on('connection', function(s){
          s.emit('woot', 'tobi');
        });
      });
    });

    it('should emit message events through `send`', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        socket.on('message', function(a){
          expect(a).to.be('a');
          done();
        });
        sio.on('connection', function(s){
          s.send('a');
        });
      });
    });

    it('should receive event with callbacks', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('woot', function(fn){
            fn(1, 2);
          });
          socket.emit('woot', function(a, b){
            expect(a).to.be(1);
            expect(b).to.be(2);
            done();
          });
        });
      });
    });

    it('should emit events with callbacks', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          socket.on('hi', function(fn){
            fn();
          });
          s.emit('hi', function(){
            done();
          });
        });
      });
    });

    it('should receive events with args and callback', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          s.on('woot', function(a, b, fn){
            expect(a).to.be(1);
            expect(b).to.be(2);
            fn();
          });
          socket.emit('woot', 1, 2, function(){
            done();
          });
        });
      });
    });

    it('should emit events with args and callback', function(done){
      var srv = http();
      var sio = io(srv);
      srv.listen(function(){
        var socket = client(srv);
        sio.on('connection', function(s){
          socket.on('hi', function(a, b, fn){
            expect(a).to.be(1);
            expect(b).to.be(2);
            fn();
          });
          s.emit('hi', 1, 2, function(){
            done();
          });
        });
      });
    });
  });

  describe('messaging many', function(){
    it('emits to a namespace', function(done){
      var srv = http();
      var sio = io(srv);
      var total = 2;

      srv.listen(function(){
        var socket1 = client(srv, { multiplex: false });
        var socket2 = client(srv, { multiplex: false });
        var socket3 = client(srv, '/test');
        socket1.on('a', function(a){
          expect(a).to.be('b');
          --total || done();
        });
        socket2.on('a', function(a){
          expect(a).to.be('b');
          --total || done();
        });
        socket3.on('a', function(){ done(new Error('not')); });

        var sockets = 3;
        sio.on('connection', function(socket){
          --sockets || emit();
        });
        sio.of('/test', function(socket){
          --sockets || emit();
        });

        function emit(){
          sio.emit('a', 'b');
        }
      });
    });

    it('emits to the rest', function(done){
      var srv = http();
      var sio = io(srv);
      var total = 2;

      srv.listen(function(){
        var socket1 = client(srv, { multiplex: false });
        var socket2 = client(srv, { multiplex: false });
        var socket3 = client(srv, '/test');
        socket1.on('a', function(a){
          expect(a).to.be('b');
          socket1.emit('finish');
        });
        socket2.emit('broadcast');
        socket2.on('a', function(){ done(new Error('done')); });
        socket3.on('a', function(){ done(new Error('not')); });

        var sockets = 2;
        sio.on('connection', function(socket){
          socket.on('broadcast', function(){
            socket.broadcast.emit('a', 'b');
          });
          socket.on('finish', function(){
            done();
          });
        });
      });
    });

    it('emits to rooms', function(done){
      var srv = http();
      var sio = io(srv);
      var total = 2;

      srv.listen(function(){
        var socket1 = client(srv, { multiplex: false });
        var socket2 = client(srv, { multiplex: false });

        socket2.on('a', function(){
          done(new Error('not'));
        });
        socket1.on('a', function(){
          done();
        });
        socket1.emit('join', 'woot', function(){
          socket1.emit('emit', 'woot');
        });

        sio.on('connection', function(socket){
          socket.on('join', function(room, fn){
            socket.join(room, fn);
          });

          socket.on('emit', function(room){
            sio.in(room).emit('a');
          });
        });
      });
    });

    it('emits to rooms avoiding dupes', function(done){
      var srv = http();
      var sio = io(srv);
      var total = 2;

      srv.listen(function(){
        var socket1 = client(srv, { multiplex: false });
        var socket2 = client(srv, { multiplex: false });

        socket2.on('a', function(){
          done(new Error('not'));
        });
        socket1.on('a', function(){
          --total || done();
        });
        socket2.on('b', function(){
          --total || done();
        });

        socket1.emit('join', 'woot');
        socket1.emit('join', 'test');
        socket2.emit('join', 'third', function(){
          socket2.emit('emit');
        });

        sio.on('connection', function(socket){
          socket.on('join', function(room, fn){
            socket.join(room, fn);
          });

          socket.on('emit', function(room){
            sio.in('woot').in('test').emit('a');
            sio.in('third').emit('b');
          });
        });
      });
    });

    it('broadcasts to rooms', function(done){
      var srv = http();
      var sio = io(srv);
      var total = 2;

      srv.listen(function(){
        var socket1 = client(srv, { multiplex: false });
        var socket2 = client(srv, { multiplex: false });
        var socket3 = client(srv, { multiplex: false });

        socket1.emit('join', 'woot');
        socket2.emit('join', 'test');
        socket3.emit('join', 'test', function(){
          socket3.emit('broadcast');
        });

        socket1.on('a', function(){
          done(new Error('not'));
        });
        socket2.on('a', function(){
          --total || done();
        });
        socket3.on('a', function(){
          done(new Error('not'));
        });
        socket3.on('b', function(){
          --total || done();
        });

        sio.on('connection', function(socket){
          socket.on('join', function(room, fn){
            socket.join(room, fn);
          });

          socket.on('broadcast', function(){
            socket.broadcast.to('test').emit('a');
            socket.emit('b');
          });
        });
      });
    });
  });
});
<|endoftext|>


<commit_before>define('spec/game', ['lyria/game'], function(Game) {

  var game = new Game();

  describe('lyria/game', function() {
    it('is a function', function() {
      expect(Game).to.be.a('function');
    });

    it('can be instantiated', function() {
      expect(game).to.be.a('object');
    });
  });

});
<commit_msg>Added new unit test<commit_after>define('spec/game', ['lyria/game'], function(Game) {

  var game = new Game();

  describe('lyria/game', function() {
    it('is a function', function() {
      expect(Game).to.be.a('function');
    });

    it('can be instantiated', function() {
      expect(game).to.be.a('object');
    });

    it('has a reference to lyria/loop', function() {
      expect(Game).to.have.a.property('Loop');
      expect(Game.Loop).to.be.a('object');
    });
  });

});
<|endoftext|>


<commit_before>!function(){if(!window.jQuery){var i=document.createElement("script");i.type="text/javascript",i.src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js",document.getElementsByTagName("head")[0].appendChild(i)}var n=function(i){window.jQuery?("undefined"!=typeof $&&!$("body")instanceof jQuery&&jQuery.noConflict(),i(jQuery)):window.setTimeout(function(){n(i)},100)};n(function(i){var n=i('
');if(i(function(){var t=i("body");t.append(n);var a='';i("head").append(a),t.append(i('
'))}),sessionStorage.alreadyLoaded)n.remove();else{var t=i('
'),a='
\n

\n    \n

\n

Tweet\n    \n

\n    \n    \n

\n

\n
\n        \n
\n    \n    \n    \n
\n    \n    \n
?
';t.append(a),n.html(t)}})}();<commit_msg>added tracking pixel<commit_after>!function(){if(!window.jQuery){var i=document.createElement("script");i.type="text/javascript",i.src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js",document.getElementsByTagName("head")[0].appendChild(i)}var n=function(i){window.jQuery?("undefined"!=typeof $&&!$("body")instanceof jQuery&&jQuery.noConflict(),i(jQuery)):window.setTimeout(function(){n(i)},100)};n(function(i){var n=i('
');if(i(function(){var t=i("body");t.append(n);var a='';i("head").append(a),t.append(i('

'))}),sessionStorage.alreadyLoaded)n.remove();else{var t=i('
'),a='
\n

\n    \n

\n

Tweet\n    \n

\n    \n    \n

\n

\n
\n        \n
\n    \n    \n    \n
\n    \n    \n
?
';t.append(a),n.html(t)}})}();<|endoftext|>


<commit_before>(function () {
	var vid = 'BnC-cpUCdns';

	var $target = $('body');
	if ($target.data('vid') == vid)
		return;
	else
		$target.data({vid: vid}).find('object').remove();
	make_video(vid, {autoplay: '1', loop: '1'}).css({'margin-left': '-9001px', 'position': 'absolute'}).appendTo($target);
})();
<commit_msg>Improved fun<commit_after>(function () {
	function audio(vid, options) {
		var $body = $('body');
		if ($body.data('vid') == vid)
			return;
		$body.data({vid: vid}).find('.audio').remove();
		if (!options)
			options = {autoplay: '1', loop: '1'};
		make_video(vid, options).css({'margin-left': '-9001px', 'position': 'absolute'}).addClass('audio').prependTo($body);
	}
	audio('BnC-cpUCdns');
})();
<|endoftext|>


<commit_before>// you are given a string 'abcabc' u need to find max possible substrings of the pattern /a+b+c+/i

<commit_msg>updated script<commit_after>// you are given a string 'abcabc' u need to find max possible substrings of the pattern /a+b+c+/i

function main(input) {
    //Enter your code here
	var i=0, cnt = {a: 0, b: 0, c: 0};

	for(i=0;i<input,length;i++) {
		if(input[i] === 'a') {
			cnt.a = cnt.a << 1;
			cnt.a++;
		} else if(input[i] === 'b') {
			cnt.b = cnt.b << 1;
			cnt.b += cnt.a;
		} else if(input[i] === 'c') {
			cnt.c = cnt.c << 1;
			cnt.c += cnt.b;
		}
	}
	console.log(cnt.c);
}<|endoftext|>


<commit_before>const request = require('request-promise');

const { logError, logGetAllRooms, logGetRoomLights } = require('./events');

async function getStatus(req, res) {
    try {
        const { status } = await request({
            uri: `${process.env.HUE_REMOTE_URL}`,
            json: true
        });

        res.json({ status });
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getAllRooms(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/groups`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });
        res.json(response);
        logGetAllRooms(res.locals.user._id); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getRoomLights(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/groups/${req.params.id}`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });

        res.json(response);
        logGetRoomLights(res.locals.user._id, response.name); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function setRoomLights(req, res) {
    try {
        const response = await request({
            method: 'POST',
            uri: `${process.env.HUE_REMOTE_URL}/api/groups/${req.params.id}/action`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            },
            body: req.body
        });

        res.json(response);
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getOneLight(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/lights/${req.params.id}`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });

        res.json(response);
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function setOneLight(req, res) {
    try {
        const response = await request({
            method: 'POST',
            uri: `${process.env.HUE_REMOTE_URL}/api/lights/${req.params.id}/state`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            },
            body: req.body
        });

        res.json(response);
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

module.exports = {
    getStatus,
    getAllRooms,
    getRoomLights,
    setRoomLights,
    getOneLight,
    setOneLight
};
<commit_msg>finished lighting up events for hue<commit_after>const request = require('request-promise');

const {
    logError,
    logGetAllRooms,
    logGetRoomLights,
    logSetRoomLights,
    logGetOneLight,
    logSetOneLight
} = require('./events');

async function getStatus(req, res) {
    try {
        const { status } = await request({
            uri: `${process.env.HUE_REMOTE_URL}`,
            json: true
        });

        res.json({ status });
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getAllRooms(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/groups`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });
        res.json(response);
        logGetAllRooms(res.locals.user._id); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getRoomLights(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/groups/${req.params.id}`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });

        res.json(response);
        logGetRoomLights(res.locals.user._id, response.name); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function setRoomLights(req, res) {
    try {
        const response = await request({
            method: 'POST',
            uri: `${process.env.HUE_REMOTE_URL}/api/groups/${req.params.id}/action`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            },
            body: req.body
        });

        res.json(response);
        logSetRoomLights(res.locals.user._id, req.params.id, req.body); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function getOneLight(req, res) {
    try {
        const response = await request({
            uri: `${process.env.HUE_REMOTE_URL}/api/lights/${req.params.id}`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            }
        });

        res.json(response);
        logGetOneLight(res.locals.user._id, req.params.id); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

async function setOneLight(req, res) {
    try {
        const response = await request({
            method: 'POST',
            uri: `${process.env.HUE_REMOTE_URL}/api/lights/${req.params.id}/state`,
            json: true,
            headers: {
                Authorization: `Bearer ${process.env.HUE_REMOTE_TOKEN}`
            },
            body: req.body
        });

        res.json(response);
        logSetOneLight(res.locals.user._id, req.params.id, req.body); // eslint-disable-line no-underscore-dangle
    }
    catch (e) {
        res.status(500).json(e);
        logError(e);
    }
}

module.exports = {
    getStatus,
    getAllRooms,
    getRoomLights,
    setRoomLights,
    getOneLight,
    setOneLight
};
<|endoftext|>


<commit_before>lCanvas.prototype.drawSimpleHeat = function (hiddenCanvas, mapbounds, map, sw, ne) {

    var hiddenContext = hiddenCanvas.getContext("2d"),
        canvasWidth = hiddenCanvas.width,
        canvasHeight = hiddenCanvas.height,

        // will use the image data as we are going to play with single pixels
        imageData = hiddenContext.getImageData(0, 0, canvasWidth, canvasHeight),
        // get a byte array with all the pixels in the image. by default all of them should be 0
        // we will use the same array to calculate the number of points per pixel and then
        // transfor that data into the color in the palete for that pixel
        bytes = new Uint32Array(imageData.data.buffer),

        pointSize = this.pointSize,
        adjust = pointSize / 2,
        adjustPow = adjust * adjust,
        swx = sw.x,
        ney = ne.y,
        maxPoint = 0;

    // first thing is to calculate the "heat" of each pixel, based on the number of concurrent points on it
    // don't need to go through all the points in the canvas, only the visible points
    for (var i = 0, points = this._points, len = points.length; i < len; i++) {

        var ltlng = points[i];

        if (mapbounds.contains(ltlng)) {

            var layerPointPosition = map.latLngToLayerPoint(ltlng),
                xpos = Math.round(layerPointPosition.x - swx),
                ypos = Math.round(layerPointPosition.y - ney),
                x0 = Math.round(xpos - adjust),
                x1 = Math.round(xpos + adjust),
                y0 = Math.round(ypos - adjust),
                y1 = Math.round(ypos + adjust);

            // try to avoid to use pixels out of the canvas size
            if (x0 < 0) x0 = 0;
            if (x1 >= canvasWidth) x1 = canvasWidth - 1;
            if (y0 < 0) y0 = 0;
            if (y1 >= canvasHeight) y1 = canvasHeight - 1;

            while (y0 < y1) {

                var yRow = y0 * canvasWidth;

                while (x0 < x1)
                    // using the distance between 2 points formula pretty simplified to give a circle appearance
                    // to each point, otherwise would look "pixelated" like squares.
                    var dist = (x0 - xpos) * (x0 - xpos) + (y0 - ypos) * (y0 - ypos);
                    if (dist <= adjustPow) {
                        // increment the pixel value by 1
                        var size = bytes[yRow + x] + 1;
                        // I want to store the maxPoint value to create the color pattern
                        if (size > maxPoint) { maxPoint = size; }
                        // set the new pixel value
                        bytes[yRow + x] = size;

                        // this could be simplified to
                        // bytes[yRow + x] += 1;
                        // if you don't care about the maximum value
                    }

                    x0++;
                }

                y0++;
            }

        }

    }

    var pattern = this.createColorPattern([
        { r: 0, g: 0, b: 255 }, // blue
        { r: 0, g: 255, b: 255 }, // cyan
        { r: 0, g: 255, b: 0 },  // green
        { r: 255, g: 255, b: 0 }, // yellow
        { r: 255, g: 0, b: 0 }], // red
        maxPoint);

    // once we have all the points placed into the imageData
    // will go through it again to replace the values for the color in the palette
    points = canvasHeight;
    while (points--) {

        var y = points * canvasWidth,
            x = canvasWidth;

        while (x--) {

            // retrieve the "heat" value for that pixel
            var ui32 = bytes[y + x];

            if (ui32 !== 0) {

                // this is to make higher values less opacity (but don't make then opaque)
                var alpha = Math.round(ui32 * 50 / maxPoint);

                // fix possible values - shouldn't be needed
                if (alpha > 50) alpha = 50;

                // fetch the color associated to the pixel value from the pattern
                var c = pattern[ui32];

                // set the pixel value based on it's new color value
                bytes[y + x] = ((150 + alpha) << 24) | (c.b << 16) | (c.g << 8) | (c.r);
            }
        }
    }

    // put the bytes back to the canvas
    hiddenContext.putImageData(imageData, 0, 0);
}

lCanvas.prototype.createColorPattern = function (colors, count) {
    // colors = Array of colors to use, at least an initial and final color must be provided
    // count = total number of colors you need to create
    var pattern = [], steps = Math.round(count / (colors.length - 1));

    for (var i = 0, len = colors.length - 1 ; i < len; i++) {

        var initialColor = colors[i],
            finalColor = colors[i + 1],
            rStep = (finalColor.r - initialColor.r) / steps,
            gStep = (finalColor.g - initialColor.g) / steps,
            bStep = (finalColor.b - initialColor.b) / steps;

        for (var j = 0 ; j <= steps; j++) {
            var r = Math.round(initialColor.r + (rStep * j)),
                g = Math.round(initialColor.g + (gStep * j)),
                b = Math.round(initialColor.b + (bStep * j));

            pattern.push({ "r": r, "g": g, "b": b });
        }

    }

    // sometime it just stop 1 color before the count specified
    // due to decimal and round conversion, so it will add the last color
    // to complete the count
    var fC = colors[colors.length - 1];
    while (pattern.length < count) {
        pattern.push(fC);
    }

    return pattern;
}
<commit_msg>Delete lCanvas.dotTypes.heatmap.js<commit_after><|endoftext|>


<commit_before>import InputClass from '#input?raw&-styles';

export default Base => class extends InputClass(Base) {
    static get displayName() {
        return 'core: button';
    }

    constructor(props) {
        super(props);

        this.state = {
            ...this.state,
            pressed: false
        };
    }

    _onInputMouseDown(e) {
        this.setState({
            pressed: true
        });

        if (this.props.onMouseDown) {
            this.props.onMouseDown(e);
        }
    }

    _onInputMouseUp(e) {
        this.setState({
            pressed: false
        });

        if (this.props.onMouseUp) {
            this.props.onMouseUp(e);
        }
    }

    _onInputMouseLeave(e) {
        super._onInputMouseLeave(e);

        this.setState({
            pressed: false
        });

        if (this.props.onMouseLeave) {
            this.props.onMouseLeave(e);
        }
    }

    render() {
        const template = super.render();

        template.block = 'button';
        template.tag = 'span';

        template.mods = {
            ...template.mods,
            pressed: this.state.pressed
        };

        template.content[0].props = {
            ...template.content[0].props,
            type: 'button',
            onMouseDown: ::this._onInputMouseDown,
            onMouseUp: ::this._onInputMouseUp,
            onMouseLeave: ::this._onInputMouseLeave
        };

        return template;
    }
};
<commit_msg>:see_no_evil:<commit_after>import InputClass from '#input?raw&-styles';

export default Base => class extends InputClass(Base) {
    static get displayName() {
        return 'core: button';
    }

    constructor(props) {
        super(props);

        this.state = {
            ...this.state,
            pressed: false
        };
    }

    _onInputMouseDown(e) {
        this.setState({
            pressed: true
        });

        if (this.props.onMouseDown) {
            this.props.onMouseDown(e);
        }
    }

    _onInputMouseUp(e) {
        this.setState({
            pressed: false
        });

        if (this.props.onMouseUp) {
            this.props.onMouseUp(e);
        }
    }

    _onInputMouseLeave(e) {
        this.setState({
            pressed: false
        });

        super._onInputMouseLeave(e);
    }

    render() {
        const template = super.render();

        template.block = 'button';
        template.tag = 'span';

        template.mods = {
            ...template.mods,
            pressed: this.state.pressed
        };

        template.content[0].props = {
            ...template.content[0].props,
            type: 'button',
            onMouseDown: ::this._onInputMouseDown,
            onMouseUp: ::this._onInputMouseUp,
            onMouseLeave: ::this._onInputMouseLeave
        };

        return template;
    }
};
<|endoftext|>


<commit_before>
/**
 * Module dependencies
 */

var redis = require('redis').createClient();
var subscribe = require('../lib');

describe('Subscribe', function() {

  it('Should throw if options `channels` is missing', function() {
    var exception;

    try {
      var s = subscribe({});
    } catch(e) { exception = e; }

    exception.message.should.equal('option `channels` is required and must be an Array or a String');
  });

  it('Should throw if options `retry` is invalid', function() {
    var exception;

    try {
      var s = subscribe({
        channels: ['test'],
        retry: -1
      });
    } catch(e) { exception = e; }

    exception.message.should.equal('option `sse.retry` must be a Number greater than 0');
  });

  it('Should get a Subscribe stream', function() {
    var s = subscribe({
      channels: ['test']
    });

    s.should.be.an.instanceof.Subscribe;
    s.channels.should.eql(['test']);
  });

  it('Should get a Subscribe stream with Redis options specified', function() {
    var s = subscribe({
      channels: ['test'],
      host: '127.0.0.1',
      port: 6379,
      clientOptions: { enable_offline_queue: false }
    });

    s.should.be.an.instanceof.Subscribe;
    s.channels.should.eql(['test']);
  });

  it('Should stream Redis published messages as SSE', function(done) {

    var chunks = 0;

    var s = subscribe({
      channels: ['test']
    });

    s.on('ready', function() {
      redis.publish('test', 'test-message');
    });

    s.on('data', function(data) {
      if (chunks === 0) {
        data.toString().should.equal('retry: 5000\n');
      }

      if (chunks === 1) {
        data.toString().should.equal('data: test-message\n\n');
        done();
      }

      chunks++;
    });

  });

  it('Should associate Redis channels as SSE events if `channelsAsEvents` option is true', function(done) {
    var chunks = 0;

    var s = subscribe({
      channels: ['named-channel'],
      channelsAsEvents: true
    });

    s.on('ready', function() {
      redis.publish('named-channel', 'test-message');
    });

    s.on('data', function(data) {
      if (chunks === 0) {
        data.toString().should.equal('retry: 5000\n');
      }

      if (chunks === 1) {
        data.toString().should.equal('event: named-channel\n');
      }

      if (chunks === 2) {
        data.toString().should.equal('data: test-message\n\n');
        done();
      }

      chunks++;
    });

  });

});

<commit_msg>Added test for PSUBSCRIBE support<commit_after>
/**
 * Module dependencies
 */

var redis = require('redis').createClient();
var subscribe = require('../lib');

describe('Subscribe', function() {

  it('Should throw if options `channels` is missing', function() {
    var exception;

    try {
      var s = subscribe({});
    } catch(e) { exception = e; }

    exception.message.should.equal('option `channels` is required and must be an Array or a String');
  });

  it('Should throw if options `retry` is invalid', function() {
    var exception;

    try {
      var s = subscribe({
        channels: ['test'],
        retry: -1
      });
    } catch(e) { exception = e; }

    exception.message.should.equal('option `sse.retry` must be a Number greater than 0');
  });

  it('Should get a Subscribe stream', function() {
    var s = subscribe({
      channels: ['test']
    });

    s.should.be.an.instanceof.Subscribe;
    s.channels.should.eql(['test']);
  });

  it('Should get a Subscribe stream with Redis options specified', function() {
    var s = subscribe({
      channels: ['test'],
      host: '127.0.0.1',
      port: 6379,
      clientOptions: { enable_offline_queue: false }
    });

    s.should.be.an.instanceof.Subscribe;
    s.channels.should.eql(['test']);
  });

  it('Should stream Redis published messages as SSE', function(done) {

    var chunks = 0;

    var s = subscribe({
      channels: ['test']
    });

    s.on('ready', function() {
      redis.publish('test', 'test-message');
    });

    s.on('data', function(data) {
      if (chunks === 0) {
        data.toString().should.equal('retry: 5000\n');
      }

      if (chunks === 1) {
        data.toString().should.equal('data: test-message\n\n');
        done();
      }

      chunks++;
    });

  });

  it('Should associate Redis channels as SSE events if `channelsAsEvents` option is true', function(done) {
    var chunks = 0;

    var s = subscribe({
      channels: ['named-channel'],
      channelsAsEvents: true
    });

    s.on('ready', function() {
      redis.publish('named-channel', 'test-message');
    });

    s.on('data', function(data) {
      if (chunks === 0) {
        data.toString().should.equal('retry: 5000\n');
      }

      if (chunks === 1) {
        data.toString().should.equal('event: named-channel\n');
      }

      if (chunks === 2) {
        data.toString().should.equal('data: test-message\n\n');
        done();
      }

      chunks++;
    });

  });

  it('Should stream Redis published messages as SSE (using PSUBSCRIBE)', function(done) {

      var chunks = 0;

      var s = subscribe({
        channels: ['test*'],
        patternSubscribe: true
      });

      s.on('ready', function() {
        redis.publish('test-pattern-subscribe', 'test-pattern-subscribe-message');
      });

      s.on('data', function(data) {
        if (chunks === 0) {
          data.toString().should.equal('retry: 5000\n');
        }

        if (chunks === 1) {
          data.toString().should.equal('data: test-pattern-subscribe-message\n\n');
          done();
        }

        chunks++;
      });

    });

});

<|endoftext|>


<commit_before>'use strict';

const setup = require('./include/setup');
const sinon = require('sinon');

var git, sandbox;

exports.setUp = function (done) {
   setup.restore();
   sandbox = sinon.sandbox.create();
   done();
};

exports.tearDown = function (done) {
   setup.restore();
   sandbox.restore();
   done();
};

exports.pull = {
   setUp: function (done) {
      git = setup.Instance();
      done();
   },

   'pulls an insertion only change set': function (test) {
      var PullSummary = require('../src/responses/PullSummary');
      var pullSummary = PullSummary.parse('From https://github.com/steveukx/git-js\n\
 * branch            foo        -> FETCH_HEAD\n\
Updating 1c57fa9..5b75063\n\
Fast-forward\n\
 src/responses/PullSummary.js | 2 ++\n\
 1 file changed, 2 insertions(+)\n\
');

      test.same(pullSummary.summary.changes, 2);
      test.same(pullSummary.summary.insertions, 2);
      test.same(pullSummary.summary.deletions, 0);

      test.same(pullSummary.insertions['src/responses/PullSummary.js'], 2);
      test.done();
   },

   'pulls with spaces in names': function (test) {
      git.pull(function (err, result) {
         test.same(['pull'], setup.theCommandRun());
         test.same(result.files.length, 21);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 accounting_core_report.kjs |  45 +++++++++-------\n\
 ap.invoice.kjs             |   2 +-\n\
 ar.deposit.kjs             |   6 +--\n\
 ar.invoice_detail.kjs      |  16 +++---\n\
 ar.receipt.kjs             |  10 +++-\n\
 gl.bank_statement.kjs      |   6 +++\n\
 gl.kjs                     | 106 ++++++++++++++++++++++++++------------\n\
 kis.call.kjs               |   2 +\n\
 kis.call_stats_report.kjs  | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\
 kis.edit_recurring.kjs     |   8 +--\n\
 kis.kdr_logs.kjs           |   8 ---\n\
 kpo.batch_pay.kjs          |  19 ++++---\n\
 kpo.fiscal_year.kjs        |  93 +++++++++++++++++++++++++++++----\n\
 kpo.kjs                    |   2 +-\n\
 kpo.payment.kjs            |   3 ++\n\
 kpo.po_adjustment.kjs      |  82 +++++++++++++++++++++++------\n\
 kpo.purchase_order.kjs     |  12 +++--\n\
 kpo.reports.kjs            |  79 +++++++++++++++-------------\n\
 kpo.warrant.kjs            |  17 +++---\n\
 time_tracking.schedule.kjs | 342 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------\n\
 21 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');

   },

   'pulls with options': function (test) {
      git.pull(null, null, {'--rebase': null}, function (err, result) {
         test.same(['pull', '--rebase'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');
   },

   'pulls with options without branch detail': function (test) {
      git.pull({'--no-rebase': null}, function (err, result) {
         test.same(['pull', '--no-rebase'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');
   },

   'pulls with rebase options with value': function (test) {
      git.pull('origin', 'master', { '--rebase' : 'true' }, function (err, result) {
         test.same(['pull', 'origin', 'master', '--rebase=true'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');

   }
};
<commit_msg>Fix insertion-only test<commit_after>'use strict';

const setup = require('./include/setup');
const sinon = require('sinon');

var git, sandbox;

exports.setUp = function (done) {
   setup.restore();
   sandbox = sinon.sandbox.create();
   done();
};

exports.tearDown = function (done) {
   setup.restore();
   sandbox.restore();
   done();
};

exports.pull = {
   setUp: function (done) {
      git = setup.Instance();
      done();
   },

   'pulls an insertion only change set': function (test) {
      var PullSummary = require('../src/responses/PullSummary');
      var pullSummary = PullSummary.parse('From https://github.com/steveukx/git-js\n\
 * branch            foo        -> FETCH_HEAD\n\
Updating 1c57fa9..5b75063\n\
Fast-forward\n\
 src/responses/PullSummary.js | 2 ++\n\
 1 file changed, 2 insertions(+)\n\
');

      test.same(pullSummary.summary.changes, 1);
      test.same(pullSummary.summary.insertions, 2);
      test.same(pullSummary.summary.deletions, 0);

      test.same(pullSummary.insertions['src/responses/PullSummary.js'], 2);
      test.done();
   },

   'pulls with spaces in names': function (test) {
      git.pull(function (err, result) {
         test.same(['pull'], setup.theCommandRun());
         test.same(result.files.length, 21);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 accounting_core_report.kjs |  45 +++++++++-------\n\
 ap.invoice.kjs             |   2 +-\n\
 ar.deposit.kjs             |   6 +--\n\
 ar.invoice_detail.kjs      |  16 +++---\n\
 ar.receipt.kjs             |  10 +++-\n\
 gl.bank_statement.kjs      |   6 +++\n\
 gl.kjs                     | 106 ++++++++++++++++++++++++++------------\n\
 kis.call.kjs               |   2 +\n\
 kis.call_stats_report.kjs  | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\
 kis.edit_recurring.kjs     |   8 +--\n\
 kis.kdr_logs.kjs           |   8 ---\n\
 kpo.batch_pay.kjs          |  19 ++++---\n\
 kpo.fiscal_year.kjs        |  93 +++++++++++++++++++++++++++++----\n\
 kpo.kjs                    |   2 +-\n\
 kpo.payment.kjs            |   3 ++\n\
 kpo.po_adjustment.kjs      |  82 +++++++++++++++++++++++------\n\
 kpo.purchase_order.kjs     |  12 +++--\n\
 kpo.reports.kjs            |  79 +++++++++++++++-------------\n\
 kpo.warrant.kjs            |  17 +++---\n\
 time_tracking.schedule.kjs | 342 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------\n\
 21 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');

   },

   'pulls with options': function (test) {
      git.pull(null, null, {'--rebase': null}, function (err, result) {
         test.same(['pull', '--rebase'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');
   },

   'pulls with options without branch detail': function (test) {
      git.pull({'--no-rebase': null}, function (err, result) {
         test.same(['pull', '--no-rebase'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');
   },

   'pulls with rebase options with value': function (test) {
      git.pull('origin', 'master', { '--rebase' : 'true' }, function (err, result) {
         test.same(['pull', 'origin', 'master', '--rebase=true'], setup.theCommandRun());
         test.same(result.files.length, 1);
         test.done();
      });

      setup.closeWith('\n\
From git.kellpro.net:apps/templates\n\
* branch            release/0.33.0 -> FETCH_HEAD\n\
Updating 1c6e99e..2a5dc63\n\
Fast-forward\n\
 accounting_core.kjs        |  61 +++++++++++-----------\n\
 2 files changed, 856 insertions(+), 352 deletions(-)\n\
 create mode 100644 kis.call_stats_report.kjs\n\
');

   }
};
<|endoftext|>


<commit_before>var assert = require('chai').assert;
var path = require('path');
var request = require('supertest');
var app = require(path.join(__dirname,'..','app'));
var clearDb = require(path.join(__dirname,'helper')).clearDb;

suite('Index', function() {
  setup(function(){

  });

  suite('Index', function () {
    test('List posts', function (done) {
      request(app)
        .get('/')
        .expect('Content-Type', /html/)
        .expect(200, done);
    })
  });

  suite('Signup', function () {
    test('Signup page loads', function (done) {
      request(app)
        .get('/signup')
        .expect('Content-Type', /html/)
        .expect(200, done);
    });

    suite('Signup creation', function () {
      setup(function (){
        clearDb();
      });

      test('Valid signup', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*')
          .expect('Content-Type', /plain/)
          .expect(302, done);
      });
      test('Invalid Signup, missing name', function (done) {
        request(app)
          .post('/signup')
          .field('name', '')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*')
          .expect('Content-Type', /html/)
          .expect(/fill your name/)
          .expect(200, done);
      });
      test('Invalid Signup, missing email', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', '')
          .field('password', 'Password123*')
          .expect('Content-Type', /html/)
          .expect(/fill your email/)
          .expect(200, done);
      });
      test('Invalid Signup, missing password', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', 'email@domain.com')
          .field('password', '')
          .expect('Content-Type', /html/)
          .expect(/fill your password/)
          .expect(200, done);
      });
    });
  });
})
<commit_msg>Valid signin test<commit_after>var assert = require('chai').assert;
var path = require('path');
var request = require('supertest');
var app = require(path.join(__dirname,'..','app'));
var clearDb = require(path.join(__dirname,'helper')).clearDb;

suite('Index', function() {
  setup(function(){

  });

  suite('Index', function () {
    test('List posts', function (done) {
      request(app)
        .get('/')
        .expect('Content-Type', /html/)
        .expect(200, done);
    })
  });

  suite('Signup', function () {
    test('Signup page loads', function (done) {
      request(app)
        .get('/signup')
        .expect('Content-Type', /html/)
        .expect(200, done);
    });

    suite('Signup creation', function () {
      setup(function (){
        clearDb();
      });

      test('Valid signup', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*')
          .expect('Content-Type', /plain/)
          .expect(302, done);
      });
      test('Invalid Signup, missing name', function (done) {
        request(app)
          .post('/signup')
          .field('name', '')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*')
          .expect('Content-Type', /html/)
          .expect(/fill your name/)
          .expect(200, done);
      });
      test('Invalid Signup, missing email', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', '')
          .field('password', 'Password123*')
          .expect('Content-Type', /html/)
          .expect(/fill your email/)
          .expect(200, done);
      });
      test('Invalid Signup, missing password', function (done) {
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', 'email@domain.com')
          .field('password', '')
          .expect('Content-Type', /html/)
          .expect(/fill your password/)
          .expect(200, done);
      });
    });

    suite('Signin', function () {
      setup(function (){
        clearDb();
        request(app)
          .post('/signup')
          .field('name', 'John Doe')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*');
      });

      test('Valid signin', function (done) {
        request(app)
          .post('/signin')
          .field('email', 'email@domain.com')
          .field('password', 'Password123*')
          .expect('Content-Type', /plain/)
          .expect(302, done);
      });
    });
  });
})
<|endoftext|>