Commit 6b1a247e authored by Julia Radzhabova's avatar Julia Radzhabova

Update underscore to v.1.8.3

parent cbcee82f
{
"env": {
"browser": true,
"node": true,
"amd": true
},
"rules": {
"array-bracket-spacing": [2],
"block-scoped-var": 1,
"brace-style": [1, "1tbs"],
"camelcase": 2,
"comma-dangle": [2, "never"],
"comma-spacing": 2,
"computed-property-spacing": [2, "never"],
"consistent-return": 1,
"dot-notation": [2, { "allowKeywords": false }],
"eol-last": 2,
"eqeqeq": [2, "smart"],
"indent": [2, 2, {"SwitchCase": 1, "VariableDeclarator": 2}],
"key-spacing": 1,
"linebreak-style": 2,
"max-depth": [1, 4],
"max-params": [1, 5],
"new-cap": 2,
"no-alert": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-console": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-div-regex": 1,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-else-return": 1,
"no-empty-character-class": 2,
"no-empty-label": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": 1,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": 2,
"no-irregular-whitespace": 2,
"no-label-var": 2,
"no-lone-blocks": 2,
"no-lonely-if": 2,
"no-multi-spaces": 1,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-negated-in-lhs": 1,
"no-nested-ternary": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-shadow": 2,
"no-spaced-func": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-undef": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unneeded-ternary": 2,
"no-unreachable": 2,
"no-unused-expressions": 2,
"no-unused-vars": 2,
"no-use-before-define": [1, "nofunc"],
"no-with": 2,
"object-curly-spacing": [2, "never"],
"quote-props": [1, "as-needed"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": 2,
"space-after-keywords": [2, "always"],
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": 2
}
}
raw
node_modules
*.log
*.idea
*.swp
nyc_output
coverage
language: node_js
sudo: false
node_js:
- 0.8
- "0.8"
- "0.10"
- "0.12"
matrix:
include:
- node_js: "4.0"
env: BROWSER=true
before_install:
- npm install -g npm@2.6
- npm install -g karma-cli
before_script:
- npm install karma-sauce-launcher
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
script:
- npm test
- "[ $BROWSER == false ] || npm run test-browser"
- "[ $BROWSER == false ] || karma start karma.conf-sauce.js"
notifications:
email: false
env:
global:
- NPM_CONFIG_PROGRESS="false"
- secure: bDZSBQfqr21hCayjcZ20IxrV6+XGhxQPFIfwWqEKLrF93Gu8LLVjZRxXE/mE8I8N4Z5WtDNb4ZHrm/TTzmcPa5MuHgIxEdknQCncobH8oimwc83SHwEPk6okeNKl39VlCjvvnmoe/V/KpnknuYn3Rqghtl/Uv9KLpCwskwjTtcw=
- secure: SRECgXuwcZTcD3GVxTS2bYNgRyye4vq6BLrV2PH9FyNenowsKQR2EwlC/dppc1Q8NWMgv79J/R96q9JOFh+mEH9L5dlBb2yhnGH8amVeM/ChAJHT/F8YktKM453uVpz5fR00QcCQDDUOx6Pvx374ID0OKNpWKAkQBWA9mPTsLnE=
matrix: BROWSER=false
after_success: npm run coveralls
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at jashkenas@gmail.com. The project team
will review and investigate all complaints, and will respond in a way that it deems
appropriate to the circumstances. The project team is obligated to maintain
confidentiality with regard to the reporter of an incident.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Moderation
Edits of another user's comment must be clearly marked with "**edit**", the
moderator's username, and a timestamp for each occurrence. The only acceptable
reasons for editing another user's comment are:
1. to edit out violations of Our Pledge. These edits must include a rationale.
2. to direct future readers to a relevant point later in the conversation
(usually the resolution). These edits must be append-only.
Deletion of another user's comment is only acceptable when the comment includes
no original value, such as "+1", ":+1:", or "me too".
## Self-Moderation
Edits of your own comment after someone has responded must be append-only and
clearly marked with "**edit**". Typographical and formatting fixes to your own
comment which do not affect its meaning are exempt from this requirement.
Deletion of your own comment is only acceptable before any later comments have
been posted.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
## How to contribute to Underscore.js
* This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
* Before you open a ticket or send a pull request, [search](https://github.com/jashkenas/underscore/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
* If you're proposing a new feature, make sure it isn't already implemented in [Underscore-Contrib](https://github.com/documentcloud/underscore-contrib).
* Before sending a pull request for a feature, be sure to have [tests](http://underscorejs.org/test/).
* Use the same coding style as the rest of the [codebase](https://github.com/jashkenas/underscore/blob/master/underscore.js).
......
Copyright (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative
Copyright (c) 2009-2017 Jeremy Ashkenas, DocumentCloud and Investigative
Reporters & Editors
Permission is hereby granted, free of charge, to any person
......
......@@ -12,9 +12,15 @@ Underscore.js is a utility-belt library for JavaScript that provides
support for the usual functional suspects (each, map, reduce, filter...)
without extending any core JavaScript objects.
This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
For Docs, License, Tests, and pre-packed downloads, see:
http://underscorejs.org
For support and questions, please use
[the gitter channel](https://gitter.im/jashkenas/underscore)
or [stackoverflow](http://stackoverflow.com/search?q=underscore.js)
Underscore is an open-sourced component of DocumentCloud:
https://github.com/documentcloud
......
{
"name": "underscore",
"main": "underscore.js",
"keywords": ["util", "functional", "server", "client", "browser"],
"ignore" : ["docs", "test", "*.yml", "CNAME", "index.html", "favicon.ico", "CONTRIBUTING.md", ".*", "package.json", "karma.*"]
}
{
"globals": {
"_": true
}
}
......@@ -21,11 +21,11 @@
}
@font-face {
font-family: 'novecento-bold';
src: url('public/fonts/novecento-bold.eot');
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'),
url('public/fonts/novecento-bold.woff') format('woff'),
url('public/fonts/novecento-bold.ttf') format('truetype');
font-family: 'roboto-black';
src: url('public/fonts/roboto-black.eot');
src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'),
url('public/fonts/roboto-black.woff') format('woff'),
url('public/fonts/roboto-black.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
......@@ -51,15 +51,23 @@ b, strong {
font-family: "aller-bold";
}
p, ul, ol {
p {
margin: 15px 0 0px;
}
.annotation ul, .annotation ol {
margin: 25px 0;
}
.annotation ul li, .annotation ol li {
font-size: 14px;
line-height: 18px;
margin: 10px 0;
}
h1, h2, h3, h4, h5, h6 {
color: #112233;
line-height: 1em;
font-weight: normal;
font-family: "novecento-bold";
font-family: "roboto-black";
text-transform: uppercase;
margin: 30px 0 15px 0;
}
......@@ -67,10 +75,13 @@ h1, h2, h3, h4, h5, h6 {
h1 {
margin-top: 40px;
}
h2 {
font-size: 1.26em;
}
hr {
border: 0;
background: 1px solid #ddd;
background: 1px #ddd;
height: 1px;
margin: 20px 0;
}
......@@ -172,9 +183,18 @@ ul.sections > li > div {
display: block;
}
#jump_page_wrapper{
position: fixed;
right: 0;
top: 0;
bottom: 0;
}
#jump_page {
padding: 5px 0 3px;
margin: 0 0 25px 25px;
max-height: 100%;
overflow: auto;
}
#jump_page .source {
......@@ -205,7 +225,6 @@ ul.sections > li > div {
}
ul.sections > li > div.content {
background: #f5f5ff;
overflow-x:auto;
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
box-shadow: inset 0 0 5px #e5e5ee;
......@@ -306,7 +325,6 @@ ul.sections > li > div {
ul.sections > li > div.content {
padding: 13px;
vertical-align: top;
background: #f5f5ff;
border: none;
-webkit-box-shadow: none;
box-shadow: none;
......@@ -376,125 +394,125 @@ pre code {
background: #f8f8ff
}
pre .comment,
pre .template_comment,
pre .diff .header,
pre .javadoc {
pre .hljs-comment,
pre .hljs-template_comment,
pre .hljs-diff .hljs-header,
pre .hljs-javadoc {
color: #408080;
font-style: italic
}
pre .keyword,
pre .assignment,
pre .literal,
pre .css .rule .keyword,
pre .winutils,
pre .javascript .title,
pre .lisp .title,
pre .subst {
pre .hljs-keyword,
pre .hljs-assignment,
pre .hljs-literal,
pre .hljs-css .hljs-rule .hljs-keyword,
pre .hljs-winutils,
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
color: #954121;
/*font-weight: bold*/
}
pre .number,
pre .hexcolor {
pre .hljs-number,
pre .hljs-hexcolor {
color: #40a070
}
pre .string,
pre .tag .value,
pre .phpdoc,
pre .tex .formula {
pre .hljs-string,
pre .hljs-tag .hljs-value,
pre .hljs-phpdoc,
pre .hljs-tex .hljs-formula {
color: #219161;
}
pre .title,
pre .id {
pre .hljs-title,
pre .hljs-id {
color: #19469D;
}
pre .params {
pre .hljs-params {
color: #00F;
}
pre .javascript .title,
pre .lisp .title,
pre .subst {
pre .hljs-javascript .hljs-title,
pre .hljs-lisp .hljs-title,
pre .hljs-subst {
font-weight: normal
}
pre .class .title,
pre .haskell .label,
pre .tex .command {
pre .hljs-class .hljs-title,
pre .hljs-haskell .hljs-label,
pre .hljs-tex .hljs-command {
color: #458;
font-weight: bold
}
pre .tag,
pre .tag .title,
pre .rules .property,
pre .django .tag .keyword {
pre .hljs-tag,
pre .hljs-tag .hljs-title,
pre .hljs-rules .hljs-property,
pre .hljs-django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal
}
pre .attribute,
pre .variable,
pre .instancevar,
pre .lisp .body {
pre .hljs-attribute,
pre .hljs-variable,
pre .hljs-instancevar,
pre .hljs-lisp .hljs-body {
color: #008080
}
pre .regexp {
pre .hljs-regexp {
color: #B68
}
pre .class {
pre .hljs-class {
color: #458;
font-weight: bold
}
pre .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .lisp .keyword,
pre .tex .special,
pre .input_number {
pre .hljs-symbol,
pre .hljs-ruby .hljs-symbol .hljs-string,
pre .hljs-ruby .hljs-symbol .hljs-keyword,
pre .hljs-ruby .hljs-symbol .hljs-keymethods,
pre .hljs-lisp .hljs-keyword,
pre .hljs-tex .hljs-special,
pre .hljs-input_number {
color: #990073
}
pre .builtin,
pre .constructor,
pre .built_in,
pre .lisp .title {
pre .hljs-builtin,
pre .hljs-constructor,
pre .hljs-built_in,
pre .hljs-lisp .hljs-title {
color: #0086b3
}
pre .preprocessor,
pre .pi,
pre .doctype,
pre .shebang,
pre .cdata {
pre .hljs-preprocessor,
pre .hljs-pi,
pre .hljs-doctype,
pre .hljs-shebang,
pre .hljs-cdata {
color: #999;
font-weight: bold
}
pre .deletion {
pre .hljs-deletion {
background: #fdd
}
pre .addition {
pre .hljs-addition {
background: #dfd
}
pre .diff .change {
pre .hljs-diff .hljs-change {
background: #0086b3
}
pre .chunk {
pre .hljs-chunk {
color: #aaa
}
pre .tex .formula {
pre .hljs-tex .hljs-formula {
opacity: 0.5;
}
(function() {
var functions = document.querySelectorAll('[data-name]');
var sections = document.querySelectorAll('.searchable_section');
var searchInput = document.getElementById('function_filter');
function searchValue() {
return searchInput.value.trim().replace(/^_\.?/, '');
}
function strIn(a, b) {
a = a.toLowerCase();
b = b.toLowerCase();
return b.indexOf(a) >= 0;
}
function doesMatch(element) {
var name = element.getAttribute('data-name');
var aliases = element.getAttribute('data-aliases') || '';
var value = searchValue();
return strIn(value, name) || strIn(value, aliases);
}
function filterElement(element) {
element.style.display = doesMatch(element) ? '' : 'none';
}
function filterToc() {
_.each(functions, filterElement);
var emptySearch = searchValue() === '';
// Hide the titles of empty sections
_.each(sections, function(section) {
var sectionFunctions = section.querySelectorAll('[data-name]');
var showSection = emptySearch || _.some(sectionFunctions, doesMatch);
section.style.display = showSection ? '' : 'none';
});
}
function gotoFirst() {
var firstFunction = _.find(functions, doesMatch);
if (firstFunction) {
window.location.hash = firstFunction.getAttribute('data-name');
searchInput.focus();
}
}
searchInput.addEventListener('input', filterToc, false);
// Press "Enter" to jump to the first matching function
searchInput.addEventListener('keypress', function(e) {
if (e.which === 13) {
gotoFirst();
}
});
// Press "/" to search
document.body.addEventListener('keyup', function(event) {
if (191 === event.which) {
searchInput.focus();
}
});
}());
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
var _ = require('./');
// Browsers to run on Sauce Labs platforms
var sauceBrowsers = _.reduce([
['firefox', '35'],
['firefox', '30'],
['firefox', '21'],
['firefox', '11'],
['firefox', '4'],
['chrome', '40'],
['chrome', '39'],
['chrome', '31'],
['chrome', '26'],
['microsoftedge', '20.10240', 'Windows 10'],
['internet explorer', '11', 'Windows 10'],
['internet explorer', '10', 'Windows 8'],
['internet explorer', '9', 'Windows 7'],
// Currently disabled due to karma-sauce issues
// ['internet explorer', '8'],
// ['internet explorer', '7'],
// ['internet explorer', '6'],
['opera', '12'],
['opera', '11'],
['android', '5'],
['android', '4.4'],
['android', '4.3'],
['android', '4.0'],
['safari', '8.0', 'OS X 10.10'],
['safari', '7'],
['safari', '6'],
['safari', '5']
], function(memo, platform) {
// internet explorer -> ie
var label = platform[0].split(' ');
if (label.length > 1) {
label = _.invoke(label, 'charAt', 0)
}
label = (label.join("") + '_v' + platform[1]).replace(' ', '_').toUpperCase();
memo[label] = _.pick({
'base': 'SauceLabs',
'browserName': platform[0],
'version': platform[1],
'platform': platform[2]
}, Boolean);
return memo;
}, {});
module.exports = function(config) {
if ( !process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY ) {
console.log('Sauce environments not set --- Skipping');
return process.exit(0);
}
config.set({
basePath: '',
frameworks: ['qunit'],
singleRun: true,
// list of files / patterns to load in the browser
files: [
'test/vendor/qunit-extras.js',
'test/qunit-setup.js',
'underscore.js',
'test/*.js'
],
// Number of sauce tests to start in parallel
concurrency: 9,
// test results reporter to use
reporters: ['dots', 'saucelabs'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
sauceLabs: {
build: 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')',
startConnect: true,
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
},
captureTimeout: 120000,
customLaunchers: sauceBrowsers,
// Browsers to launch, commented out to prevent karma from starting
// too many concurrent browsers and timing sauce out.
browsers: _.keys(sauceBrowsers)
});
};
// Note some browser launchers should be installed before using karma start.
// For example:
// $ npm install karma-firefox-launcher
// $ karma start --browser=Firefox
// See http://karma-runner.github.io/0.8/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['qunit'],
logLevel: config.LOG_INFO,
port: 9876,
// list of files / patterns to load in the browser
files: [
'test/vendor/qunit-extras.js',
'test/qunit-setup.js',
'underscore.js',
'test/*.js'
],
// Test results reporter to use
// https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['PhantomJS'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};
\ No newline at end of file
{
"name" : "underscore",
"description" : "JavaScript's functional programming helper library.",
"homepage" : "http://underscorejs.org",
"keywords" : ["util", "functional", "server", "client", "browser"],
"author" : "Jeremy Ashkenas <jeremy@documentcloud.org>",
"repository" : {"type": "git", "url": "git://github.com/jashkenas/underscore.git"},
"main" : "underscore.js",
"version" : "1.5.2",
"name": "underscore",
"description": "JavaScript's functional programming helper library.",
"homepage": "http://underscorejs.org",
"keywords": [
"util",
"functional",
"server",
"client",
"browser"
],
"author": "Jeremy Ashkenas <jeremy@documentcloud.org>",
"repository": {
"type": "git",
"url": "git://github.com/jashkenas/underscore.git"
},
"main": "underscore.js",
"version": "1.8.3",
"devDependencies": {
"phantomjs": "1.9.0-1"
"coveralls": "^2.11.2",
"docco": "*",
"eslint": "1.10.x",
"gzip-size-cli": "^1.0.0",
"karma": "^0.13.13",
"karma-qunit": "~0.1.4",
"nyc": "^2.1.3",
"pretty-bytes-cli": "^1.0.0",
"qunit-cli": "~0.2.0",
"qunitjs": "^1.18.0",
"uglify-js": "2.4.x"
},
"scripts": {
"test": "phantomjs test/vendor/runner.js test/index.html?noglobals=true"
"test": "npm run test-node && npm run lint",
"coverage": "nyc npm run test-node && nyc report",
"coveralls": "nyc npm run test-node && nyc report --reporter=text-lcov | coveralls",
"lint": "eslint underscore.js test/*.js",
"test-node": "qunit-cli test/*.js",
"test-browser": "npm i karma-phantomjs-launcher && karma start",
"minify": "uglifyjs underscore.js -c \"evaluate=false\" --comments \"/ .*/\" -m",
"build": "npm run minify -- --source-map underscore-min.map --source-map-url \" \" -o underscore-min.js",
"doc": "docco underscore.js",
"weight": "npm run minify | gzip-size | pretty-bytes"
},
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/jashkenas/underscore/master/LICENSE"
}
],
"files" : ["underscore.js", "underscore-min.js", "LICENSE"]
"license": "MIT",
"files": [
"underscore.js",
"underscore-min.js",
"underscore-min.map"
]
}
{
"env": {
"browser": true
},
"globals": {
"QUnit": false
},
"rules": {
"brace-style": 0,
"no-new-wrappers": 0,
"no-extend-native": 0
}
}
This diff is collapsed.
$(document).ready(function() {
(function() {
var _ = typeof require == 'function' ? require('..') : window._;
module("Chaining");
QUnit.module('Chaining');
test("map/flatten/reduce", function() {
QUnit.test('map/flatten/reduce', function(assert) {
var lyrics = [
"I'm a lumberjack and I'm okay",
"I sleep all night and I work all day",
"He's a lumberjack and he's okay",
"He sleeps all night and he works all day"
'I\'m a lumberjack and I\'m okay',
'I sleep all night and I work all day',
'He\'s a lumberjack and he\'s okay',
'He sleeps all night and he works all day'
];
var counts = _(lyrics).chain()
.map(function(line) { return line.split(''); })
......@@ -16,12 +17,14 @@ $(document).ready(function() {
hash[l] = hash[l] || 0;
hash[l]++;
return hash;
}, {}).value();
ok(counts.a == 16 && counts.e == 10, 'counted all the letters in the song');
}, {})
.value();
assert.strictEqual(counts.a, 16, 'counted all the letters in the song');
assert.strictEqual(counts.e, 10, 'counted all the letters in the song');
});
test("select/reject/sortBy", function() {
var numbers = [1,2,3,4,5,6,7,8,9,10];
QUnit.test('select/reject/sortBy', function(assert) {
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
numbers = _(numbers).chain().select(function(n) {
return n % 2 === 0;
}).reject(function(n) {
......@@ -29,11 +32,11 @@ $(document).ready(function() {
}).sortBy(function(n) {
return -n;
}).value();
equal(numbers.join(', '), "10, 6, 2", "filtered and reversed the numbers");
assert.deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
});
test("select/reject/sortBy in functional style", function() {
var numbers = [1,2,3,4,5,6,7,8,9,10];
QUnit.test('select/reject/sortBy in functional style', function(assert) {
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
numbers = _.chain(numbers).select(function(n) {
return n % 2 === 0;
}).reject(function(n) {
......@@ -41,11 +44,11 @@ $(document).ready(function() {
}).sortBy(function(n) {
return -n;
}).value();
equal(numbers.join(', '), "10, 6, 2", "filtered and reversed the numbers");
assert.deepEqual(numbers, [10, 6, 2], 'filtered and reversed the numbers');
});
test("reverse/concat/unshift/pop/map", function() {
var numbers = [1,2,3,4,5];
QUnit.test('reverse/concat/unshift/pop/map', function(assert) {
var numbers = [1, 2, 3, 4, 5];
numbers = _(numbers).chain()
.reverse()
.concat([5, 5, 5])
......@@ -53,13 +56,44 @@ $(document).ready(function() {
.pop()
.map(function(n){ return n * 2; })
.value();
equal(numbers.join(', '), "34, 10, 8, 6, 4, 2, 10, 10", 'can chain together array functions.');
assert.deepEqual(numbers, [34, 10, 8, 6, 4, 2, 10, 10], 'can chain together array functions.');
});
QUnit.test('splice', function(assert) {
var instance = _([1, 2, 3, 4, 5]).chain();
assert.deepEqual(instance.splice(1, 3).value(), [1, 5]);
assert.deepEqual(instance.splice(1, 0).value(), [1, 5]);
assert.deepEqual(instance.splice(1, 1).value(), [1]);
assert.deepEqual(instance.splice(0, 1).value(), [], '#397 Can create empty array');
});
QUnit.test('shift', function(assert) {
var instance = _([1, 2, 3]).chain();
assert.deepEqual(instance.shift().value(), [2, 3]);
assert.deepEqual(instance.shift().value(), [3]);
assert.deepEqual(instance.shift().value(), [], '#397 Can create empty array');
});
test("chaining works in small stages", function() {
QUnit.test('pop', function(assert) {
var instance = _([1, 2, 3]).chain();
assert.deepEqual(instance.pop().value(), [1, 2]);
assert.deepEqual(instance.pop().value(), [1]);
assert.deepEqual(instance.pop().value(), [], '#397 Can create empty array');
});
QUnit.test('chaining works in small stages', function(assert) {
var o = _([1, 2, 3, 4]).chain();
deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
assert.deepEqual(o.filter(function(i) { return i < 3; }).value(), [1, 2]);
assert.deepEqual(o.filter(function(i) { return i > 2; }).value(), [3, 4]);
});
QUnit.test('#1562: Engine proxies for chained functions', function(assert) {
var wrapped = _(512);
assert.strictEqual(wrapped.toJSON(), 512);
assert.strictEqual(wrapped.valueOf(), 512);
assert.strictEqual(+wrapped, 512);
assert.strictEqual(wrapped.toString(), '512');
assert.strictEqual('' + wrapped, '512');
});
});
}());
This diff is collapsed.
(function() {
if (typeof document == 'undefined') return;
var _ = typeof require == 'function' ? require('..') : window._;
QUnit.module('Cross Document');
/* global iObject, iElement, iArguments, iFunction, iArray, iError, iString, iNumber, iBoolean, iDate, iRegExp, iNaN, iNull, iUndefined, ActiveXObject */
// Setup remote variables for iFrame tests.
var iframe = document.createElement('iframe');
iframe.frameBorder = iframe.height = iframe.width = 0;
document.body.appendChild(iframe);
var iframeContent = iframe.contentDocument || iframe.contentWindow;
var iDoc = iframeContent.document || iframeContent;
iDoc.write(
[
'<script>',
'parent.iElement = document.createElement("div");',
'parent.iArguments = (function(){ return arguments; })(1, 2, 3);',
'parent.iArray = [1, 2, 3];',
'parent.iString = new String("hello");',
'parent.iNumber = new Number(100);',
'parent.iFunction = (function(){});',
'parent.iDate = new Date();',
'parent.iRegExp = /hi/;',
'parent.iNaN = NaN;',
'parent.iNull = null;',
'parent.iBoolean = new Boolean(false);',
'parent.iUndefined = undefined;',
'parent.iObject = {};',
'parent.iError = new Error();',
'</script>'
].join('\n')
);
iDoc.close();
QUnit.test('isEqual', function(assert) {
assert.notOk(_.isEqual(iNumber, 101));
assert.ok(_.isEqual(iNumber, 100));
// Objects from another frame.
assert.ok(_.isEqual({}, iObject), 'Objects with equivalent members created in different documents are equal');
// Array from another frame.
assert.ok(_.isEqual([1, 2, 3], iArray), 'Arrays with equivalent elements created in different documents are equal');
});
QUnit.test('isEmpty', function(assert) {
assert.notOk(_([iNumber]).isEmpty(), '[1] is not empty');
assert.notOk(_.isEmpty(iArray), '[] is empty');
assert.ok(_.isEmpty(iObject), '{} is empty');
});
QUnit.test('isElement', function(assert) {
assert.notOk(_.isElement('div'), 'strings are not dom elements');
assert.ok(_.isElement(document.body), 'the body tag is a DOM element');
assert.ok(_.isElement(iElement), 'even from another frame');
});
QUnit.test('isArguments', function(assert) {
assert.ok(_.isArguments(iArguments), 'even from another frame');
});
QUnit.test('isObject', function(assert) {
assert.ok(_.isObject(iElement), 'even from another frame');
assert.ok(_.isObject(iFunction), 'even from another frame');
});
QUnit.test('isArray', function(assert) {
assert.ok(_.isArray(iArray), 'even from another frame');
});
QUnit.test('isString', function(assert) {
assert.ok(_.isString(iString), 'even from another frame');
});
QUnit.test('isNumber', function(assert) {
assert.ok(_.isNumber(iNumber), 'even from another frame');
});
QUnit.test('isBoolean', function(assert) {
assert.ok(_.isBoolean(iBoolean), 'even from another frame');
});
QUnit.test('isFunction', function(assert) {
assert.ok(_.isFunction(iFunction), 'even from another frame');
});
QUnit.test('isDate', function(assert) {
assert.ok(_.isDate(iDate), 'even from another frame');
});
QUnit.test('isRegExp', function(assert) {
assert.ok(_.isRegExp(iRegExp), 'even from another frame');
});
QUnit.test('isNaN', function(assert) {
assert.ok(_.isNaN(iNaN), 'even from another frame');
});
QUnit.test('isNull', function(assert) {
assert.ok(_.isNull(iNull), 'even from another frame');
});
QUnit.test('isUndefined', function(assert) {
assert.ok(_.isUndefined(iUndefined), 'even from another frame');
});
QUnit.test('isError', function(assert) {
assert.ok(_.isError(iError), 'even from another frame');
});
if (typeof ActiveXObject != 'undefined') {
QUnit.test('IE host objects', function(assert) {
var xml = new ActiveXObject('Msxml2.DOMDocument.3.0');
assert.notOk(_.isNumber(xml));
assert.notOk(_.isBoolean(xml));
assert.notOk(_.isNaN(xml));
assert.notOk(_.isFunction(xml));
assert.notOk(_.isNull(xml));
assert.notOk(_.isUndefined(xml));
});
QUnit.test('#1621 IE 11 compat mode DOM elements are not functions', function(assert) {
var fn = function() {};
var xml = new ActiveXObject('Msxml2.DOMDocument.3.0');
var div = document.createElement('div');
// JIT the function
var count = 200;
while (count--) {
_.isFunction(fn);
}
assert.strictEqual(_.isFunction(xml), false);
assert.strictEqual(_.isFunction(div), false);
assert.strictEqual(_.isFunction(fn), true);
});
}
}());
This diff is collapsed.
......@@ -3,42 +3,21 @@
<head>
<title>Underscore Test Suite</title>
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen">
<script src="vendor/jquery.js"></script>
<link rel="icon" href="../favicon.ico">
</head>
<body>
<div id="qunit"></div>
<div id="exports" style="display: none"></div>
<script src="vendor/qunit.js"></script>
<script src="vendor/jslitmus.js"></script>
<script src="vendor/qunit-extras.js"></script>
<script src="../underscore.js"></script>
<script src="qunit-setup.js"></script>
<script src="collections.js"></script>
<script src="arrays.js"></script>
<script src="functions.js"></script>
<script src="objects.js"></script>
<script src="cross-document.js"></script>
<script src="utility.js"></script>
<script src="chaining.js"></script>
<script src="speed.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<div id="map-test">
<div id="id1"></div>
<div id="id2"></div>
</div>
</div>
<br>
<h1 class="qunit-header">Underscore Speed Suite</h1>
<p>
A representative sample of the functions are benchmarked here, to provide
a sense of how fast they might run in different browsers.
Each iteration runs on an array of 1000 elements.<br /><br />
For example, the 'intersection' test measures the number of times you can
find the intersection of two thousand-element arrays in one second.
</p>
<br>
<script type="text/html" id="template">
<%
// a comment
if (data) { data += 12345; }; %>
<li><%= data %></li>
</script>
</body>
</html>
This diff is collapsed.
(function() {
QUnit.config.noglobals = true;
}());
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* QUnit v1.12.0 - A JavaScript Unit Testing Framework
/*!
* QUnit 1.18.0
* http://qunitjs.com/
*
* http://qunitjs.com
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license.
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2015-04-03T10:23Z
*/
/** Font Family and Sizes */
......@@ -31,32 +32,29 @@
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
color: #8699A4;
background-color: #0D3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
font-weight: 400;
border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
color: #C2CCD1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
color: #FFF;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 .5em 0 .1em;
padding: 0 0.5em 0 0.1em;
}
#qunit-banner {
......@@ -64,21 +62,33 @@
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #eee;
background-color: #EEE;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
padding: 0.5em 1em 0.5em 1em;
background-color: #2B81AF;
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
padding: 0.2em;
}
.qunit-url-config {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
float: right;
margin-left: 1em;
}
/** Tests: Pass/Fail */
......@@ -88,24 +98,51 @@
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
visibility: hidden;
position: absolute;
width: 0px;
height: 0px;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
......@@ -120,11 +157,9 @@
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
background-color: #FFF;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.qunit-collapsed {
......@@ -133,13 +168,13 @@
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
margin-top: 0.2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
padding: 0 0.5em 0 0;
}
#qunit-tests td {
......@@ -153,26 +188,26 @@
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
background-color: #E0F2BE;
color: #374E0C;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
background-color: #FFCACA;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.counts { color: #000; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #fff;
background-color: #FFF;
border-bottom: none;
list-style-position: inside;
}
......@@ -180,8 +215,8 @@
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3c510c;
background-color: #fff;
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
......@@ -189,7 +224,7 @@
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
......@@ -197,40 +232,52 @@
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
background-color: #FFF;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
padding: 0.5em 1em 0.5em 1em;
color: #2b81af;
color: #2B81AF;
background-color: #D2E0E6;
border-bottom: 1px solid white;
border-bottom: 1px solid #FFF;
}
#qunit-testresult .module-name {
font-weight: bold;
font-weight: 700;
}
/** Fixture */
......
This diff is collapsed.
/*
* QtWebKit-powered headless test runner using PhantomJS
*
* PhantomJS binaries: http://phantomjs.org/download.html
* Requires PhantomJS 1.6+ (1.7+ recommended)
*
* Run with:
* phantomjs runner.js [url-of-your-qunit-testsuite]
*
* e.g.
* phantomjs runner.js http://localhost/qunit/test/index.html
*/
/*jshint latedef:false */
/*global phantom:false, require:false, console:false, window:false, QUnit:false */
(function() {
'use strict';
var args = require('system').args;
// arg[0]: scriptName, args[1...]: arguments
if (args.length !== 2) {
console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite]');
phantom.exit(1);
}
var url = args[1],
page = require('webpage').create();
// Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`)
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.onInitialized = function() {
page.evaluate(addLogging);
};
page.onCallback = function(message) {
var result,
failed;
if (message) {
if (message.name === 'QUnit.done') {
result = message.data;
failed = !result || result.failed;
phantom.exit(failed ? 1 : 0);
}
}
};
page.open(url, function(status) {
if (status !== 'success') {
console.error('Unable to access network: ' + status);
phantom.exit(1);
} else {
// Cannot do this verification with the 'DOMContentLoaded' handler because it
// will be too late to attach it if a page does not have any script tags.
var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); });
if (qunitMissing) {
console.error('The `QUnit` object is not present on this page.');
phantom.exit(1);
}
// Do nothing... the callback mechanism will handle everything!
}
});
function addLogging() {
window.document.addEventListener('DOMContentLoaded', function() {
var current_test_assertions = [];
QUnit.log(function(details) {
var response;
// Ignore passing assertions
if (details.result) {
return;
}
response = details.message || '';
if (typeof details.expected !== 'undefined') {
if (response) {
response += ', ';
}
response += 'expected: ' + details.expected + ', but was: ' + details.actual;
if (details.source) {
response += "\n" + details.source;
}
}
current_test_assertions.push('Failed assertion: ' + response);
});
QUnit.testDone(function(result) {
var i,
len,
name = result.module + ': ' + result.name;
if (result.failed) {
console.log('Test failed: ' + name);
for (i = 0, len = current_test_assertions.length; i < len; i++) {
console.log(' ' + current_test_assertions[i]);
}
}
current_test_assertions.length = 0;
});
QUnit.done(function(result) {
console.log('Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
if (typeof window.callPhantom === 'function') {
window.callPhantom({
'name': 'QUnit.done',
'data': result
});
}
});
}, false);
}
})();
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment