[Pkg-javascript-commits] [node-assertion-error] 01/05: Imported Upstream version 1.0.2

Sruthi Chandran srud-guest at moszumanska.debian.org
Wed Oct 12 17:58:50 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-assertion-error.

commit c812a7cd2600289f92b86fa9581b728a3e29afce
Author: Syam G Krishnan <sgk at riseup.net>
Date:   Wed Oct 12 09:11:37 2016 +0530

    Imported Upstream version 1.0.2
---
 .gitignore      |  19 ++++++++++
 .npmignore      |  11 ++++++
 .travis.yml     |  14 +++++++
 History.md      |  19 ++++++++++
 Makefile        |  38 +++++++++++++++++++
 README.md       |  41 ++++++++++++++++++++
 component.json  |  18 +++++++++
 index.js        | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 package.json    |  27 +++++++++++++
 test/index.html |  57 ++++++++++++++++++++++++++++
 test/index.js   |  59 ++++++++++++++++++++++++++++
 test/test.js    |  58 ++++++++++++++++++++++++++++
 12 files changed, 477 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8972bd0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+build
+components
+
+node_modules
+npm-debug.log
+
+coverage.html
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..f105953
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,11 @@
+docs/
+test/
+build/
+components/
+support/
+coverage.html
+component.json
+lib-cov
+.travis.yml
+Makefile
+*.swp
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..c44380c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,14 @@
+language: node_js
+node_js:
+  - 0.10
+
+deploy:
+  provider: npm
+  email: jake at alogicalparadox.com
+  api_key:
+    secure: AgNQTECM/3Gh0q77gkrMx0jASgRh/dysPdUf7Zdsm1k9Gt+i4H99k2L8lVWqpLF1+e6lhWg9w4C08Xgz6tuOTPZZr6UzeRDl+ZjniTYK3E/tpcUbqAQxxgD4b3iA6BLbF0YKGofnWrMtXBBWI8X0jekxncu7sWdBuieyhg33fik=
+  on:
+    tags: true
+    repo: chaijs/assertion-error
+    all_branches: true
+
diff --git a/History.md b/History.md
new file mode 100644
index 0000000..7285b55
--- /dev/null
+++ b/History.md
@@ -0,0 +1,19 @@
+1.0.1 / 2015-03-04
+==================
+
+  * Merge pull request #2 from simonzack/master
+  * fixes `.stack` on firefox
+
+1.0.0 / 2013-06-08
+==================
+
+  * readme: change travis and component urls
+  * refactor: [*] prepare for move to chaijs gh org
+
+0.1.0 / 2013-04-07
+==================
+
+  * test: use vanilla test runner/assert
+  * pgk: remove unused deps
+  * lib: implement
+  * "Initial commit"
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f1a63dd
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,38 @@
+
+#
+# Tests
+# 
+
+test: test-node
+
+test-node: 
+	@printf "\n  ==> [Node.js]\n"
+	@NODE_ENV=test node ./test/index.js
+
+test-browser:
+	@printf "\n  ==> [Browser]\n"
+	@make build
+	@printf "\n\n  Open 'test/index.html' in your browser to test.\n\n"
+
+#
+# Components
+# 
+
+build: components
+	@./node_modules/.bin/component-build --dev
+
+components: component.json
+	@./node_modules/.bin/component-install --dev
+
+#
+# Clean up
+# 
+
+clean: clean-components 
+
+clean-components:
+	@rm -rf build
+	@rm -rf components
+
+.PHONY: test test-node test-browser
+.PHONY: clean clean-components
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6cf03c8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,41 @@
+# AssertionError [![Build Status](https://travis-ci.org/chaijs/assertion-error.png?branch=master)](https://travis-ci.org/chaijs/assertion-error)
+
+> Error constructor for test and validation frameworks that implements standardized AssertionError specification.
+
+## Installation
+
+### Node.js
+
+`assertion-error` is available on [npm](http://npmjs.org).
+
+    $ npm install assertion-error
+
+### Component
+
+`assertion-error` is available as a [component](https://github.com/component/component).
+
+    $ component install chaijs/assertion-error
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2013 Jake Luer <jake at qualiancy.com> (http://qualiancy.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/component.json b/component.json
new file mode 100644
index 0000000..e8e0547
--- /dev/null
+++ b/component.json
@@ -0,0 +1,18 @@
+{
+    "name": "assertion-error"
+  , "repo": "chaijs/assertion-error"
+  , "version": "1.0.1"
+  , "description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification."
+  , "license": "MIT"
+  , "keywords": [
+        "test"
+      , "assertion"
+      , "assertion-error"
+    ]
+  , "main": "index.js"
+  , "scripts": [
+        "index.js"
+    ]
+  , "dependencies": {}
+  , "development": {}
+}
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..5c01747
--- /dev/null
+++ b/index.js
@@ -0,0 +1,116 @@
+/*!
+ * assertion-error
+ * Copyright(c) 2013 Jake Luer <jake at qualiancy.com>
+ * MIT Licensed
+ */
+
+/*!
+ * Return a function that will copy properties from
+ * one object to another excluding any originally
+ * listed. Returned function will create a new `{}`.
+ *
+ * @param {String} excluded properties ...
+ * @return {Function}
+ */
+
+function exclude () {
+  var excludes = [].slice.call(arguments);
+
+  function excludeProps (res, obj) {
+    Object.keys(obj).forEach(function (key) {
+      if (!~excludes.indexOf(key)) res[key] = obj[key];
+    });
+  }
+
+  return function extendExclude () {
+    var args = [].slice.call(arguments)
+      , i = 0
+      , res = {};
+
+    for (; i < args.length; i++) {
+      excludeProps(res, args[i]);
+    }
+
+    return res;
+  };
+};
+
+/*!
+ * Primary Exports
+ */
+
+module.exports = AssertionError;
+
+/**
+ * ### AssertionError
+ *
+ * An extension of the JavaScript `Error` constructor for
+ * assertion and validation scenarios.
+ *
+ * @param {String} message
+ * @param {Object} properties to include (optional)
+ * @param {callee} start stack function (optional)
+ */
+
+function AssertionError (message, _props, ssf) {
+  var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
+    , props = extend(_props || {});
+
+  // default values
+  this.message = message || 'Unspecified AssertionError';
+  this.showDiff = false;
+
+  // copy from properties
+  for (var key in props) {
+    this[key] = props[key];
+  }
+
+  // capture stack trace
+  ssf = ssf || arguments.callee;
+  if (ssf && Error.captureStackTrace) {
+    Error.captureStackTrace(this, ssf);
+  } else {
+    try {
+      throw new Error();
+    } catch(e) {
+      this.stack = e.stack;
+    }
+  }
+}
+
+/*!
+ * Inherit from Error.prototype
+ */
+
+AssertionError.prototype = Object.create(Error.prototype);
+
+/*!
+ * Statically set name
+ */
+
+AssertionError.prototype.name = 'AssertionError';
+
+/*!
+ * Ensure correct constructor
+ */
+
+AssertionError.prototype.constructor = AssertionError;
+
+/**
+ * Allow errors to be converted to JSON for static transfer.
+ *
+ * @param {Boolean} include stack (default: `true`)
+ * @return {Object} object that can be `JSON.stringify`
+ */
+
+AssertionError.prototype.toJSON = function (stack) {
+  var extend = exclude('constructor', 'toJSON', 'stack')
+    , props = extend({ name: this.name }, this);
+
+  // include stack if exists and not turned off
+  if (false !== stack && this.stack) {
+    props.stack = this.stack;
+  }
+
+  return props;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..419eb4f
--- /dev/null
+++ b/package.json
@@ -0,0 +1,27 @@
+{
+    "name": "assertion-error"
+  , "version": "1.0.2"
+  , "description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification."
+  , "author": "Jake Luer <jake at qualiancy.com> (http://qualiancy.com)"
+  , "license": "MIT"
+  , "keywords": [
+        "test"
+      , "assertion"
+      , "assertion-error"
+    ]
+  , "repository": {
+        "type": "git"
+      , "url": "git at github.com:chaijs/assertion-error.git"
+    }
+  , "engines": {
+      "node": "*"
+    }
+  , "main": "./index"
+  , "scripts": {
+      "test": "make test"
+    }
+  , "dependencies": {}
+  , "devDependencies": {
+        "component": "*"
+    }
+}
diff --git a/test/index.html b/test/index.html
new file mode 100644
index 0000000..5d769f0
--- /dev/null
+++ b/test/index.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>Browser Tests (assertion-error)</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  </head>
+  <body>
+    <p>To see results view console.</p>
+    <script src="../build/build.js"></script>
+    <script>
+      AssertionError = require('assertion-error');
+      (function runner (ctx) {
+        /*!
+         * Simple test runner.
+         */
+
+        var count = 0
+          , failures = []
+          , tests = [];
+
+        function test (name, fn) {
+          tests.push({ name: name, fn: fn });
+        }
+
+        function assert (pass, msg) {
+          if (!pass) throw new Error(msg);
+        }
+
+        ctx.suite = function (fn) {
+          fn(test, assert);
+          console.log('  Tests (%d)', tests.length);
+
+          tests.forEach(function (test) {
+            var err = false
+              , num = ++count;
+
+            try { test.fn(); }
+            catch (ex) { err = ex; }
+
+            if (err) {
+              console.log('  %d. [fail] %s', num, test.name);
+              failures.push({ num: num, err: err });
+            } else {
+              console.log('  %d. [pass] %s', num, test.name);
+            }
+          });
+
+          console.log('  Failures (%d)', failures.length);
+          failures.forEach(function (failure) {
+            console.log('  %d. %s', failure.num, failure.err.message);
+          });
+        };
+      })(this);
+    </script>
+    <script src="./test.js"></script>
+  </body>
+</html>
diff --git a/test/index.js b/test/index.js
new file mode 100644
index 0000000..6cb5d47
--- /dev/null
+++ b/test/index.js
@@ -0,0 +1,59 @@
+/*!
+ * Include lib
+ */
+
+global.AssertionError = require('..');
+
+/*!
+ * Simple test runner.
+ */
+
+var count = 0
+  , failures = []
+  , tests = [];
+
+function test (name, fn) {
+  tests.push({ name: name, fn: fn });
+}
+
+function assert (pass, msg) {
+  if (!pass) throw new Error(msg);
+}
+
+global.suite = function (fn) {
+  fn(test, assert);
+
+  console.log('');
+  console.log('  Tests (%d)', tests.length);
+
+  tests.forEach(function (test) {
+    var err = false
+      , num = ++count;
+
+    try { test.fn(); }
+    catch (ex) { err = ex; }
+
+    if (err) {
+      console.log('  %d. [fail] %s', num, test.name);
+      failures.push({ num: num, err: err });
+    } else {
+      console.log('  %d. [pass] %s', num, test.name);
+    }
+  });
+
+  console.log('');
+  console.log('  Failures (%d)', failures.length);
+
+  failures.forEach(function (failure) {
+    console.log('  %d. %s', failure.num, failure.err.message);
+  });
+
+  console.log('');
+  process.exit(failures.length);
+};
+
+/*!
+ * Load the tests
+ */
+
+require('./test');
diff --git a/test/test.js b/test/test.js
new file mode 100644
index 0000000..c696e0f
--- /dev/null
+++ b/test/test.js
@@ -0,0 +1,58 @@
+suite(function (test, assert) {
+  test('construction', function () {
+    var err = new AssertionError();
+    assert(err instanceof Error, 'instanceof Error');
+    assert(err instanceof AssertionError, 'instanceof AssertionError');
+    assert(err.name && err.name === 'AssertionError', 'name === "AssertionError"');
+  });
+
+  test('message', function () {
+    var err = new AssertionError('Oops.')
+      , empty = new AssertionError();
+    assert(err.message === 'Oops.', 'w/ err.message');
+    assert(empty.message === 'Unspecified AssertionError', 'w/o err.message');
+  });
+
+  test('stack', function() {
+    assert(typeof new AssertionError().stack === 'string');
+  });
+
+  test('custom properties', function () {
+    var err = new AssertionError('good message', {
+        name: 'ShouldNotExist'
+      , hello: 'universe'
+      , message: 'bad message'
+      , stack: 'custom stack'
+    });
+
+    assert(err.name === 'AssertionError', 'does not overwrite name');
+    assert(err.message === 'good message', 'does not overwrite message');
+    assert(err.hello && err.hello === 'universe', 'has custom property');
+
+    // some browsers don't have stack
+    if (err.stack) {
+      assert(err.stack && err.stack !== 'custom stack', 'does not overwrite stack');
+    }
+  });
+
+  test('.toJSON()', function () {
+    var err = new AssertionError('some message', {
+        hello: 'universe'
+      , goodbye: 'known'
+    });
+
+    var json = err.toJSON();
+
+    assert(json.name === 'AssertionError', 'json has name');
+    assert(json.message === 'some message', 'json has message');
+    assert(json.hello === 'universe' && json.goodbye === 'known', 'json has custom properties');
+
+    // some browsers don't have stack
+    if (err.stack) {
+      assert('string' === typeof json.stack, 'json has stack');
+    }
+
+    var nostack = err.toJSON(false);
+    assert(!nostack.stack, 'no stack on false argument');
+  });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-assertion-error.git



More information about the Pkg-javascript-commits mailing list