content_type stringclasses 8 values | main_lang stringclasses 7 values | message stringlengths 1 50 | sha stringlengths 40 40 | patch stringlengths 52 962k | file_count int64 1 300 |
|---|---|---|---|---|---|
Javascript | Javascript | add async/await support to parser | fc8b1d348dcd3a49786b0f367c8cac3eb97f5bf6 | <ide><path>lib/Parser.js
<ide> Parser.prototype.walkExpression = function walkExpression(expression) {
<ide> return this["walk" + expression.type](expression);
<ide> };
<ide>
<add>Parser.prototype.walkAwaitExpression = function walkAwaitExpression(expression) {
<add> var argument = expression.argument
<add> if(this["walk" + argument.type])
<add> return this["walk" + argument.type](argument);
<add>}
<add>
<ide> Parser.prototype.walkArrayExpression = function walkArrayExpression(expression) {
<ide> if(expression.elements)
<ide> this.walkExpressions(expression.elements);
<ide> Parser.prototype.parseCalculatedString = function parseCalculatedString(expressi
<ide> var POSSIBLE_AST_OPTIONS = [{
<ide> ranges: true,
<ide> locations: true,
<del> ecmaVersion: 6,
<add> ecmaVersion: 2017,
<ide> sourceType: "module"
<ide> }, {
<ide> ranges: true,
<ide> locations: true,
<del> ecmaVersion: 6,
<add> ecmaVersion: 2017,
<ide> sourceType: "script"
<ide> }]
<ide>
<ide> Parser.prototype.parse = function parse(source, initialState) {
<ide> ast = acorn.parse(source, {
<ide> ranges: true,
<ide> locations: true,
<del> ecmaVersion: 6,
<add> ecmaVersion: 2017,
<ide> sourceType: "module",
<ide> onComment: comments
<ide> });
<ide> Parser.prototype.evaluate = function evaluate(source) {
<ide> var ast = acorn.parse("(" + source + ")", {
<ide> ranges: true,
<ide> locations: true,
<del> ecmaVersion: 6,
<add> ecmaVersion: 2017,
<ide> sourceType: "module"
<ide> });
<ide> if(!ast || typeof ast !== "object" || ast.type !== "Program")
<ide><path>test/Parser.test.js
<ide> describe("Parser", function() {
<ide> });
<ide> });
<ide> });
<add>
<add> describe("async/await support", function() {
<add> describe("should accept", function() {
<add> var cases = {
<add> "async function": "async function x() {}",
<add> "async arrow function": "async () => {}",
<add> "await expression": "async function x(y) { await y }"
<add> };
<add> var parser = new Parser();
<add> Object.keys(cases).forEach(function(name) {
<add> var expr = cases[name];
<add> it(name, function() {
<add> var actual = parser.parse(expr);
<add> should.strictEqual(typeof actual, "object");
<add> });
<add> });
<add> });
<add> describe("should parse await", function() {
<add> var cases = {
<add> "require": [
<add> "async function x() { await require('y'); }", {
<add> param: "y"
<add> }
<add> ],
<add> "System.import": [
<add> "async function x() { var y = await System.import('z'); }", {
<add> param: "z"
<add> }
<add> ]
<add> };
<add>
<add> var parser = new Parser();
<add> parser.plugin("call require", function(expr) {
<add> var param = this.evaluateExpression(expr.arguments[0]);
<add> this.state.param = param.string;
<add> });
<add> parser.plugin("call System.import", function(expr) {
<add> var param = this.evaluateExpression(expr.arguments[0]);
<add> this.state.param = param.string;
<add> });
<add>
<add> Object.keys(cases).forEach(function(name) {
<add> it(name, function() {
<add> var actual = parser.parse(cases[name][0]);
<add> actual.should.be.eql(cases[name][1]);
<add> });
<add> });
<add> });
<add> })
<ide> }); | 2 |
Javascript | Javascript | use regex to test | 474fd78d229508fa56aa6f790fc408973935250d | <ide><path>src/extras/ImageUtils.js
<ide> const ImageUtils = {
<ide> let canvas;
<ide>
<ide> var src = image.src;
<del> if ( src[ 0 ] === "d" && src[ 1 ] === "a" && src[ 2 ] === "t" && src[ 3 ] === "a" && src[ 4 ] === ":" ) {
<add> if ( /^data:/i.test( src ) ) {
<ide>
<ide> return image.src;
<ide> | 1 |
Python | Python | use copy to move the masked values into the result | ad902ff2e3b2be2bc33b65e6eaef857a2d3b5e6b | <ide><path>numpy/ma/core.py
<ide> def __call__ (self, a, b, *args, **kwargs):
<ide> return result
<ide> # Case 2. : array
<ide> # Revert result to da where masked
<del> if m.any():
<del> np.copyto(result, 0, casting='unsafe', where=m)
<del> # This only makes sense if the operation preserved the dtype
<del> if result.dtype == da.dtype:
<del> result += m * da
<add> if m is not np.ma.nomask:
<add> np.copyto(result, da, casting='unsafe', where=m)
<ide> # Transforms to a (subclass of) MaskedArray
<ide> result = result.view(get_masked_subclass(a, b))
<ide> result._mask = m
<ide> def __call__(self, a, b, *args, **kwargs):
<ide> else:
<ide> return result
<ide> # When the mask is True, put back da
<del> np.copyto(result, 0, casting='unsafe', where=m)
<del> result += m * da
<add> np.copyto(result, da, casting='unsafe', where=m)
<ide> result = result.view(get_masked_subclass(a, b))
<ide> result._mask = m
<ide> if isinstance(b, MaskedArray): | 1 |
Text | Text | credit the author of in the previous commit | 850d313c3bd8267ef08c4fdfedbdb510cc419721 | <ide><path>activerecord/CHANGELOG.md
<ide>
<ide> Fixes #20515.
<ide>
<del> *Sean Griffin*
<add> *Sean Griffin & jmondo*
<ide>
<ide> * Deprecate the PG `:point` type in favor of a new one which will return
<ide> `Point` objects instead of an `Array` | 1 |
Python | Python | add custom warning when run_command fails | 60f97bc519ecf607f7711c3ae0402f89d939989b | <ide><path>spacy/errors.py
<ide> class Errors(object):
<ide> E199 = ("Unable to merge 0-length span at doc[{start}:{end}].")
<ide>
<ide> # TODO: fix numbering after merging develop into master
<add> E970 = ("Can not execute command '{str_command}'. Do you have '{tool}' installed?")
<ide> E971 = ("Found incompatible lengths in Doc.from_array: {array_length} for the "
<ide> "array and {doc_length} for the Doc itself.")
<ide> E972 = ("Example.__init__ got None for '{arg}'. Requires Doc.")
<ide><path>spacy/util.py
<ide> def run_command(command: Union[str, List[str]]) -> None:
<ide> """
<ide> if isinstance(command, str):
<ide> command = split_command(command)
<del> status = subprocess.call(command, env=os.environ.copy())
<add> try:
<add> status = subprocess.call(command, env=os.environ.copy())
<add> except FileNotFoundError:
<add> raise FileNotFoundError(
<add> Errors.E970.format(str_command=" ".join(command), tool=command[0])
<add> )
<ide> if status != 0:
<ide> sys.exit(status)
<ide> | 2 |
Python | Python | remove "ista" from portuguese stop words | c1d020b0a68630bbc9950b09ad72ba38ee1c749f | <ide><path>spacy/pt/stop_words.py
<ide>
<ide> hoje horas há
<ide>
<del>iniciar inicio ir irá isso ista isto já
<add>iniciar inicio ir irá isso isto já
<ide>
<ide> lado ligado local logo longe lugar lá
<ide> | 1 |
Python | Python | apply patch to fix ticket | 18c907f73b760346855351c88562aaf4edf0013f | <ide><path>numpy/core/tests/test_regression.py
<ide> def test_buffer_hashlib(self):
<ide> except ImportError:
<ide> from md5 import new as md5
<ide>
<del> x = np.array([1,2,3], dtype=np.int32)
<add> x = np.array([1,2,3], dtype=np.dtype('<i4'))
<ide> assert_equal(md5(x).hexdigest(), '2a1dd1e1e59d0a384c26951e316cd7e6')
<ide>
<ide> if __name__ == "__main__": | 1 |
Python | Python | fix authorization few perms tests | 79c1f2154adfbb13fa5d7e24e9624afa41652a6c | <ide><path>tests/test_permissions.py
<ide> def test_empty_view_does_not_assert(self):
<ide> self.assertEqual(response.status_code, status.HTTP_200_OK)
<ide>
<ide> def test_calling_method_not_allowed(self):
<del> request = factory.generic('METHOD_NOT_ALLOWED', '/')
<add> request = factory.generic('METHOD_NOT_ALLOWED', '/', HTTP_AUTHORIZATION=self.permitted_credentials)
<ide> response = root_view(request)
<ide> self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
<ide>
<del> request = factory.generic('METHOD_NOT_ALLOWED', '/1')
<add> request = factory.generic('METHOD_NOT_ALLOWED', '/1', HTTP_AUTHORIZATION=self.permitted_credentials)
<ide> response = instance_view(request, pk='1')
<ide> self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
<ide>
<ide> def test_cannot_read_list_permissions(self):
<ide> self.assertListEqual(response.data, [])
<ide>
<ide> def test_cannot_method_not_allowed(self):
<del> request = factory.generic('METHOD_NOT_ALLOWED', '/')
<add> request = factory.generic('METHOD_NOT_ALLOWED', '/', HTTP_AUTHORIZATION=self.credentials['readonly'])
<ide> response = object_permissions_list_view(request)
<ide> self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
<ide> | 1 |
Text | Text | add legendecas to tsc list | 325f54966e6cd85a123448af68c04b5d1a55b663 | <ide><path>README.md
<ide> For information about the governance of the Node.js project, see
<ide> **James M Snell** <<jasnell@gmail.com>> (he/him)
<ide> * [joyeecheung](https://github.com/joyeecheung) -
<ide> **Joyee Cheung** <<joyeec9h3@gmail.com>> (she/her)
<add>* [legendecas](https://github.com/legendecas) -
<add> **Chengzhong Wu** <<legendecas@gmail.com>> (he/him)
<ide> * [mcollina](https://github.com/mcollina) -
<ide> **Matteo Collina** <<matteo.collina@gmail.com>> (he/him)
<ide> * [mhdawson](https://github.com/mhdawson) - | 1 |
Javascript | Javascript | add test for writable.write() argument types | 6ea51bc4918c05e293c30d5efc384a15ae6cfd7e | <ide><path>test/parallel/test-stream-writable-invalid-chunk.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>const stream = require('stream');
<add>
<add>function testWriteType(val, objectMode, code) {
<add> const writable = new stream.Writable({
<add> objectMode,
<add> write: () => {}
<add> });
<add> if (!code) {
<add> writable.on('error', common.mustNotCall());
<add> } else {
<add> writable.on('error', common.expectsError({
<add> code: code,
<add> }));
<add> }
<add> writable.write(val);
<add>}
<add>
<add>testWriteType([], false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType({}, false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType(0, false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType(true, false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType(0.0, false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType(undefined, false, 'ERR_INVALID_ARG_TYPE');
<add>testWriteType(null, false, 'ERR_STREAM_NULL_VALUES');
<add>
<add>testWriteType([], true);
<add>testWriteType({}, true);
<add>testWriteType(0, true);
<add>testWriteType(true, true);
<add>testWriteType(0.0, true);
<add>testWriteType(undefined, true);
<add>testWriteType(null, true, 'ERR_STREAM_NULL_VALUES'); | 1 |
PHP | PHP | fix use of deprecated string interpolation | dd1e721607fd04e36602681aafa56c55c91d717f | <ide><path>src/Routing/RouteCollection.php
<ide> protected function _getNames(array $url): array
<ide> $action = strtolower($url['action']);
<ide>
<ide> $names = [
<del> "${controller}:${action}",
<del> "${controller}:_action",
<del> "_controller:${action}",
<add> "{$controller}:{$action}",
<add> "{$controller}:_action",
<add> "_controller:{$action}",
<ide> '_controller:_action',
<ide> ];
<ide>
<ide> protected function _getNames(array $url): array
<ide> // Only a plugin
<ide> if ($prefix === false) {
<ide> return [
<del> "${plugin}.${controller}:${action}",
<del> "${plugin}.${controller}:_action",
<del> "${plugin}._controller:${action}",
<del> "${plugin}._controller:_action",
<del> "_plugin.${controller}:${action}",
<del> "_plugin.${controller}:_action",
<del> "_plugin._controller:${action}",
<add> "{$plugin}.{$controller}:{$action}",
<add> "{$plugin}.{$controller}:_action",
<add> "{$plugin}._controller:{$action}",
<add> "{$plugin}._controller:_action",
<add> "_plugin.{$controller}:{$action}",
<add> "_plugin.{$controller}:_action",
<add> "_plugin._controller:{$action}",
<ide> '_plugin._controller:_action',
<ide> ];
<ide> }
<ide>
<ide> // Only a prefix
<ide> if ($plugin === false) {
<ide> return [
<del> "${prefix}:${controller}:${action}",
<del> "${prefix}:${controller}:_action",
<del> "${prefix}:_controller:${action}",
<del> "${prefix}:_controller:_action",
<del> "_prefix:${controller}:${action}",
<del> "_prefix:${controller}:_action",
<del> "_prefix:_controller:${action}",
<add> "{$prefix}:{$controller}:{$action}",
<add> "{$prefix}:{$controller}:_action",
<add> "{$prefix}:_controller:{$action}",
<add> "{$prefix}:_controller:_action",
<add> "_prefix:{$controller}:{$action}",
<add> "_prefix:{$controller}:_action",
<add> "_prefix:_controller:{$action}",
<ide> '_prefix:_controller:_action',
<ide> ];
<ide> }
<ide>
<ide> // Prefix and plugin has the most options
<ide> // as there are 4 factors.
<ide> return [
<del> "${prefix}:${plugin}.${controller}:${action}",
<del> "${prefix}:${plugin}.${controller}:_action",
<del> "${prefix}:${plugin}._controller:${action}",
<del> "${prefix}:${plugin}._controller:_action",
<del> "${prefix}:_plugin.${controller}:${action}",
<del> "${prefix}:_plugin.${controller}:_action",
<del> "${prefix}:_plugin._controller:${action}",
<del> "${prefix}:_plugin._controller:_action",
<del> "_prefix:${plugin}.${controller}:${action}",
<del> "_prefix:${plugin}.${controller}:_action",
<del> "_prefix:${plugin}._controller:${action}",
<del> "_prefix:${plugin}._controller:_action",
<del> "_prefix:_plugin.${controller}:${action}",
<del> "_prefix:_plugin.${controller}:_action",
<del> "_prefix:_plugin._controller:${action}",
<add> "{$prefix}:{$plugin}.{$controller}:{$action}",
<add> "{$prefix}:{$plugin}.{$controller}:_action",
<add> "{$prefix}:{$plugin}._controller:{$action}",
<add> "{$prefix}:{$plugin}._controller:_action",
<add> "{$prefix}:_plugin.{$controller}:{$action}",
<add> "{$prefix}:_plugin.{$controller}:_action",
<add> "{$prefix}:_plugin._controller:{$action}",
<add> "{$prefix}:_plugin._controller:_action",
<add> "_prefix:{$plugin}.{$controller}:{$action}",
<add> "_prefix:{$plugin}.{$controller}:_action",
<add> "_prefix:{$plugin}._controller:{$action}",
<add> "_prefix:{$plugin}._controller:_action",
<add> "_prefix:_plugin.{$controller}:{$action}",
<add> "_prefix:_plugin.{$controller}:_action",
<add> "_prefix:_plugin._controller:{$action}",
<ide> '_prefix:_plugin._controller:_action',
<ide> ];
<ide> }
<ide><path>tests/TestCase/Console/ShellTest.php
<ide> public function testCreateFileNonInteractive(): void
<ide>
<ide> $this->fs->mkdir($path);
<ide>
<del> $contents = "<?php{$eol}echo 'test';${eol}\$te = 'st';{$eol}";
<add> $contents = "<?php{$eol}echo 'test';{$eol}\$te = 'st';{$eol}";
<ide>
<ide> $this->Shell->interactive = false;
<ide> $result = $this->Shell->createFile($file, $contents);
<ide> public function testCreateFileNonInteractiveFileExists(): void
<ide>
<ide> $this->fs->mkdir($path);
<ide>
<del> $contents = "<?php{$eol}echo 'test';${eol}\$te = 'st';{$eol}";
<add> $contents = "<?php{$eol}echo 'test';{$eol}\$te = 'st';{$eol}";
<ide> $this->Shell->interactive = false;
<ide> $result = $this->Shell->createFile($file, $contents);
<ide> $this->assertFalse($result);
<ide><path>tests/TestCase/Database/QueryTest.php
<ide> public function testStringExpression(): void
<ide> if ($driver instanceof Postgres) {
<ide> // Older postgres versions throw an error on the parameter type without a cast
<ide> $query->select(['test_string' => $query->func()->cast(new StringExpression('testString', $collation), 'text')]);
<del> $expected = "SELECT \(CAST\(:c0 COLLATE \"${collation}\" AS text\)\) AS <test_string>";
<add> $expected = "SELECT \(CAST\(:c0 COLLATE \"{$collation}\" AS text\)\) AS <test_string>";
<ide> } else {
<ide> $query->select(['test_string' => new StringExpression('testString', $collation)]);
<del> $expected = "SELECT \(:c0 COLLATE ${collation}\) AS <test_string>";
<add> $expected = "SELECT \(:c0 COLLATE {$collation}\) AS <test_string>";
<ide> }
<ide> $this->assertRegExpSql($expected, $query->sql(new ValueBinder()), !$this->autoQuote);
<ide>
<ide> public function testIdentifierCollation(): void
<ide>
<ide> if ($driver instanceof Postgres) {
<ide> // Older postgres versions throw an error on the parameter type without a cast
<del> $expected = "SELECT \(<title> COLLATE \"${collation}\"\) AS <test_string>";
<add> $expected = "SELECT \(<title> COLLATE \"{$collation}\"\) AS <test_string>";
<ide> } else {
<del> $expected = "SELECT \(<title> COLLATE ${collation}\) AS <test_string>";
<add> $expected = "SELECT \(<title> COLLATE {$collation}\) AS <test_string>";
<ide> }
<ide> $this->assertRegExpSql($expected, $query->sql(new ValueBinder()), !$this->autoQuote);
<ide>
<ide><path>tests/TestCase/Error/DebuggerTest.php
<ide> public function testEditorUrlValid(): void
<ide> public function testEditorUrlClosure(): void
<ide> {
<ide> Debugger::addEditor('open', function (string $file, int $line) {
<del> return "${file}/${line}";
<add> return "{$file}/{$line}";
<ide> });
<ide> Debugger::setEditor('open');
<ide> $this->assertSame('test.php/123', Debugger::editorUrl('test.php', 123)); | 4 |
Python | Python | resolve line-too-long in integration_test | 4f1d333ded256b0315cf02eee067d6fa902b748d | <ide><path>keras/integration_test/custom_object_saving_test.py
<ide> # `tf.print` message is only available in stderr in TF2, which this test checks.
<ide> @test_utils.run_v2_only
<ide> class CustomObjectSavingTest(tf.test.TestCase, parameterized.TestCase):
<del> """Test for custom Keras object saving with `register_keras_serializable`."""
<add> """Test for custom Keras object saving with
<add> `register_keras_serializable`."""
<ide>
<ide> def setUp(self):
<ide> super().setUp()
<ide><path>keras/integration_test/distributed_training_test.py
<ide> def testKerasTrainingAPI(self, strategy):
<ide> strategy, tf.distribute.experimental.ParameterServerStrategy
<ide> ):
<ide> self.skipTest(
<del> "Parameter Server strategy with dataset creator need to be run when "
<del> "eager execution is enabled."
<add> "Parameter Server strategy with dataset creator need to be run "
<add> "when eager execution is enabled."
<ide> )
<ide>
<del> # A `dataset_fn` is required for `Model.fit` to work across all strategies.
<add> # A `dataset_fn` is required for `Model.fit` to work across all
<add> # strategies.
<ide> def dataset_fn(input_context):
<ide> batch_size = input_context.get_per_replica_batch_size(
<ide> global_batch_size=64
<ide><path>keras/integration_test/forwardprop_test.py
<ide> def _forward_over_back_hessian(f, params, use_pfor, dtype=None):
<ide> (e.g. `tf.float32`) matching the structure of `f`'s returns.
<ide>
<ide> Returns:
<del> A possibly nested structure of matrix slices corresponding to `params`. Each
<del> slice has shape [P, p_s] where `p_s` is the number of parameters (`tf.size`)
<del> in the corresponding element of `params` and `P` is the total number of
<del> parameters (`sum_s(p_s)`). The full matrix can be obtained by concatenating
<del> along the second axis.
<add> A possibly nested structure of matrix slices corresponding to `params`.
<add> Each slice has shape [P, p_s] where `p_s` is the number of parameters
<add> (`tf.size`) in the corresponding element of `params` and `P` is the total
<add> number of parameters (`sum_s(p_s)`). The full matrix can be obtained by
<add> concatenating along the second axis.
<ide> """
<ide> return _vectorize_parameters(
<ide> functools.partial(_hvp, f, params),
<ide> def _forward_over_back_hessian(f, params, use_pfor, dtype=None):
<ide> def _test_gradients(
<ide> testcase, f, primals, order, delta=1e-3, rtol=1e-2, atol=1e-6
<ide> ):
<del> """Tests forward/backward jacobians of `f`'s [0, `order`)-order gradients."""
<add> """Tests forward/backward jacobians of `f`'s [0, `order`)-order
<add> gradients."""
<ide> if order < 1:
<ide> raise ValueError(
<ide> "`order` should be a positive integer, got '{}'.".format(order)
<ide> def call(self, x):
<ide> parameters = model.embed.variables
<ide> tangents = [tf.ones_like(v) for v in parameters]
<ide> with tf.autodiff.ForwardAccumulator(parameters, tangents):
<del> # Note that forwardprop runs alongside the original computation. This test
<del> # is just checking that it doesn't crash; correctness is tested in core
<del> # TF.
<add> # Note that forwardprop runs alongside the original computation.
<add> # This test is just checking that it doesn't crash; correctness is
<add> # tested in core TF.
<ide> model(
<ide> tf.zeros([3, 3], dtype=tf.int32)
<ide> ) # pylint: disable=not-callable
<ide><path>keras/integration_test/function_test.py
<ide> def testFunctionRelaxationLosesInnerDimWithKerasLayer(self):
<ide> self.assertNotIn("ValueError", printed.contents())
<ide>
<ide> # Shape relaxation passes TensorShape([None, None]), which causes layer
<del> # matmul to fail, due to incompatible dims. What would have been a graph
<del> # build time error (layer would complain about the inner dim being 4).
<add> # matmul to fail, due to incompatible dims. What would have been a
<add> # graph build time error (layer would complain about the inner dim being
<add> # 4).
<ide> with self.captureWritesToStream(sys.stderr) as printed:
<ide> with self.assertRaisesRegex(
<ide> tf.errors.InvalidArgumentError, r"Matrix size-incompatible"
<ide> def testDecoratedMethodVariableCleanup(self):
<ide>
<ide> # Verifying if the variables are only referenced from variable_refs.
<ide> # We expect the reference counter to be 1, but `sys.getrefcount` reports
<del> # one higher reference counter because a temporary is created when we call
<del> # sys.getrefcount(). Hence check if the number returned is 2.
<add> # one higher reference counter because a temporary is created when we
<add> # call sys.getrefcount(). Hence check if the number returned is 2.
<ide> # https://docs.python.org/3/library/sys.html#sys.getrefcount
<ide> self.assertEqual(sys.getrefcount(variable_refs[0].deref()), 2)
<ide> self.assertEqual(sys.getrefcount(variable_refs[1].deref()), 2)
<ide> def test_optimizer(self):
<ide>
<ide> class AutomaticControlDependenciesTest(tf.test.TestCase):
<ide> def testVariableInitializersCanBeLifted(self):
<del> # The initializer is a stateful op, but using it inside a function should
<del> # *not* create additional dependencies. That's what we're testing.
<add> # The initializer is a stateful op, but using it inside a function
<add> # should *not* create additional dependencies. That's what we're
<add> # testing.
<ide> layer = tf.keras.layers.Dense(1, kernel_initializer="glorot_uniform")
<ide>
<ide> @tf.function
<ide> def fn(x):
<ide> # Stateful operation
<ide> tf.debugging.Assert(x, ["Error"])
<del> # Variable initialization should be lifted. Prior to the change that
<del> # added this test, the lifting would crash because of an auto control dep
<del> # added on `x`. Note, the error did not happen if we
<add> # Variable initialization should be lifted. Prior to the change
<add> # that added this test, the lifting would crash because of an auto
<add> # control dep added on `x`. Note, the error did not happen if we
<ide> # manually created a tf.Variable outside of function and used it
<del> # here. Alternatively, creating a tf.Variable inside fn() causes
<del> # a different sort of error that is out of scope for this test.
<add> # here. Alternatively, creating a tf.Variable inside fn() causes a
<add> # different sort of error that is out of scope for this test.
<ide> return layer(tf.convert_to_tensor([[1.0, 1.0]]))
<ide>
<ide> true = tf.convert_to_tensor(True)
<ide><path>keras/integration_test/gradient_checkpoint_test.py
<ide> def _get_big_cnn_model(
<ide> img_dim, n_channels, num_partitions, blocks_per_partition
<ide> ):
<del> """Creates a test model whose activations are significantly larger than model size."""
<add> """Creates a test model whose activations are significantly larger than
<add> model size."""
<ide> model = tf.keras.Sequential()
<ide> model.add(layers.Input(shape=(img_dim, img_dim, n_channels)))
<ide> for _ in range(num_partitions):
<ide> def _get_big_cnn_model(
<ide> def _get_split_cnn_model(
<ide> img_dim, n_channels, num_partitions, blocks_per_partition
<ide> ):
<del> """Creates a test model that is split into `num_partitions` smaller models."""
<add> """Creates a test model that is split into `num_partitions` smaller
<add> models."""
<ide> models = [tf.keras.Sequential() for _ in range(num_partitions)]
<ide> models[0].add(layers.Input(shape=(img_dim, img_dim, n_channels)))
<ide> for i in range(num_partitions):
<ide> def _train_no_recompute(n_steps):
<ide>
<ide>
<ide> def _train_with_recompute(n_steps):
<del> """Trains a single large model with gradient checkpointing using tf.recompute_grad."""
<add> """Trains a single large model with gradient checkpointing using
<add> tf.recompute_grad."""
<ide> img_dim, n_channels, batch_size = 256, 1, 4
<ide> x, y = _get_dummy_data(img_dim, n_channels, batch_size)
<ide> # This model is the same model as _get_big_cnn_model but split into 3 parts.
<ide> def test_does_not_raise_oom_exception(self):
<ide> def tearDown(self):
<ide> super().tearDown()
<ide> # Make sure all the models created in keras has been deleted and cleared
<del> # from the global keras grpah, also do a force GC to recycle the GPU memory.
<add> # from the global keras grpah, also do a force GC to recycle the GPU
<add> # memory.
<ide> tf.keras.backend.clear_session()
<ide> gc.collect()
<ide>
<ide><path>keras/integration_test/legacy_rnn_test.py
<ide> def testSimpleRNNCellAndBasicRNNCellComparison(self):
<ide> )
<ide> fix_weights_generator = tf.keras.layers.SimpleRNNCell(output_shape)
<ide> fix_weights_generator.build((None, input_shape))
<del> # The SimpleRNNCell contains 3 weights: kernel, recurrent_kernel, and bias
<del> # The BasicRNNCell contains 2 weight: kernel and bias, where kernel is
<del> # zipped [kernel, recurrent_kernel] in SimpleRNNCell.
<add> # The SimpleRNNCell contains 3 weights: kernel, recurrent_kernel, and
<add> # bias The BasicRNNCell contains 2 weight: kernel and bias, where kernel
<add> # is zipped [kernel, recurrent_kernel] in SimpleRNNCell.
<ide> keras_weights = fix_weights_generator.get_weights()
<ide> kernel, recurrent_kernel, bias = keras_weights
<ide> tf_weights = [np.concatenate((kernel, recurrent_kernel)), bias]
<ide> def testRNNCellSerialization(self):
<ide> weights = model.get_weights()
<ide> config = layer.get_config()
<ide> # The custom_objects is important here since rnn_cell_impl is
<del> # not visible as a Keras layer, and also has a name conflict with
<del> # keras.LSTMCell and GRUCell.
<add> # not visible as a Keras layer, and also has a name conflict
<add> # with keras.LSTMCell and GRUCell.
<ide> layer = tf.keras.layers.RNN.from_config(
<ide> config,
<ide> custom_objects={
<ide> def testRNNCellActsLikeKerasRNNCellInProperScope(self):
<ide> kn2_new = KerasNetworkKerasRNNs(name="kn2_new")
<ide>
<ide> kn2_new(z) # pylint:disable=not-callable
<del> # Most importantly, this doesn't fail due to variable scope reuse issues.
<add> # Most importantly, this doesn't fail due to variable scope reuse
<add> # issues.
<ide> kn1_new(z) # pylint:disable=not-callable
<ide>
<ide> self.assertTrue(
<ide><path>keras/integration_test/multi_worker_tutorial_test.py
<ide> def skip_fetch_failure_exception(self):
<ide> try:
<ide> yield
<ide> except zipfile.BadZipfile as e:
<del> # There can be a race when multiple processes are downloading the data.
<del> # Skip the test if that results in loading errors.
<add> # There can be a race when multiple processes are downloading the
<add> # data. Skip the test if that results in loading errors.
<ide> self.skipTest(
<ide> "Data loading error: Bad magic number for file header."
<ide> )
<ide> def extract_accuracy(worker_id, input_string):
<ide> )
<ide> )
<ide> def testMwmsWithCtl(self, mode):
<del> """Test multi-worker CTL training flow demo'ed in a to-be-added tutorial."""
<add> """Test multi-worker CTL training flow demo'ed in a to-be-added
<add> tutorial."""
<ide>
<ide> def proc_func(checkpoint_dir):
<ide> global_batch_size = PER_WORKER_BATCH_SIZE * NUM_WORKERS
<ide><path>keras/integration_test/mwms_multi_process_runner_test.py
<ide> class MwmsMultiProcessRunnerTest(tf.test.TestCase):
<ide> def testMwmsWithModelFit(self):
<ide> def worker_fn():
<ide> def dataset_fn(input_context):
<del> del input_context # User should shard data accordingly. Omitted here.
<add> # User should shard data accordingly. Omitted here.
<add> del input_context
<ide> return tf.data.Dataset.from_tensor_slices(
<ide> (tf.random.uniform((6, 10)), tf.random.uniform((6, 10)))
<ide> ).batch(2)
<ide><path>keras/integration_test/preprocessing_applied_in_dataset_creator_test.py
<ide> def testDistributedModelFit(self, strategy):
<ide> strategy, tf.distribute.experimental.ParameterServerStrategy
<ide> ):
<ide> self.skipTest(
<del> "Parameter Server strategy with dataset creator need to be run when "
<del> "eager execution is enabled."
<add> "Parameter Server strategy with dataset creator need to be run "
<add> "when eager execution is enabled."
<ide> )
<ide> with strategy.scope():
<ide> preprocessing_model = utils.make_preprocessing_model(
<ide><path>keras/integration_test/preprocessing_applied_in_model_test.py
<ide> def testDistributedModelFit(self, strategy):
<ide> strategy, tf.distribute.experimental.ParameterServerStrategy
<ide> ):
<ide> self.skipTest(
<del> "Parameter Server strategy with dataset creator need to be run when "
<del> "eager execution is enabled."
<add> "Parameter Server strategy with dataset creator need to be run "
<add> "when eager execution is enabled."
<ide> )
<ide> with strategy.scope():
<ide> preprocessing_model = utils.make_preprocessing_model( | 10 |
Python | Python | add tests for list field to schema | 56021f9e7769138e0ae69115f01ed45b5bc8be3f | <ide><path>tests/test_schemas.py
<ide> class ExampleSerializer(serializers.Serializer):
<ide> hidden = serializers.HiddenField(default='hello')
<ide>
<ide>
<add>class AnotherSerializerWithListFields(serializers.Serializer):
<add> a = serializers.ListField(child=serializers.IntegerField())
<add> b = serializers.ListSerializer(child=serializers.CharField())
<add>
<add>
<ide> class AnotherSerializer(serializers.Serializer):
<ide> c = serializers.CharField(required=True)
<ide> d = serializers.CharField(required=False)
<ide> def custom_action(self, request, pk):
<ide> """
<ide> return super(ExampleSerializer, self).retrieve(self, request)
<ide>
<add> @detail_route(methods=['post'], serializer_class=AnotherSerializerWithListFields)
<add> def custom_action_with_list_fields(self, request, pk):
<add> """
<add> A custom action using both list field and list serializer in the serializer.
<add> """
<add> return super(ExampleSerializer, self).retrieve(self, request)
<add>
<ide> @list_route()
<ide> def custom_list_action(self, request):
<ide> return super(ExampleViewSet, self).list(self, request)
<ide> def test_authenticated_request(self):
<ide> coreapi.Field('d', required=False, location='form', schema=coreschema.String(title='D')),
<ide> ]
<ide> ),
<add> 'custom_action_with_list_fields': coreapi.Link(
<add> url='/example/{id}/custom_action_with_list_fields/',
<add> action='post',
<add> encoding='application/json',
<add> description='A custom action using both list field and list serializer in the serializer.',
<add> fields=[
<add> coreapi.Field('id', required=True, location='path', schema=coreschema.String()),
<add> coreapi.Field('a', required=True, location='form', schema=coreschema.Array(title='A', items=coreschema.Integer())),
<add> coreapi.Field('b', required=True, location='form', schema=coreschema.Array(title='B', items=coreschema.String())),
<add> ]
<add> ),
<ide> 'custom_list_action': coreapi.Link(
<ide> url='/example/custom_list_action/',
<ide> action='get' | 1 |
Javascript | Javascript | add fallback for lenient parsing | 46bba4e27ac9c5bcd5355d4520bd3a25f6e41ed6 | <ide><path>src/lib/locale/set.js
<ide> export function set (config) {
<ide> this._config = config;
<ide> // Lenient ordinal parsing accepts just a number in addition to
<ide> // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
<add> // TODO: Remove "ordinalParse" fallback in next major release.
<ide> this._dayOfMonthOrdinalParseLenient = new RegExp(
<del> this._dayOfMonthOrdinalParse.source + '|' + (/\d{1,2}/).source);
<add> (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
<add> '|' + (/\d{1,2}/).source);
<ide> }
<ide>
<ide> export function mergeConfigs(parentConfig, childConfig) { | 1 |
Text | Text | remove extra parenthesis | 29ac0866beaf5fdf4946e05ef3d2af930d3a371e | <ide><path>CHANGELOG-5.4.md
<ide> - Added `--force` option to `make:mail`, `make:model` and `make:notification` ([#19932](https://github.com/laravel/framework/pull/19932))
<ide> - Added support for PostgreSQL deletes with `USES` clauses ([#20062](https://github.com/laravel/framework/pull/20062), [f94fc02](https://github.com/laravel/framework/commit/f94fc026c64471ca5a5b42919c9b5795021d783c))
<ide> - Added support for CC and BBC on mail notifications ([#20093](https://github.com/laravel/framework/pull/20093))
<del>- Added Blade `@auth` and `@guest` directive ([#20087](https://github.com/laravel/framework/pull/20087), ([#20114](https://github.com/laravel/framework/pull/20114)))
<add>- Added Blade `@auth` and `@guest` directive ([#20087](https://github.com/laravel/framework/pull/20087), [#20114](https://github.com/laravel/framework/pull/20114))
<ide> - Added option to configure MARS on SqlServer connections ([#20113](https://github.com/laravel/framework/pull/20113), [c2c917c](https://github.com/laravel/framework/commit/c2c917c5f773d3df7f59242768f921af95309bcc))
<ide>
<ide> ### Changed | 1 |
Javascript | Javascript | prepare more touchable experiments | e802bd0ea9c09e37164e94bcdcbcd1daa5163db4 | <ide><path>Libraries/Components/Touchable/TouchableBounce.js
<ide>
<ide> 'use strict';
<ide>
<add>import TouchableInjection from './TouchableInjection';
<add>
<ide> const Animated = require('../../Animated/src/Animated');
<ide> const DeprecatedViewPropTypes = require('../../DeprecatedPropTypes/DeprecatedViewPropTypes');
<ide> const DeprecatedEdgeInsetsPropType = require('../../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType');
<ide> type Props = $ReadOnly<{|
<ide> * `TouchableMixin` expects us to implement some abstract methods to handle
<ide> * interesting interactions such as `handleTouchablePress`.
<ide> */
<del>const TouchableBounce = ((createReactClass({
<add>const TouchableBounceImpl = ((createReactClass({
<ide> displayName: 'TouchableBounce',
<ide> mixins: [Touchable.Mixin.withoutDefaultFocusAndBlur, NativeMethodsMixin],
<ide>
<ide> const TouchableBounce = ((createReactClass({
<ide> },
<ide> }): any): React.ComponentType<Props>);
<ide>
<add>const TouchableBounce: React.ComponentType<Props> =
<add> TouchableInjection.unstable_TouchableBounce == null
<add> ? TouchableBounceImpl
<add> : TouchableInjection.unstable_TouchableBounce;
<add>
<ide> module.exports = TouchableBounce;
<ide><path>Libraries/Components/Touchable/TouchableHighlight.js
<ide>
<ide> 'use strict';
<ide>
<add>import TouchableInjection from './TouchableInjection';
<add>
<ide> const DeprecatedColorPropType = require('../../DeprecatedPropTypes/DeprecatedColorPropType');
<ide> const DeprecatedViewPropTypes = require('../../DeprecatedPropTypes/DeprecatedViewPropTypes');
<ide> const NativeMethodsMixin = require('../../Renderer/shims/NativeMethodsMixin');
<ide> export type Props = $ReadOnly<{|
<ide> *
<ide> */
<ide>
<del>const TouchableHighlight = ((createReactClass({
<add>const TouchableHighlightImpl = ((createReactClass({
<ide> displayName: 'TouchableHighlight',
<ide> propTypes: {
<ide> /* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an
<ide> const TouchableHighlight = ((createReactClass({
<ide> },
<ide> }): any): React.ComponentType<Props>);
<ide>
<add>const TouchableHighlight: React.ComponentType<Props> =
<add> TouchableInjection.unstable_TouchableHighlight == null
<add> ? TouchableHighlightImpl
<add> : TouchableInjection.unstable_TouchableHighlight;
<add>
<ide> module.exports = TouchableHighlight;
<ide><path>Libraries/Components/Touchable/TouchableInjection.js
<add>/**
<add> * Copyright (c) Facebook, Inc. and its affiliates.
<add> *
<add> * This source code is licensed under the MIT license found in the
<add> * LICENSE file in the root directory of this source tree.
<add> *
<add> * @format
<add> * @flow
<add> */
<add>
<add>'use strict';
<add>
<add>import typeof TouchableBounce from './TouchableBounce';
<add>import typeof TouchableHighlight from './TouchableHighlight';
<add>import typeof TouchableNativeFeedback from './TouchableNativeFeedback';
<add>import typeof TouchableOpacity from './TouchableOpacity';
<add>import typeof TouchableWithoutFeedback from './TouchableWithoutFeedback';
<add>
<add>export default {
<add> unstable_TouchableBounce: (null: ?TouchableBounce),
<add> unstable_TouchableHighlight: (null: ?TouchableHighlight),
<add> unstable_TouchableNativeFeedback: (null: ?TouchableNativeFeedback),
<add> unstable_TouchableOpacity: (null: ?TouchableOpacity),
<add> unstable_TouchableWithoutFeedback: (null: ?TouchableWithoutFeedback),
<add>};
<ide><path>Libraries/Components/Touchable/TouchableNativeFeedback.android.js
<ide>
<ide> 'use strict';
<ide>
<add>import TouchableInjection from './TouchableInjection';
<add>
<ide> const Platform = require('../../Utilities/Platform');
<ide> const PropTypes = require('prop-types');
<ide> const React = require('react');
<ide> const createReactClass = require('create-react-class');
<ide> const ensurePositiveDelayProps = require('./ensurePositiveDelayProps');
<ide> const processColor = require('../../StyleSheet/processColor');
<ide>
<add>import type {Props as TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';
<ide> import type {PressEvent} from '../../Types/CoreEventTypes';
<ide>
<ide> const rippleBackgroundPropType = PropTypes.shape({
<ide> const backgroundPropType = PropTypes.oneOfType([
<ide>
<ide> const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
<ide>
<add>export type Props = $ReadOnly<{|
<add> ...TouchableWithoutFeedbackProps,
<add>
<add> background?: ?(
<add> | $ReadOnly<{|
<add> type: 'ThemeAttrAndroid',
<add> attribute:
<add> | 'selectableItemBackground'
<add> | 'selectableItemBackgroundBorderless',
<add> |}>
<add> | $ReadOnly<{|
<add> type: 'RippleAndroid',
<add> color: ?number,
<add> borderless: boolean,
<add> |}>
<add> ),
<add> hasTVPreferredFocus?: ?boolean,
<add> nextFocusDown?: ?number,
<add> nextFocusForward?: ?number,
<add> nextFocusLeft?: ?number,
<add> nextFocusRight?: ?number,
<add> nextFocusUp?: ?number,
<add> useForeground?: ?boolean,
<add>|}>;
<add>
<ide> /**
<ide> * A wrapper for making views respond properly to touches (Android only).
<ide> * On Android this component uses native state drawable to display touch
<ide> const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
<ide> * ```
<ide> */
<ide>
<del>const TouchableNativeFeedback = createReactClass({
<add>const TouchableNativeFeedbackImpl = createReactClass({
<ide> displayName: 'TouchableNativeFeedback',
<ide> propTypes: {
<ide> /* $FlowFixMe(>=0.89.0 site=react_native_android_fb) This comment
<ide> const TouchableNativeFeedback = createReactClass({
<ide> }
<ide> if (
<ide> this.props.useForeground &&
<del> !TouchableNativeFeedback.canUseNativeForeground()
<add> !TouchableNativeFeedbackImpl.canUseNativeForeground()
<ide> ) {
<ide> console.warn(
<ide> 'Requested foreground ripple, but it is not available on this version of Android. ' +
<ide> const TouchableNativeFeedback = createReactClass({
<ide> }
<ide> const drawableProp =
<ide> this.props.useForeground &&
<del> TouchableNativeFeedback.canUseNativeForeground()
<add> TouchableNativeFeedbackImpl.canUseNativeForeground()
<ide> ? 'nativeForegroundAndroid'
<ide> : 'nativeBackgroundAndroid';
<ide> const childProps = {
<ide> const TouchableNativeFeedback = createReactClass({
<ide> },
<ide> });
<ide>
<add>const TouchableNativeFeedback: React.ComponentType<Props> =
<add> TouchableInjection.unstable_TouchableNativeFeedback == null
<add> ? TouchableNativeFeedbackImpl
<add> : TouchableInjection.unstable_TouchableNativeFeedback;
<add>
<ide> module.exports = (TouchableNativeFeedback: $FlowFixMe);
<ide><path>Libraries/Components/Touchable/TouchableOpacity.js
<ide>
<ide> 'use strict';
<ide>
<add>import TouchableInjection from './TouchableInjection';
<add>
<ide> const Animated = require('../../Animated/src/Animated');
<ide> const Easing = require('../../Animated/src/Easing');
<ide> const NativeMethodsMixin = require('../../Renderer/shims/NativeMethodsMixin');
<ide> export type Props = $ReadOnly<{|
<ide> * ```
<ide> *
<ide> */
<del>const TouchableOpacity = ((createReactClass({
<add>const TouchableOpacityImpl = ((createReactClass({
<ide> displayName: 'TouchableOpacity',
<ide> mixins: [Touchable.Mixin.withoutDefaultFocusAndBlur, NativeMethodsMixin],
<ide>
<ide> const TouchableOpacity = ((createReactClass({
<ide> },
<ide> }): any): React.ComponentType<Props>);
<ide>
<add>const TouchableOpacity: React.ComponentType<Props> =
<add> TouchableInjection.unstable_TouchableOpacity == null
<add> ? TouchableOpacityImpl
<add> : TouchableInjection.unstable_TouchableOpacity;
<add>
<ide> module.exports = TouchableOpacity;
<ide><path>Libraries/Components/Touchable/TouchableWithoutFeedback.js
<ide>
<ide> 'use strict';
<ide>
<del>import TouchableWithoutFeedbackInjection from './TouchableWithoutFeedbackInjection';
<add>import TouchableInjection from './TouchableInjection';
<ide>
<ide> const DeprecatedEdgeInsetsPropType = require('../../DeprecatedPropTypes/DeprecatedEdgeInsetsPropType');
<ide> const React = require('react');
<ide> const TouchableWithoutFeedbackImpl = ((createReactClass({
<ide> }): any): React.ComponentType<Props>);
<ide>
<ide> const TouchableWithoutFeedback: React.ComponentType<Props> =
<del> TouchableWithoutFeedbackInjection.unstable_Override == null
<add> TouchableInjection.unstable_TouchableWithoutFeedback == null
<ide> ? TouchableWithoutFeedbackImpl
<del> : TouchableWithoutFeedbackInjection.unstable_Override;
<add> : TouchableInjection.unstable_TouchableWithoutFeedback;
<ide>
<ide> module.exports = TouchableWithoutFeedback;
<ide><path>Libraries/Components/Touchable/TouchableWithoutFeedbackInjection.js
<del>/**
<del> * Copyright (c) Facebook, Inc. and its affiliates.
<del> *
<del> * This source code is licensed under the MIT license found in the
<del> * LICENSE file in the root directory of this source tree.
<del> *
<del> * @format
<del> * @flow
<del> */
<del>
<del>'use strict';
<del>
<del>import type {Props} from './TouchableWithoutFeedback';
<del>import * as React from 'react';
<del>
<del>export default {
<del> unstable_Override: (null: ?React.ComponentType<Props>),
<del>}; | 7 |
Ruby | Ruby | improve escape_javascript performance | 2bb7dbf75d2c267c6a3149c178e111869c61cbfe | <ide><path>actionview/lib/action_view/helpers/javascript_helper.rb
<ide> def escape_javascript(javascript)
<ide> if javascript.empty?
<ide> result = ""
<ide> else
<del> result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u) { |match| JS_ESCAPE_MAP[match] }
<add> result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u, JS_ESCAPE_MAP)
<ide> end
<ide> javascript.html_safe? ? result.html_safe : result
<ide> end | 1 |
Ruby | Ruby | reduce method calls on arel | f1758525f940eb6c4dd4178784db2ba66316083d | <ide><path>activerecord/lib/active_record/relation/calculations.rb
<ide> def perform_calculation(operation, column_name, options = {})
<ide> if operation == "count"
<ide> column_name ||= (select_for_count || :all)
<ide>
<del> if arel.joins(arel) =~ /LEFT OUTER/i
<add> if arel.join_sql =~ /LEFT OUTER/i
<ide> distinct = true
<ide> column_name = @klass.primary_key if column_name == :all
<ide> end
<ide><path>activerecord/lib/active_record/relation/finder_methods.rb
<ide> def find_with_associations
<ide>
<ide> def construct_relation_for_association_calculations
<ide> including = (@eager_load_values + @includes_values).uniq
<del> join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, including, arel.joins(arel))
<add> join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, including, arel.join_sql)
<ide> relation = except(:includes, :eager_load, :preload)
<ide> apply_join_dependency(relation, join_dependency)
<ide> end
<ide><path>activerecord/lib/active_record/relation/query_methods.rb
<ide> def custom_join_sql(*joins)
<ide> arel.join(join)
<ide> end
<ide>
<del> arel.joins(arel)
<add> arel.join_sql
<ide> end
<ide>
<ide> def build_arel | 3 |
Mixed | Javascript | fix socket re-use races | 8700d89306cc4c1fd1a540d4b8f27a59f7b4957e | <ide><path>doc/api/http.md
<ide> added: v0.11.4
<ide> An object which contains arrays of sockets currently awaiting use by
<ide> the agent when `keepAlive` is enabled. Do not modify.
<ide>
<add>Sockets in the `freeSockets` list will be automatically destroyed and
<add>removed from the array on `'timeout'`.
<add>
<ide> ### `agent.getName(options)`
<ide> <!-- YAML
<ide> added: v0.11.4
<ide><path>lib/_http_agent.js
<ide> function Agent(options) {
<ide> socket[async_id_symbol] = -1;
<ide> socket._httpMessage = null;
<ide> this.removeSocket(socket, options);
<add>
<add> const agentTimeout = this.options.timeout || 0;
<add> if (socket.timeout !== agentTimeout) {
<add> socket.setTimeout(agentTimeout);
<add> }
<add>
<ide> freeSockets.push(socket);
<ide> } else {
<ide> // Implementation doesn't want to keep socket alive
<ide> Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
<ide> this.sockets[name] = [];
<ide> }
<ide>
<del> const freeLen = this.freeSockets[name] ? this.freeSockets[name].length : 0;
<add> const freeSockets = this.freeSockets[name];
<add> let socket;
<add> if (freeSockets) {
<add> while (freeSockets.length && freeSockets[0].destroyed) {
<add> freeSockets.shift();
<add> }
<add> socket = freeSockets.shift();
<add> if (!freeSockets.length)
<add> delete this.freeSockets[name];
<add> }
<add>
<add> const freeLen = freeSockets ? freeSockets.length : 0;
<ide> const sockLen = freeLen + this.sockets[name].length;
<ide>
<del> if (freeLen) {
<del> // We have a free socket, so use that.
<del> const socket = this.freeSockets[name].shift();
<add> if (socket) {
<ide> // Guard against an uninitialized or user supplied Socket.
<ide> const handle = socket._handle;
<ide> if (handle && typeof handle.asyncReset === 'function') {
<ide> Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
<ide> socket[async_id_symbol] = handle.getAsyncId();
<ide> }
<ide>
<del> // don't leak
<del> if (!this.freeSockets[name].length)
<del> delete this.freeSockets[name];
<del>
<ide> this.reuseSocket(socket, req);
<ide> setRequestSocket(this, req, socket);
<ide> this.sockets[name].push(socket);
<ide> function installListeners(agent, s, options) {
<ide> }
<ide> s.on('close', onClose);
<ide>
<add> function onTimeout() {
<add> debug('CLIENT socket onTimeout');
<add>
<add> // Destroy if in free list.
<add> // TODO(ronag): Always destroy, even if not in free list.
<add> const sockets = agent.freeSockets;
<add> for (const name of ObjectKeys(sockets)) {
<add> if (sockets[name].includes(s)) {
<add> return s.destroy();
<add> }
<add> }
<add> }
<add> s.on('timeout', onTimeout);
<add>
<ide> function onRemove() {
<ide> // We need this function for cases like HTTP 'upgrade'
<ide> // (defined by WebSockets) where we need to remove a socket from the
<ide> function installListeners(agent, s, options) {
<ide> agent.removeSocket(s, options);
<ide> s.removeListener('close', onClose);
<ide> s.removeListener('free', onFree);
<add> s.removeListener('timeout', onTimeout);
<ide> s.removeListener('agentRemove', onRemove);
<ide> }
<ide> s.on('agentRemove', onRemove);
<ide> function setRequestSocket(agent, req, socket) {
<ide> return;
<ide> }
<ide> socket.setTimeout(req.timeout);
<del> // Reset timeout after response end
<del> req.once('response', (res) => {
<del> res.once('end', () => {
<del> if (socket.timeout !== agentTimeout) {
<del> socket.setTimeout(agentTimeout);
<del> }
<del> });
<del> });
<ide> }
<ide>
<ide> function emitErrorNT(emitter, err) {
<ide><path>test/parallel/test-http-agent-timeout-option.js
<ide> request.on('socket', mustCall((socket) => {
<ide>
<ide> const listeners = socket.listeners('timeout');
<ide>
<del> strictEqual(listeners.length, 1);
<del> strictEqual(listeners[0], request.timeoutCb);
<add> strictEqual(listeners.length, 2);
<add> strictEqual(listeners[1], request.timeoutCb);
<ide> }));
<ide><path>test/parallel/test-http-agent-timeout.js
<add>'use strict';
<add>
<add>const common = require('../common');
<add>const assert = require('assert');
<add>const http = require('http');
<add>
<add>{
<add> // Ensure reuse of successful sockets.
<add>
<add> const agent = new http.Agent({ keepAlive: true });
<add>
<add> const server = http.createServer((req, res) => {
<add> res.end();
<add> });
<add>
<add> server.listen(0, common.mustCall(() => {
<add> let socket;
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> socket = res.socket;
<add> assert(socket);
<add> res.resume();
<add> socket.on('free', common.mustCall(() => {
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> assert.strictEqual(socket, res.socket);
<add> assert(socket);
<add> agent.destroy();
<add> server.close();
<add> }));
<add> }));
<add> }));
<add> }));
<add>}
<add>
<add>{
<add> // Ensure that timeouted sockets are not reused.
<add>
<add> const agent = new http.Agent({ keepAlive: true, timeout: 50 });
<add>
<add> const server = http.createServer((req, res) => {
<add> res.end();
<add> });
<add>
<add> server.listen(0, common.mustCall(() => {
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> const socket = res.socket;
<add> assert(socket);
<add> res.resume();
<add> socket.on('free', common.mustCall(() => {
<add> socket.on('timeout', common.mustCall(() => {
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> assert.notStrictEqual(socket, res.socket);
<add> assert.strictEqual(socket.destroyed, true);
<add> agent.destroy();
<add> server.close();
<add> }));
<add> }));
<add> }));
<add> }));
<add> }));
<add>}
<add>
<add>{
<add> // Ensure that destroyed sockets are not reused.
<add>
<add> const agent = new http.Agent({ keepAlive: true });
<add>
<add> const server = http.createServer((req, res) => {
<add> res.end();
<add> });
<add>
<add> server.listen(0, common.mustCall(() => {
<add> let socket;
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> socket = res.socket;
<add> assert(socket);
<add> res.resume();
<add> socket.on('free', common.mustCall(() => {
<add> socket.destroy();
<add> http.get({ port: server.address().port, agent })
<add> .on('response', common.mustCall((res) => {
<add> assert.notStrictEqual(socket, res.socket);
<add> assert(socket);
<add> agent.destroy();
<add> server.close();
<add> }));
<add> }));
<add> }));
<add> }));
<add>}
<ide><path>test/parallel/test-http-client-set-timeout-after-end.js
<ide> server.listen(0, () => {
<ide> const req = get({ agent, port }, (res) => {
<ide> res.on('end', () => {
<ide> strictEqual(req.setTimeout(0), req);
<del> strictEqual(socket.listenerCount('timeout'), 0);
<add> strictEqual(socket.listenerCount('timeout'), 1);
<ide> agent.destroy();
<ide> server.close();
<ide> });
<ide><path>test/parallel/test-http-client-set-timeout.js
<ide> server.listen(0, mustCall(() => {
<ide> }));
<ide>
<ide> req.on('timeout', mustCall(() => {
<del> strictEqual(req.socket.listenerCount('timeout'), 0);
<add> strictEqual(req.socket.listenerCount('timeout'), 1);
<ide> req.destroy();
<ide> }));
<ide> }));
<ide><path>test/parallel/test-http-client-timeout-option-listeners.js
<ide> const options = {
<ide> server.listen(0, options.host, common.mustCall(() => {
<ide> options.port = server.address().port;
<ide> doRequest(common.mustCall((numListeners) => {
<del> assert.strictEqual(numListeners, 1);
<add> assert.strictEqual(numListeners, 2);
<ide> doRequest(common.mustCall((numListeners) => {
<del> assert.strictEqual(numListeners, 1);
<add> assert.strictEqual(numListeners, 2);
<ide> server.close();
<ide> agent.destroy();
<ide> }));
<ide><path>test/parallel/test-http-client-timeout-option-with-agent.js
<ide> request.on('socket', mustCall((socket) => {
<ide>
<ide> const listeners = socket.listeners('timeout');
<ide>
<del> strictEqual(listeners.length, 1);
<del> strictEqual(listeners[0], request.timeoutCb);
<add> strictEqual(listeners.length, 2);
<add> strictEqual(listeners[1], request.timeoutCb);
<ide> })); | 8 |
Python | Python | add methods for creating and deleting a container | 9a92bbf2dd67bb764dde2b1d9b564572ccedac16 | <ide><path>libcloud/storage/drivers/s3.py
<ide> # limitations under the License.
<ide>
<ide> import time
<del>import urllib
<add>import httplib
<ide> import copy
<ide> import base64
<ide> import hmac
<ide>
<ide> from hashlib import sha1
<add>from xml.etree.ElementTree import Element, SubElement, tostring
<ide>
<ide> from libcloud.utils import fixxpath, findtext, in_development_warning
<ide> from libcloud.common.types import InvalidCredsError, LibcloudError
<ide> from libcloud.common.base import ConnectionUserAndKey
<ide> from libcloud.common.aws import AWSBaseResponse
<ide>
<ide> from libcloud.storage.base import Object, Container, StorageDriver
<add>from libcloud.storage.types import ContainerIsNotEmptyError
<add>from libcloud.storage.types import ContainerDoesNotExistError
<ide>
<ide> in_development_warning('libcloud.storage.drivers.s3')
<ide>
<ide>
<ide>
<ide> class S3Response(AWSBaseResponse):
<add>
<add> valid_response_codes = [ httplib.NOT_FOUND, httplib.CONFLICT ]
<add>
<add> def success(self):
<add> i = int(self.status)
<add> return i >= 200 and i <= 299 or i in self.valid_response_codes
<add>
<ide> def parse_error(self):
<ide> if self.status == 403:
<ide> raise InvalidCredsError(self.body)
<ide> elif self.status == 301:
<del> # This bucket is located in a different region
<ide> raise LibcloudError('This bucket is located in a different ' +
<ide> 'region. Please use the correct driver.',
<ide> driver=S3StorageDriver)
<ide> class S3StorageDriver(StorageDriver):
<ide> name = 'Amazon S3 (standard)'
<ide> connectionCls = S3Connection
<ide> hash_type = 'md5'
<add> ex_location_name = ''
<ide>
<ide> def list_containers(self):
<ide> response = self.connection.request('/')
<del> if response.status == 200:
<add> if response.status == httplib.OK:
<ide> containers = self._to_containers(obj=response.object,
<ide> xpath='Buckets/Bucket')
<ide> return containers
<ide>
<del> raise LibcloudError('Unexpected status code: %s' % (response.status))
<add> raise LibcloudError('Unexpected status code: %s' % (response.status),
<add> driver=self)
<ide>
<ide> def list_container_objects(self, container):
<ide> response = self.connection.request('/%s' % (container.name))
<del> if response.status == 200:
<add> if response.status == httplib.OK:
<ide> objects = self._to_objs(obj=response.object,
<ide> xpath='Contents', container=container)
<ide> return objects
<ide>
<del> raise LibcloudError('Unexpected status code: %s' % (response.status))
<add> raise LibcloudError('Unexpected status code: %s' % (response.status),
<add> driver=self)
<add>
<add> def create_container(self, container_name):
<add> root = Element('CreateBucketConfiguration')
<add> child = SubElement(root, 'LocationConstraint')
<add> child.text = self.ex_location_name
<add>
<add> response = self.connection.request('/%s' % (container_name),
<add> data=tostring(root),
<add> method='PUT')
<add> if response.status == httplib.OK:
<add> container = Container(name=container_name, extra=None, driver=self)
<add> return container
<add> elif response.status == httplib.CONFLICT:
<add> raise LibcloudError('Container with this name already exists.' +
<add> 'The name must be unique across all the ' +
<add> 'containers in the system')
<add>
<add> raise LibcloudError('Unexpected status code: %s' % (response.status),
<add> driver=self)
<add>
<add> def delete_container(self, container):
<add> # All the objects in the container must be deleted first
<add> response = self.connection.request('/%s' % (container.name),
<add> method='DELETE')
<add> if response.status == httplib.NO_CONTENT:
<add> return True
<add> elif response.status == httplib.CONFLICT:
<add> raise ContainerIsNotEmptyError(value='Container must be empty' +
<add> ' before it can be deleted.',
<add> container_name=container.name,
<add> driver=self)
<add> elif response.status == httplib.NOT_FOUND:
<add> raise ContainerDoesNotExistError(value=None,
<add> driver=self,
<add> container_name=container.name)
<add>
<add> return False
<ide>
<ide> def _to_containers(self, obj, xpath):
<ide> return [ self._to_container(element) for element in \
<ide> class S3USWestConnection(S3Connection):
<ide> class S3USWestStorageDriver(S3StorageDriver):
<ide> name = 'Amazon S3 (us-west-1)'
<ide> connectionCls = S3USWestConnection
<add> ex_location_name = 'us-west-1'
<ide>
<ide> class S3EUWestConnection(S3Connection):
<ide> host = S3_EU_WEST_HOST
<ide>
<ide> class S3EUWestStorageDriver(S3StorageDriver):
<ide> name = 'Amazon S3 (eu-west-1)'
<ide> connectionCls = S3EUWestConnection
<add> ex_location_name = 'EU'
<ide>
<ide> class S3APSEConnection(S3Connection):
<ide> host = S3_AP_SOUTHEAST_HOST
<ide>
<ide> class S3APSEStorageDriver(S3StorageDriver):
<ide> name = 'Amazon S3 (ap-southeast-1)'
<ide> connectionCls = S3APSEConnection
<add> ex_location_name = 'ap-southeast-1'
<ide>
<ide> class S3APNEConnection(S3Connection):
<ide> host = S3_AP_NORTHEAST_HOST
<ide>
<ide> class S3APNEStorageDriver(S3StorageDriver):
<ide> name = 'Amazon S3 (ap-northeast-1)'
<ide> connectionCls = S3APNEConnection
<del>
<add> ex_location_name = 'ap-northeast-1' | 1 |
Java | Java | improve restclientexception javadoc | 03ea92df9916baa5f8df37ec4154cb07fd2cea4d | <ide><path>spring-web/src/main/java/org/springframework/web/client/RestClientException.java
<ide> /*
<del> * Copyright 2002-2012 the original author or authors.
<add> * Copyright 2002-2020 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> package org.springframework.web.client;
<ide>
<ide> import org.springframework.core.NestedRuntimeException;
<add>import org.springframework.http.client.ClientHttpResponse;
<ide>
<ide> /**
<del> * Base class for exceptions thrown by {@link RestTemplate} whenever it encounters
<del> * client-side HTTP errors.
<add> * Base class for exceptions thrown by {@link RestTemplate} in case a request
<add> * fails because of a server error response, as determined via
<add> * {@link ResponseErrorHandler#hasError(ClientHttpResponse)}, failure to decode
<add> * the response, or a low level I/O error.
<ide> *
<ide> * @author Arjen Poutsma
<ide> * @since 3.0 | 1 |
Text | Text | correct minor grammar mistake | 10d3126383ad560eb148ae3df3705ad11110d7ea | <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/mutate-an-array-declared-with-const.md
<ide> As you can see, you can mutate the object <code>[5, 6, 7]</code> itself and the
<ide>
<ide> ## Instructions
<ide> <section id='instructions'>
<del>An array is declared as <code>const s = [5, 7, 2]</code>. Change the array to <code>[2, 5, 7]</code> using various element assignment.
<add>An array is declared as <code>const s = [5, 7, 2]</code>. Change the array to <code>[2, 5, 7]</code> using various element assignments.
<ide> </section>
<ide>
<ide> ## Tests | 1 |
Python | Python | fix broken regression test | bd2f3c0ddad61d78eda6257dbf1cbeb608aa1c82 | <ide><path>numpy/core/tests/test_regression.py
<ide> def __array_finalize__(self, obj):
<ide> def test_recarray_tolist(self, level=rlevel):
<ide> """Ticket #793, changeset r5215
<ide> """
<del> a = np.recarray(2, formats="i4,f8,f8", names="id,x,y")
<add> # Comparisons fail for NaN, so we can't use random memory
<add> # for the test.
<add> buf = np.zeros(40, dtype=np.int8)
<add> a = np.recarray(2, formats="i4,f8,f8", names="id,x,y", buf=buf)
<ide> b = a.tolist()
<ide> assert( a[0].tolist() == b[0])
<ide> assert( a[1].tolist() == b[1]) | 1 |
Python | Python | add strip_accents to basic berttokenizer. | d5bc32ce92ace9aaec7752e0b89d51ba18903a1b | <ide><path>src/transformers/tokenization_bert.py
<ide> class BertTokenizer(PreTrainedTokenizer):
<ide> Whether to tokenize Chinese characters.
<ide> This should likely be deactivated for Japanese:
<ide> see: https://github.com/huggingface/transformers/issues/328
<add> strip_accents: (:obj:`bool`, `optional`, defaults to :obj:`None`):
<add> Whether to strip all accents. If this option is not specified (ie == None),
<add> then it will be determined by the value for `lowercase` (as in the original Bert).
<ide> """
<ide>
<ide> vocab_files_names = VOCAB_FILES_NAMES
<ide> def __init__(
<ide> cls_token="[CLS]",
<ide> mask_token="[MASK]",
<ide> tokenize_chinese_chars=True,
<add> strip_accents=None,
<ide> **kwargs
<ide> ):
<ide> super().__init__(
<ide> def __init__(
<ide> self.do_basic_tokenize = do_basic_tokenize
<ide> if do_basic_tokenize:
<ide> self.basic_tokenizer = BasicTokenizer(
<del> do_lower_case=do_lower_case, never_split=never_split, tokenize_chinese_chars=tokenize_chinese_chars
<add> do_lower_case=do_lower_case,
<add> never_split=never_split,
<add> tokenize_chinese_chars=tokenize_chinese_chars,
<add> strip_accents=strip_accents,
<ide> )
<ide> self.wordpiece_tokenizer = WordpieceTokenizer(vocab=self.vocab, unk_token=self.unk_token)
<ide>
<ide> def save_vocabulary(self, vocab_path):
<ide> class BasicTokenizer(object):
<ide> """Runs basic tokenization (punctuation splitting, lower casing, etc.)."""
<ide>
<del> def __init__(self, do_lower_case=True, never_split=None, tokenize_chinese_chars=True):
<add> def __init__(self, do_lower_case=True, never_split=None, tokenize_chinese_chars=True, strip_accents=None):
<ide> """ Constructs a BasicTokenizer.
<ide>
<ide> Args:
<ide> def __init__(self, do_lower_case=True, never_split=None, tokenize_chinese_chars=
<ide> Whether to tokenize Chinese characters.
<ide> This should likely be deactivated for Japanese:
<ide> see: https://github.com/huggingface/pytorch-pretrained-BERT/issues/328
<add> **strip_accents**: (`optional`) boolean (default None)
<add> Whether to strip all accents. If this option is not specified (ie == None),
<add> then it will be determined by the value for `lowercase` (as in the original Bert).
<ide> """
<ide> if never_split is None:
<ide> never_split = []
<ide> self.do_lower_case = do_lower_case
<ide> self.never_split = set(never_split)
<ide> self.tokenize_chinese_chars = tokenize_chinese_chars
<add> self.strip_accents = strip_accents
<ide>
<ide> def tokenize(self, text, never_split=None):
<ide> """ Basic Tokenization of a piece of text.
<ide> def tokenize(self, text, never_split=None):
<ide> orig_tokens = whitespace_tokenize(text)
<ide> split_tokens = []
<ide> for token in orig_tokens:
<del> if self.do_lower_case and token not in never_split:
<del> token = token.lower()
<del> token = self._run_strip_accents(token)
<add> if token not in never_split:
<add> if self.do_lower_case:
<add> token = token.lower()
<add> if self.strip_accents is not False:
<add> token = self._run_strip_accents(token)
<add> elif self.strip_accents:
<add> token = self._run_strip_accents(token)
<ide> split_tokens.extend(self._run_split_on_punc(token, never_split))
<ide>
<ide> output_tokens = whitespace_tokenize(" ".join(split_tokens))
<ide><path>tests/test_tokenization_bert.py
<ide> def test_basic_tokenizer_lower(self):
<ide> )
<ide> self.assertListEqual(tokenizer.tokenize("H\u00E9llo"), ["hello"])
<ide>
<add> def test_basic_tokenizer_lower_strip_accents_false(self):
<add> tokenizer = BasicTokenizer(do_lower_case=True, strip_accents=False)
<add>
<add> self.assertListEqual(
<add> tokenizer.tokenize(" \tHäLLo!how \n Are yoU? "), ["hällo", "!", "how", "are", "you", "?"]
<add> )
<add> self.assertListEqual(tokenizer.tokenize("H\u00E9llo"), ["h\u00E9llo"])
<add>
<add> def test_basic_tokenizer_lower_strip_accents_true(self):
<add> tokenizer = BasicTokenizer(do_lower_case=True, strip_accents=True)
<add>
<add> self.assertListEqual(
<add> tokenizer.tokenize(" \tHäLLo!how \n Are yoU? "), ["hallo", "!", "how", "are", "you", "?"]
<add> )
<add> self.assertListEqual(tokenizer.tokenize("H\u00E9llo"), ["hello"])
<add>
<add> def test_basic_tokenizer_lower_strip_accents_default(self):
<add> tokenizer = BasicTokenizer(do_lower_case=True)
<add>
<add> self.assertListEqual(
<add> tokenizer.tokenize(" \tHäLLo!how \n Are yoU? "), ["hallo", "!", "how", "are", "you", "?"]
<add> )
<add> self.assertListEqual(tokenizer.tokenize("H\u00E9llo"), ["hello"])
<add>
<ide> def test_basic_tokenizer_no_lower(self):
<ide> tokenizer = BasicTokenizer(do_lower_case=False)
<ide>
<ide> self.assertListEqual(
<ide> tokenizer.tokenize(" \tHeLLo!how \n Are yoU? "), ["HeLLo", "!", "how", "Are", "yoU", "?"]
<ide> )
<ide>
<add> def test_basic_tokenizer_no_lower_strip_accents_false(self):
<add> tokenizer = BasicTokenizer(do_lower_case=False, strip_accents=False)
<add>
<add> self.assertListEqual(
<add> tokenizer.tokenize(" \tHäLLo!how \n Are yoU? "), ["HäLLo", "!", "how", "Are", "yoU", "?"]
<add> )
<add>
<add> def test_basic_tokenizer_no_lower_strip_accents_true(self):
<add> tokenizer = BasicTokenizer(do_lower_case=False, strip_accents=True)
<add>
<add> self.assertListEqual(
<add> tokenizer.tokenize(" \tHäLLo!how \n Are yoU? "), ["HaLLo", "!", "how", "Are", "yoU", "?"]
<add> )
<add>
<ide> def test_basic_tokenizer_respects_never_split_tokens(self):
<ide> tokenizer = BasicTokenizer(do_lower_case=False, never_split=["[UNK]"])
<ide> | 2 |
Text | Text | add v3.4.0 to changelog | b2cc5662e9c020aa46f84f5801b0f1f7ce5cd0d8 | <ide><path>CHANGELOG.md
<ide> # Ember Changelog
<ide>
<del>### v3.4.0-beta.3 (August 21, 2018)
<del>
<del>- [#16870](https://github.com/emberjs/ember.js/pull/16870) [BUGFIX] Enable @ember/object#get to be called with an empty string
<add>### v3.4.0 (August 27, 2018)
<ide> - [#16603](https://github.com/emberjs/ember.js/pull/16603) [BUGFIX] Support mouseEnter/Leave events w/o jQuery
<del>
<del>### v3.4.0-beta.2 (August 06, 2018)
<del>
<ide> - [#16857](https://github.com/emberjs/ember.js/pull/16857) [BUGFIX] Prevents the recursive redefinition of root chains
<ide> - [#16854](https://github.com/emberjs/ember.js/pull/16854) [BUGFIX] Don't thread FactoryManager through createComponent
<del>- [#16853](https://github.com/emberjs/ember.js/pull/16853) [BUGFIX] Allow ArrayProxy#pushObjects to accept ArrayProxy again
<del>
<del>### v3.4.0-beta.1 (July 16, 2018)
<del>
<ide> - [#16773](https://github.com/emberjs/ember.js/pull/16773) [FEATURE] Custom component manager (see [emberjs/rfcs#213](https://github.com/emberjs/rfcs/blob/master/text/0213-custom-components.md) for more details)
<ide> - [#16708](https://github.com/emberjs/ember.js/pull/16708) [FEATURE] Angle bracket component invocation (see [emberjs/rfcs#311](https://github.com/emberjs/rfcs/blob/master/text/0311-angle-bracket-invocation.md) for more details)
<ide> - [#16744](https://github.com/emberjs/ember.js/pull/16744) [DEPRECATION] Deprecate `component#sendAction` (see [emberjs/rfcs#335](https://github.com/emberjs/rfcs/blob/master/text/0335-deprecate-send-action.md) for more details) | 1 |
Javascript | Javascript | fix the type definition of typedarray | a0f0ab78f3755a83dd39ff2a50e34e4b7c433b6c | <ide><path>src/display/api.js
<ide> function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
<ide> }
<ide>
<ide> /**
<del> * @typedef {
<del> * Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array |
<del> * Int32Array | Uint32Array | Float32Array | Float64Array
<add> * @typedef { Int8Array | Uint8Array | Uint8ClampedArray |
<add> * Int16Array | Uint16Array |
<add> * Int32Array | Uint32Array | Float32Array |
<add> * Float64Array
<ide> * } TypedArray
<ide> */
<ide> | 1 |
Text | Text | fix typo in eslint doc | 5c7475a6e89990cee45abfec8f396524bc122fa1 | <ide><path>docs/basic-features/eslint.md
<ide> Here's an example of an `.eslintrc.json` file:
<ide> ```
<ide>
<ide> - Extending the original base of rules (`plugin:@next/next/recommended`) is highly recommended to
<del> catch and fix significant Next.js issues in your application
<add> catch and fix significant Next.js issues in your application.
<ide> - Including `@babel/eslint-parser` with the `next/babel` preset ensures that all language features
<ide> supported by Next.js will also be supported by ESLint. Although `@babel/eslint-parser` can parse
<ide> TypeScript, consider using | 1 |
Ruby | Ruby | save a hash allocation in mysql statement pool | f2a906337355e3ddd5f42182711075e9404f7096 | <ide><path>activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
<ide> class AbstractMysqlAdapter < AbstractAdapter
<ide>
<ide> class StatementPool < ConnectionAdapters::StatementPool # :nodoc:
<ide> private def dealloc(stmt)
<del> stmt[:stmt].close
<add> stmt.close
<ide> end
<ide> end
<ide>
<ide><path>activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
<ide> def exec_stmt_and_free(sql, name, binds, cache_stmt: false)
<ide>
<ide> log(sql, name, binds, type_casted_binds) do
<ide> if cache_stmt
<del> cache = @statements[sql] ||= {
<del> stmt: @connection.prepare(sql)
<del> }
<del> stmt = cache[:stmt]
<add> stmt = @statements[sql] ||= @connection.prepare(sql)
<ide> else
<ide> stmt = @connection.prepare(sql)
<ide> end | 2 |
PHP | PHP | add suggestions for missing command name | b3783a542776ae8762b6a8316afbe5035a5c1491 | <ide><path>src/Console/CommandCollection.php
<ide> public function autoDiscover(): array
<ide>
<ide> return array_merge($core, $app);
<ide> }
<add>
<add> /**
<add> * Find suggested command names based on $needle
<add> *
<add> * Used to generate suggested commands when a
<add> * command cannot be found in the collection.
<add> *
<add> * @param string $needle The missing command to find suggestions for.
<add> * @return string[]
<add> */
<add> public function suggest(string $needle): array
<add> {
<add> $found = [];
<add> foreach (array_keys($this->commands) as $candidate) {
<add> if (levenshtein($candidate, $needle) < 3) {
<add> $found[] = $candidate;
<add> } elseif (strpos($candidate, $needle) === 0) {
<add> $found[] = $candidate;
<add> }
<add> }
<add>
<add> return $found;
<add> }
<ide> }
<ide><path>src/Console/CommandRunner.php
<ide>
<ide> use Cake\Command\HelpCommand;
<ide> use Cake\Command\VersionCommand;
<add>use Cake\Console\Exception\NoOptionException;
<ide> use Cake\Console\Exception\StopException;
<ide> use Cake\Core\ConsoleApplicationInterface;
<ide> use Cake\Core\HttpApplicationInterface;
<ide> public function run(array $argv, ?ConsoleIo $io = null): int
<ide>
<ide> $io = $io ?: new ConsoleIo();
<ide>
<del> [$name, $argv] = $this->longestCommandName($commands, $argv);
<del> $name = $this->resolveName($commands, $io, $name);
<add> try {
<add> [$name, $argv] = $this->longestCommandName($commands, $argv);
<add> $name = $this->resolveName($commands, $io, $name);
<add> } catch (NoOptionException $e) {
<add> $io->error($e->getFullMessage());
<add>
<add> return Command::CODE_ERROR;
<add> }
<ide>
<ide> $result = Command::CODE_ERROR;
<ide> $shell = $this->getShell($io, $commands, $name);
<ide> protected function resolveName(CommandCollection $commands, ConsoleIo $io, ?stri
<ide> $name = Inflector::underscore($name);
<ide> }
<ide> if (!$commands->has($name)) {
<del> throw new RuntimeException(
<del> "Unknown command `{$this->root} {$name}`." .
<del> " Run `{$this->root} --help` to get the list of valid commands."
<add> $suggestions = $commands->suggest($name);
<add> throw new NoOptionException(
<add> "Unknown command `{$this->root} {$name}`. " .
<add> "Run `{$this->root} --help` to get the list of commands.",
<add> $suggestions
<ide> );
<ide> }
<ide>
<ide><path>src/Console/Exception/NoOptionException.php
<add><?php
<add>declare(strict_types=1);
<add>
<add>/**
<add> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
<add> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<add> *
<add> * Licensed under The MIT License
<add> * Redistributions of files must retain the above copyright notice.
<add> *
<add> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
<add> * @link https://book.cakephp.org/3.0/en/development/errors.html#error-exception-configuration
<add> * @since 4.0.0
<add> * @license https://opensource.org/licenses/mit-license.php MIT License
<add> */
<add>namespace Cake\Console\Exception;
<add>
<add>/**
<add> * Exception raised with suggestions
<add> */
<add>class NoOptionException extends ConsoleException
<add>{
<add> /**
<add> * The suggestions for the error.
<add> *
<add> * @var string[]
<add> */
<add> protected $suggestions = [];
<add>
<add> /**
<add> * Constructor.
<add> *
<add> * @param string $message The string message.
<add> * @param null $suggestions The code of the error, is also the HTTP status code for the error.
<add> * @param array $code Either the string of the error message, or an array of attributes
<add> * @param \Throwable|null $previous the previous exception.
<add> */
<add> public function __construct(
<add> string $message = '',
<add> array $suggestions = [],
<add> ?int $code = null,
<add> ?Throwable $previous = null
<add> ) {
<add> $this->suggestions = $suggestions;
<add> parent::__construct($message, $code, $previous);
<add> }
<add>
<add> /**
<add> * Get the message with suggestions
<add> *
<add> * @return string
<add> */
<add> public function getFullMessage(): string
<add> {
<add> $out = $this->getMessage();
<add> if ($this->suggestions) {
<add> $suggestions = array_map(function ($item) {
<add> return '`' . $item . '`';
<add> }, $this->suggestions);
<add> $out .= ' Did you mean: ' . implode(', ', $suggestions) . '?';
<add> }
<add>
<add> return $out;
<add> }
<add>
<add> /**
<add> * Get suggestions from exception.
<add> *
<add> * @return string[]
<add> */
<add> public function getSuggetions()
<add> {
<add> return $this->suggestions;
<add> }
<add>}
<ide><path>tests/TestCase/Console/CommandCollectionTest.php
<ide> public function testDiscoverPlugin()
<ide> $this->assertSame($result['company'], $result['company/test_plugin_three.company']);
<ide> $this->clearPlugins();
<ide> }
<add>
<add> /**
<add> * Test suggest
<add> *
<add> * @return void
<add> */
<add> public function testSuggest()
<add> {
<add> $collection = new CommandCollection();
<add> $collection->add('demo', DemoCommand::class);
<add> $collection->add('demo sample', DemoCommand::class);
<add> $collection->add('dang', DemoCommand::class);
<add> $collection->add('woot', DemoCommand::class);
<add> $collection->add('wonder', DemoCommand::class);
<add>
<add> $this->assertEmpty($collection->suggest('nope'));
<add> $this->assertEquals(['demo', 'demo sample'], $collection->suggest('dem'));
<add> $this->assertEquals(['dang'], $collection->suggest('dan'));
<add> $this->assertEquals(['woot', 'wonder'], $collection->suggest('wo'));
<add> $this->assertEquals(['wonder'], $collection->suggest('wander'), 'typos should be found');
<add> }
<ide> }
<ide><path>tests/TestCase/Console/CommandRunnerTest.php
<ide> public function testRunMissingRootCommand()
<ide> */
<ide> public function testRunInvalidCommand()
<ide> {
<del> $this->expectException(\RuntimeException::class);
<del> $this->expectExceptionMessage('Unknown command `cake nope`. Run `cake --help` to get the list of valid commands.');
<ide> $app = $this->getMockBuilder(BaseApplication::class)
<ide> ->setMethods(['middleware', 'bootstrap', 'routes'])
<ide> ->setConstructorArgs([$this->config])
<ide> ->getMock();
<ide>
<add> $output = new ConsoleOutput();
<add> $runner = new CommandRunner($app);
<add> $runner->run(['cake', 'nope', 'nope', 'nope'], $this->getMockIo($output));
<add>
<add> $messages = implode("\n", $output->messages());
<add> $this->assertStringContainsString(
<add> 'Unknown command `cake nope`. Run `cake --help` to get the list of commands.',
<add> $messages
<add> );
<add> }
<add>
<add> /**
<add> * Test that running an unknown command gives suggestions.
<add> *
<add> * @return void
<add> */
<add> public function testRunInvalidCommandSuggestion()
<add> {
<add> $app = $this->getMockBuilder(BaseApplication::class)
<add> ->setMethods(['middleware', 'bootstrap', 'routes'])
<add> ->setConstructorArgs([$this->config])
<add> ->getMock();
<add>
<add> $output = new ConsoleOutput();
<ide> $runner = new CommandRunner($app);
<del> $runner->run(['cake', 'nope', 'nope', 'nope']);
<add> $runner->run(['cake', 'cache'], $this->getMockIo($output));
<add>
<add> $messages = implode("\n", $output->messages());
<add> $this->assertStringContainsString(
<add> 'Did you mean: `cache clear`, `cache clear_all`, `cache list`?',
<add> $messages
<add> );
<ide> }
<ide>
<ide> /** | 5 |
Javascript | Javascript | clarify documentation of `$setviewvalue` | 8f283fe4738b607e3b82924007eeb30fad522137 | <ide><path>src/ng/directive/input.js
<ide> var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
<ide> * @methodOf ng.directive:ngModel.NgModelController
<ide> *
<ide> * @description
<del> * Read a value from view.
<add> * Update the view value.
<ide> *
<del> * This method should be called from within a DOM event handler.
<del> * For example {@link ng.directive:input input} or
<add> * This method should be called when the view value changes, typically from within a DOM event handler.
<add> * For example {@link ng.directive:input input} and
<ide> * {@link ng.directive:select select} directives call it.
<ide> *
<del> * It internally calls all `$parsers` (including validators) and updates the `$modelValue` and the actual model path.
<del> * Lastly it calls all registered change listeners.
<add> * It will update the $viewValue, then pass this value through each of the functions in `$parsers`,
<add> * which includes any validators. The value that comes out of this `$parsers` pipeline, be applied to
<add> * `$modelValue` and the **expression** specified in the `ng-model` attribute.
<add> *
<add> * Lastly, all the registered change listeners, in the `$viewChangeListeners` list, are called.
<add> *
<add> * Note that calling this function does not trigger a `$digest`.
<ide> *
<ide> * @param {string} value Value from the view.
<ide> */ | 1 |
Java | Java | anticipate reactor.test.testsubscriber removal | 5531e807248e3155e7509bea9c1adcc58592157e | <ide><path>spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java
<ide> import org.junit.Test;
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.assertFalse;
<ide><path>spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java
<ide> import org.junit.Test;
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.assertArrayEquals;
<ide><path>spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java
<ide> import org.junit.runner.RunWith;
<ide> import org.junit.runners.Parameterized;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.assertFalse;
<ide><path>spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.ByteArrayResource;
<ide> import org.springframework.core.io.InputStreamResource;
<ide> import org.springframework.core.io.Resource;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide> import org.springframework.util.StreamUtils;
<ide>
<ide><path>spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.ByteArrayResource;
<ide> import org.springframework.core.io.InputStreamResource;
<ide> import org.springframework.core.io.Resource;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.assertTrue;
<ide><path>spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.MimeTypeUtils;
<ide>
<ide> import static org.junit.Assert.assertFalse;
<ide><path>spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide>
<ide><path>spring-core/src/test/java/org/springframework/tests/TestSubscriber.java
<add>/*
<add> * Copyright (c) 2011-2016 Pivotal Software Inc, All Rights Reserved.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * http://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>
<add>package org.springframework.tests;
<add>
<add>import java.time.Duration;
<add>import java.util.ArrayList;
<add>import java.util.Arrays;
<add>import java.util.Iterator;
<add>import java.util.LinkedList;
<add>import java.util.List;
<add>import java.util.Objects;
<add>import java.util.Set;
<add>import java.util.concurrent.CountDownLatch;
<add>import java.util.concurrent.TimeUnit;
<add>import java.util.concurrent.atomic.AtomicLongFieldUpdater;
<add>import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
<add>import java.util.function.BooleanSupplier;
<add>import java.util.function.Consumer;
<add>import java.util.function.Supplier;
<add>
<add>import org.reactivestreams.Publisher;
<add>import org.reactivestreams.Subscriber;
<add>import org.reactivestreams.Subscription;
<add>import reactor.core.Fuseable;
<add>import reactor.core.Receiver;
<add>import reactor.core.Trackable;
<add>import reactor.core.publisher.Operators;
<add>
<add>/**
<add> * A Reactor based Subscriber implementation that hosts assertion tests for its state and
<add> * allows asynchronous cancellation and requesting.
<add> *
<add> * <p> To create a new instance of {@link TestSubscriber}, you have the choice between
<add> * these static methods:
<add> * <ul>
<add> * <li>{@link TestSubscriber#subscribe(Publisher)}: create a new {@link TestSubscriber},
<add> * subscribe to it with the specified {@link Publisher} and requests an unbounded
<add> * number of elements.</li>
<add> * <li>{@link TestSubscriber#subscribe(Publisher, long)}: create a new {@link TestSubscriber},
<add> * subscribe to it with the specified {@link Publisher} and requests {@code n} elements
<add> * (can be 0 if you want no initial demand).
<add> * <li>{@link TestSubscriber#create()}: create a new {@link TestSubscriber} and requests
<add> * an unbounded number of elements.</li>
<add> * <li>{@link TestSubscriber#create(long)}: create a new {@link TestSubscriber} and
<add> * requests {@code n} elements (can be 0 if you want no initial demand).
<add> * </ul>
<add> *
<add> * <p>If you are testing asynchronous publishers, don't forget to use one of the
<add> * {@code await*()} methods to wait for the data to assert.
<add> *
<add> * <p> You can extend this class but only the onNext, onError and onComplete can be overridden.
<add> * You can call {@link #request(long)} and {@link #cancel()} from any thread or from within
<add> * the overridable methods but you should avoid calling the assertXXX methods asynchronously.
<add> *
<add> * <p>Usage:
<add> * <pre>
<add> * {@code
<add> * TestSubscriber
<add> * .subscribe(publisher)
<add> * .await()
<add> * .assertValues("ABC", "DEF");
<add> * }
<add> * </pre>
<add> *
<add> * @param <T> the value type.
<add> *
<add> * @author Sebastien Deleuze
<add> * @author David Karnok
<add> * @author Anatoly Kadyshev
<add> * @author Stephane Maldini
<add> * @author Brian Clozel
<add> */
<add>public class TestSubscriber<T>
<add> implements Subscriber<T>, Subscription, Trackable, Receiver {
<add>
<add> /**
<add> * Default timeout for waiting next values to be received
<add> */
<add> public static final Duration DEFAULT_VALUES_TIMEOUT = Duration.ofSeconds(3);
<add>
<add> @SuppressWarnings("rawtypes")
<add> private static final AtomicLongFieldUpdater<TestSubscriber> REQUESTED =
<add> AtomicLongFieldUpdater.newUpdater(TestSubscriber.class, "requested");
<add>
<add> @SuppressWarnings("rawtypes")
<add> private static final AtomicReferenceFieldUpdater<TestSubscriber, List> NEXT_VALUES =
<add> AtomicReferenceFieldUpdater.newUpdater(TestSubscriber.class, List.class,
<add> "values");
<add>
<add> @SuppressWarnings("rawtypes")
<add> private static final AtomicReferenceFieldUpdater<TestSubscriber, Subscription> S =
<add> AtomicReferenceFieldUpdater.newUpdater(TestSubscriber.class, Subscription.class, "s");
<add>
<add>
<add> private final List<Throwable> errors = new LinkedList<>();
<add>
<add> private final CountDownLatch cdl = new CountDownLatch(1);
<add>
<add> volatile Subscription s;
<add>
<add> volatile long requested;
<add>
<add> volatile List<T> values = new LinkedList<>();
<add>
<add> /**
<add> * The fusion mode to request.
<add> */
<add> private int requestedFusionMode = -1;
<add>
<add> /**
<add> * The established fusion mode.
<add> */
<add> private volatile int establishedFusionMode = -1;
<add>
<add> /**
<add> * The fuseable QueueSubscription in case a fusion mode was specified.
<add> */
<add> private Fuseable.QueueSubscription<T> qs;
<add>
<add> private int subscriptionCount = 0;
<add>
<add> private int completionCount = 0;
<add>
<add> private volatile long valueCount = 0L;
<add>
<add> private volatile long nextValueAssertedCount = 0L;
<add>
<add> private Duration valuesTimeout = DEFAULT_VALUES_TIMEOUT;
<add>
<add> private boolean valuesStorage = true;
<add>
<add>// ==============================================================================================================
<add>// Static methods
<add>// ==============================================================================================================
<add>
<add> /**
<add> * Blocking method that waits until {@code conditionSupplier} returns true, or if it
<add> * does not before the specified timeout, throws an {@link AssertionError} with the
<add> * specified error message supplier.
<add> *
<add> * @param timeout the timeout duration
<add> * @param errorMessageSupplier the error message supplier
<add> * @param conditionSupplier condition to break out of the wait loop
<add> *
<add> * @throws AssertionError
<add> */
<add> public static void await(Duration timeout, Supplier<String> errorMessageSupplier,
<add> BooleanSupplier conditionSupplier) {
<add>
<add> Objects.requireNonNull(errorMessageSupplier);
<add> Objects.requireNonNull(conditionSupplier);
<add> Objects.requireNonNull(timeout);
<add>
<add> long timeoutNs = timeout.toNanos();
<add> long startTime = System.nanoTime();
<add> do {
<add> if (conditionSupplier.getAsBoolean()) {
<add> return;
<add> }
<add> try {
<add> Thread.sleep(100);
<add> }
<add> catch (InterruptedException e) {
<add> Thread.currentThread().interrupt();
<add> throw new RuntimeException(e);
<add> }
<add> }
<add> while (System.nanoTime() - startTime < timeoutNs);
<add> throw new AssertionError(errorMessageSupplier.get());
<add> }
<add>
<add> /**
<add> * Blocking method that waits until {@code conditionSupplier} returns true, or if it
<add> * does not before the specified timeout, throw an {@link AssertionError} with the
<add> * specified error message.
<add> *
<add> * @param timeout the timeout duration
<add> * @param errorMessage the error message
<add> * @param conditionSupplier condition to break out of the wait loop
<add> *
<add> * @throws AssertionError
<add> */
<add> public static void await(Duration timeout,
<add> final String errorMessage,
<add> BooleanSupplier conditionSupplier) {
<add> await(timeout, new Supplier<String>() {
<add> @Override
<add> public String get() {
<add> return errorMessage;
<add> }
<add> }, conditionSupplier);
<add> }
<add>
<add> /**
<add> * Create a new {@link TestSubscriber} that requests an unbounded number of elements.
<add> * <p>Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)}
<add> * before use assert methods.
<add> * @see #subscribe(Publisher)
<add> * @param <T> the observed value type
<add> * @return a fresh TestSubscriber instance
<add> */
<add> public static <T> TestSubscriber<T> create() {
<add> return new TestSubscriber<>();
<add> }
<add>
<add> /**
<add> * Create a new {@link TestSubscriber} that requests initially {@code n} elements. You
<add> * can then manage the demand with {@link Subscription#request(long)}.
<add> * <p>Be sure at least a publisher has subscribed to it via {@link Publisher#subscribe(Subscriber)}
<add> * before use assert methods.
<add> * @param n Number of elements to request (can be 0 if you want no initial demand).
<add> * @see #subscribe(Publisher, long)
<add> * @param <T> the observed value type
<add> * @return a fresh TestSubscriber instance
<add> */
<add> public static <T> TestSubscriber<T> create(long n) {
<add> return new TestSubscriber<>(n);
<add> }
<add>
<add> /**
<add> * Create a new {@link TestSubscriber} that requests an unbounded number of elements,
<add> * and make the specified {@code publisher} subscribe to it.
<add> * @param publisher The publisher to subscribe with
<add> * @param <T> the observed value type
<add> * @return a fresh TestSubscriber instance
<add> */
<add> public static <T> TestSubscriber<T> subscribe(Publisher<T> publisher) {
<add> TestSubscriber<T> subscriber = new TestSubscriber<>();
<add> publisher.subscribe(subscriber);
<add> return subscriber;
<add> }
<add>
<add> /**
<add> * Create a new {@link TestSubscriber} that requests initially {@code n} elements,
<add> * and make the specified {@code publisher} subscribe to it. You can then manage the
<add> * demand with {@link Subscription#request(long)}.
<add> * @param publisher The publisher to subscribe with
<add> * @param n Number of elements to request (can be 0 if you want no initial demand).
<add> * @param <T> the observed value type
<add> * @return a fresh TestSubscriber instance
<add> */
<add> public static <T> TestSubscriber<T> subscribe(Publisher<T> publisher, long n) {
<add> TestSubscriber<T> subscriber = new TestSubscriber<>(n);
<add> publisher.subscribe(subscriber);
<add> return subscriber;
<add> }
<add>
<add>// ==============================================================================================================
<add>// Private constructors
<add>// ==============================================================================================================
<add>
<add> private TestSubscriber() {
<add> this(Long.MAX_VALUE);
<add> }
<add>
<add> private TestSubscriber(long n) {
<add> if (n < 0) {
<add> throw new IllegalArgumentException("initialRequest >= required but it was " + n);
<add> }
<add> REQUESTED.lazySet(this, n);
<add> }
<add>
<add>// ==============================================================================================================
<add>// Configuration
<add>// ==============================================================================================================
<add>
<add>
<add> /**
<add> * Enable or disabled the values storage. It is enabled by default, and can be disable
<add> * in order to be able to perform performance benchmarks or tests with a huge amount
<add> * values.
<add> * @param enabled enable value storage?
<add> * @return this
<add> */
<add> public final TestSubscriber<T> configureValuesStorage(boolean enabled) {
<add> this.valuesStorage = enabled;
<add> return this;
<add> }
<add>
<add> /**
<add> * Configure the timeout in seconds for waiting next values to be received (3 seconds
<add> * by default).
<add> * @param timeout the new default value timeout duration
<add> * @return this
<add> */
<add> public final TestSubscriber<T> configureValuesTimeout(Duration timeout) {
<add> this.valuesTimeout = timeout;
<add> return this;
<add> }
<add>
<add> /**
<add> * Returns the established fusion mode or -1 if it was not enabled
<add> *
<add> * @return the fusion mode, see Fuseable constants
<add> */
<add> public final int establishedFusionMode() {
<add> return establishedFusionMode;
<add> }
<add>
<add>// ==============================================================================================================
<add>// Assertions
<add>// ==============================================================================================================
<add>
<add> /**
<add> * Assert a complete successfully signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertComplete() {
<add> assertNoError();
<add> int c = completionCount;
<add> if (c == 0) {
<add> throw new AssertionError("Not completed", null);
<add> }
<add> if (c > 1) {
<add> throw new AssertionError("Multiple completions: " + c, null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert the specified values have been received. Values storage should be enabled to
<add> * use this method.
<add> * @param expectedValues the values to assert
<add> * @see #configureValuesStorage(boolean)
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertContainValues(Set<? extends T> expectedValues) {
<add> if (!valuesStorage) {
<add> throw new IllegalStateException(
<add> "Using assertNoValues() requires enabling values storage");
<add> }
<add> if (expectedValues.size() > values.size()) {
<add> throw new AssertionError("Actual contains fewer elements" + values, null);
<add> }
<add>
<add> Iterator<? extends T> expected = expectedValues.iterator();
<add>
<add> for (; ; ) {
<add> boolean n2 = expected.hasNext();
<add> if (n2) {
<add> T t2 = expected.next();
<add> if (!values.contains(t2)) {
<add> throw new AssertionError("The element is not contained in the " +
<add> "received resuls" +
<add> " = " + valueAndClass(t2), null);
<add> }
<add> }
<add> else{
<add> break;
<add> }
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert an error signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertError() {
<add> assertNotComplete();
<add> int s = errors.size();
<add> if (s == 0) {
<add> throw new AssertionError("No error", null);
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("Multiple errors: " + s, null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert an error signal has been received.
<add> * @param clazz The class of the exception contained in the error signal
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertError(Class<? extends Throwable> clazz) {
<add> assertNotComplete();
<add> int s = errors.size();
<add> if (s == 0) {
<add> throw new AssertionError("No error", null);
<add> }
<add> if (s == 1) {
<add> Throwable e = errors.get(0);
<add> if (!clazz.isInstance(e)) {
<add> throw new AssertionError("Error class incompatible: expected = " +
<add> clazz + ", actual = " + e, null);
<add> }
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("Multiple errors: " + s, null);
<add> }
<add> return this;
<add> }
<add>
<add> public final TestSubscriber<T> assertErrorMessage(String message) {
<add> assertNotComplete();
<add> int s = errors.size();
<add> if (s == 0) {
<add> assertionError("No error", null);
<add> }
<add> if (s == 1) {
<add> if (!Objects.equals(message,
<add> errors.get(0)
<add> .getMessage())) {
<add> assertionError("Error class incompatible: expected = \"" + message +
<add> "\", actual = \"" + errors.get(0).getMessage() + "\"", null);
<add> }
<add> }
<add> if (s > 1) {
<add> assertionError("Multiple errors: " + s, null);
<add> }
<add>
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert an error signal has been received.
<add> * @param expectation A method that can verify the exception contained in the error signal
<add> * and throw an exception (like an {@link AssertionError}) if the exception is not valid.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertErrorWith(Consumer<? super Throwable> expectation) {
<add> assertNotComplete();
<add> int s = errors.size();
<add> if (s == 0) {
<add> throw new AssertionError("No error", null);
<add> }
<add> if (s == 1) {
<add> expectation.accept(errors.get(0));
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("Multiple errors: " + s, null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert that the upstream was a Fuseable source.
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertFuseableSource() {
<add> if (qs == null) {
<add> throw new AssertionError("Upstream was not Fuseable");
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert that the fusion mode was granted.
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertFusionEnabled() {
<add> if (establishedFusionMode != Fuseable.SYNC && establishedFusionMode != Fuseable.ASYNC) {
<add> throw new AssertionError("Fusion was not enabled");
<add> }
<add> return this;
<add> }
<add>
<add> public final TestSubscriber<T> assertFusionMode(int expectedMode) {
<add> if (establishedFusionMode != expectedMode) {
<add> throw new AssertionError("Wrong fusion mode: expected: " + fusionModeName(
<add> expectedMode) + ", actual: " + fusionModeName(establishedFusionMode));
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert that the fusion mode was granted.
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertFusionRejected() {
<add> if (establishedFusionMode != Fuseable.NONE) {
<add> throw new AssertionError("Fusion was granted");
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert no error signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNoError() {
<add> int s = errors.size();
<add> if (s == 1) {
<add> Throwable e = errors.get(0);
<add> String valueAndClass = e == null ? null : e + " (" + e.getClass().getSimpleName() + ")";
<add> throw new AssertionError("Error present: " + valueAndClass, null);
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("Multiple errors: " + s, null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert no values have been received.
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNoValues() {
<add> if (valueCount != 0) {
<add> throw new AssertionError("No values expected but received: [length = " + values.size() + "] " + values,
<add> null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert that the upstream was not a Fuseable source.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNonFuseableSource() {
<add> if (qs != null) {
<add> throw new AssertionError("Upstream was Fuseable");
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert no complete successfully signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNotComplete() {
<add> int c = completionCount;
<add> if (c == 1) {
<add> throw new AssertionError("Completed", null);
<add> }
<add> if (c > 1) {
<add> throw new AssertionError("Multiple completions: " + c, null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert no subscription occurred.
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNotSubscribed() {
<add> int s = subscriptionCount;
<add>
<add> if (s == 1) {
<add> throw new AssertionError("OnSubscribe called once", null);
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("OnSubscribe called multiple times: " + s, null);
<add> }
<add>
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert no complete successfully or error signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertNotTerminated() {
<add> if (cdl.getCount() == 0) {
<add> throw new AssertionError("Terminated", null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert subscription occurred (once).
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertSubscribed() {
<add> int s = subscriptionCount;
<add>
<add> if (s == 0) {
<add> throw new AssertionError("OnSubscribe not called", null);
<add> }
<add> if (s > 1) {
<add> throw new AssertionError("OnSubscribe called multiple times: " + s, null);
<add> }
<add>
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert either complete successfully or error signal has been received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertTerminated() {
<add> if (cdl.getCount() != 0) {
<add> throw new AssertionError("Not terminated", null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert {@code n} values has been received.
<add> *
<add> * @param n the expected value count
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertValueCount(long n) {
<add> if (valueCount != n) {
<add> throw new AssertionError("Different value count: expected = " + n + ", actual = " + valueCount,
<add> null);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert the specified values have been received in the same order read by the
<add> * passed {@link Iterable}. Values storage
<add> * should be enabled to
<add> * use this method.
<add> * @param expectedSequence the values to assert
<add> * @see #configureValuesStorage(boolean)
<add> * @return this
<add> */
<add> public final TestSubscriber<T> assertValueSequence(Iterable<? extends T> expectedSequence) {
<add> if (!valuesStorage) {
<add> throw new IllegalStateException("Using assertNoValues() requires enabling values storage");
<add> }
<add> Iterator<T> actual = values.iterator();
<add> Iterator<? extends T> expected = expectedSequence.iterator();
<add> int i = 0;
<add> for (; ; ) {
<add> boolean n1 = actual.hasNext();
<add> boolean n2 = expected.hasNext();
<add> if (n1 && n2) {
<add> T t1 = actual.next();
<add> T t2 = expected.next();
<add> if (!Objects.equals(t1, t2)) {
<add> throw new AssertionError("The element with index " + i + " does not match: expected = " + valueAndClass(t2) + ", actual = "
<add> + valueAndClass(
<add> t1), null);
<add> }
<add> i++;
<add> } else if (n1 && !n2) {
<add> throw new AssertionError("Actual contains more elements" + values, null);
<add> } else if (!n1 && n2) {
<add> throw new AssertionError("Actual contains fewer elements: " + values, null);
<add> } else {
<add> break;
<add> }
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Assert the specified values have been received in the declared order. Values
<add> * storage should be enabled to use this method.
<add> *
<add> * @param expectedValues the values to assert
<add> *
<add> * @return this
<add> *
<add> * @see #configureValuesStorage(boolean)
<add> */
<add> @SafeVarargs
<add> public final TestSubscriber<T> assertValues(T... expectedValues) {
<add> return assertValueSequence(Arrays.asList(expectedValues));
<add> }
<add>
<add> /**
<add> * Assert the specified values have been received in the declared order. Values
<add> * storage should be enabled to use this method.
<add> *
<add> * @param expectations One or more methods that can verify the values and throw a
<add> * exception (like an {@link AssertionError}) if the value is not valid.
<add> *
<add> * @return this
<add> *
<add> * @see #configureValuesStorage(boolean)
<add> */
<add> @SafeVarargs
<add> public final TestSubscriber<T> assertValuesWith(Consumer<T>... expectations) {
<add> if (!valuesStorage) {
<add> throw new IllegalStateException(
<add> "Using assertNoValues() requires enabling values storage");
<add> }
<add> final int expectedValueCount = expectations.length;
<add> if (expectedValueCount != values.size()) {
<add> throw new AssertionError("Different value count: expected = " + expectedValueCount + ", actual = " + valueCount, null);
<add> }
<add> for (int i = 0; i < expectedValueCount; i++) {
<add> Consumer<T> consumer = expectations[i];
<add> T actualValue = values.get(i);
<add> consumer.accept(actualValue);
<add> }
<add> return this;
<add> }
<add>
<add>// ==============================================================================================================
<add>// Await methods
<add>// ==============================================================================================================
<add>
<add> /**
<add> * Blocking method that waits until a complete successfully or error signal is received.
<add> * @return this
<add> */
<add> public final TestSubscriber<T> await() {
<add> if (cdl.getCount() == 0) {
<add> return this;
<add> }
<add> try {
<add> cdl.await();
<add> } catch (InterruptedException ex) {
<add> throw new AssertionError("Wait interrupted", ex);
<add> }
<add> return this;
<add> }
<add>
<add> /**
<add> * Blocking method that waits until a complete successfully or error signal is received
<add> * or until a timeout occurs.
<add> * @param timeout The timeout value
<add> * @return this
<add> */
<add> public final TestSubscriber<T> await(Duration timeout) {
<add> if (cdl.getCount() == 0) {
<add> return this;
<add> }
<add> try {
<add> if (!cdl.await(timeout.toMillis(), TimeUnit.MILLISECONDS)) {
<add> throw new AssertionError("No complete or error signal before timeout");
<add> }
<add> return this;
<add> }
<add> catch (InterruptedException ex) {
<add> throw new AssertionError("Wait interrupted", ex);
<add> }
<add> }
<add>
<add> /**
<add> * Blocking method that waits until {@code n} next values have been received.
<add> *
<add> * @param n the value count to assert
<add> *
<add> * @return this
<add> */
<add> public final TestSubscriber<T> awaitAndAssertNextValueCount(final long n) {
<add> await(valuesTimeout, () -> {
<add> if(valuesStorage){
<add> return String.format("%d out of %d next values received within %d, " +
<add> "values : %s",
<add> valueCount - nextValueAssertedCount,
<add> n,
<add> valuesTimeout.toMillis(),
<add> values.toString()
<add> );
<add> }
<add> return String.format("%d out of %d next values received within %d",
<add> valueCount - nextValueAssertedCount,
<add> n,
<add> valuesTimeout.toMillis());
<add> }, () -> valueCount >= (nextValueAssertedCount + n));
<add> nextValueAssertedCount += n;
<add> return this;
<add> }
<add>
<add> /**
<add> * Blocking method that waits until {@code n} next values have been received (n is the
<add> * number of values provided) to assert them.
<add> *
<add> * @param values the values to assert
<add> *
<add> * @return this
<add> */
<add> @SafeVarargs
<add> @SuppressWarnings("unchecked")
<add> public final TestSubscriber<T> awaitAndAssertNextValues(T... values) {
<add> final int expectedNum = values.length;
<add> final List<Consumer<T>> expectations = new ArrayList<>();
<add> for (int i = 0; i < expectedNum; i++) {
<add> final T expectedValue = values[i];
<add> expectations.add(actualValue -> {
<add> if (!actualValue.equals(expectedValue)) {
<add> throw new AssertionError(String.format(
<add> "Expected Next signal: %s, but got: %s",
<add> expectedValue,
<add> actualValue));
<add> }
<add> });
<add> }
<add> awaitAndAssertNextValuesWith(expectations.toArray((Consumer<T>[]) new Consumer[0]));
<add> return this;
<add> }
<add>
<add> /**
<add> * Blocking method that waits until {@code n} next values have been received
<add> * (n is the number of expectations provided) to assert them.
<add> * @param expectations One or more methods that can verify the values and throw a
<add> * exception (like an {@link AssertionError}) if the value is not valid.
<add> * @return this
<add> */
<add> @SafeVarargs
<add> public final TestSubscriber<T> awaitAndAssertNextValuesWith(Consumer<T>... expectations) {
<add> valuesStorage = true;
<add> final int expectedValueCount = expectations.length;
<add> await(valuesTimeout, () -> {
<add> if(valuesStorage){
<add> return String.format("%d out of %d next values received within %d, " +
<add> "values : %s",
<add> valueCount - nextValueAssertedCount,
<add> expectedValueCount,
<add> valuesTimeout.toMillis(),
<add> values.toString()
<add> );
<add> }
<add> return String.format("%d out of %d next values received within %d ms",
<add> valueCount - nextValueAssertedCount,
<add> expectedValueCount,
<add> valuesTimeout.toMillis());
<add> }, () -> valueCount >= (nextValueAssertedCount + expectedValueCount));
<add> List<T> nextValuesSnapshot;
<add> List<T> empty = new ArrayList<>();
<add> for(;;){
<add> nextValuesSnapshot = values;
<add> if(NEXT_VALUES.compareAndSet(this, values, empty)){
<add> break;
<add> }
<add> }
<add> if (nextValuesSnapshot.size() < expectedValueCount) {
<add> throw new AssertionError(String.format("Expected %d number of signals but received %d",
<add> expectedValueCount,
<add> nextValuesSnapshot.size()));
<add> }
<add> for (int i = 0; i < expectedValueCount; i++) {
<add> Consumer<T> consumer = expectations[i];
<add> T actualValue = nextValuesSnapshot.get(i);
<add> consumer.accept(actualValue);
<add> }
<add> nextValueAssertedCount += expectedValueCount;
<add> return this;
<add> }
<add>
<add>// ==============================================================================================================
<add>// Overrides
<add>// ==============================================================================================================
<add>
<add> @Override
<add> public void cancel() {
<add> Subscription a = s;
<add> if (a != Operators.cancelledSubscription()) {
<add> a = S.getAndSet(this, Operators.cancelledSubscription());
<add> if (a != null && a != Operators.cancelledSubscription()) {
<add> a.cancel();
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public final boolean isCancelled() {
<add> return s == Operators.cancelledSubscription();
<add> }
<add>
<add> @Override
<add> public final boolean isStarted() {
<add> return s != null;
<add> }
<add>
<add> @Override
<add> public final boolean isTerminated() {
<add> return isCancelled();
<add> }
<add>
<add> @Override
<add> public void onComplete() {
<add> completionCount++;
<add> cdl.countDown();
<add> }
<add>
<add> @Override
<add> public void onError(Throwable t) {
<add> errors.add(t);
<add> cdl.countDown();
<add> }
<add>
<add> @Override
<add> public void onNext(T t) {
<add> if (establishedFusionMode == Fuseable.ASYNC) {
<add> for (; ; ) {
<add> t = qs.poll();
<add> if (t == null) {
<add> break;
<add> }
<add> valueCount++;
<add> if (valuesStorage) {
<add> List<T> nextValuesSnapshot;
<add> for (; ; ) {
<add> nextValuesSnapshot = values;
<add> nextValuesSnapshot.add(t);
<add> if (NEXT_VALUES.compareAndSet(this,
<add> nextValuesSnapshot,
<add> nextValuesSnapshot)) {
<add> break;
<add> }
<add> }
<add> }
<add> }
<add> }
<add> else {
<add> valueCount++;
<add> if (valuesStorage) {
<add> List<T> nextValuesSnapshot;
<add> for (; ; ) {
<add> nextValuesSnapshot = values;
<add> nextValuesSnapshot.add(t);
<add> if (NEXT_VALUES.compareAndSet(this,
<add> nextValuesSnapshot,
<add> nextValuesSnapshot)) {
<add> break;
<add> }
<add> }
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> @SuppressWarnings("unchecked")
<add> public void onSubscribe(Subscription s) {
<add> subscriptionCount++;
<add> int requestMode = requestedFusionMode;
<add> if (requestMode >= 0) {
<add> if (!setWithoutRequesting(s)) {
<add> if (!isCancelled()) {
<add> errors.add(new IllegalStateException("Subscription already set: " +
<add> subscriptionCount));
<add> }
<add> } else {
<add> if (s instanceof Fuseable.QueueSubscription) {
<add> this.qs = (Fuseable.QueueSubscription<T>)s;
<add>
<add> int m = qs.requestFusion(requestMode);
<add> establishedFusionMode = m;
<add>
<add> if (m == Fuseable.SYNC) {
<add> for (;;) {
<add> T v = qs.poll();
<add> if (v == null) {
<add> onComplete();
<add> break;
<add> }
<add>
<add> onNext(v);
<add> }
<add> }
<add> else {
<add> requestDeferred();
<add> }
<add> }
<add> else {
<add> requestDeferred();
<add> }
<add> }
<add> } else {
<add> if (!set(s)) {
<add> if (!isCancelled()) {
<add> errors.add(new IllegalStateException("Subscription already set: " +
<add> subscriptionCount));
<add> }
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public void request(long n) {
<add> if (Operators.validate(n)) {
<add> if (establishedFusionMode != Fuseable.SYNC) {
<add> normalRequest(n);
<add> }
<add> }
<add> }
<add>
<add> @Override
<add> public final long requestedFromDownstream() {
<add> return requested;
<add> }
<add>
<add> /**
<add> * Setup what fusion mode should be requested from the incomining
<add> * Subscription if it happens to be QueueSubscription
<add> * @param requestMode the mode to request, see Fuseable constants
<add> * @return this
<add> */
<add> public final TestSubscriber<T> requestedFusionMode(int requestMode) {
<add> this.requestedFusionMode = requestMode;
<add> return this;
<add> }
<add>
<add> @Override
<add> public Subscription upstream() {
<add> return s;
<add> }
<add>
<add>
<add>// ==============================================================================================================
<add>// Non public methods
<add>// ==============================================================================================================
<add>
<add> protected final void normalRequest(long n) {
<add> Subscription a = s;
<add> if (a != null) {
<add> a.request(n);
<add> } else {
<add> Operators.addAndGet(REQUESTED, this, n);
<add>
<add> a = s;
<add>
<add> if (a != null) {
<add> long r = REQUESTED.getAndSet(this, 0L);
<add>
<add> if (r != 0L) {
<add> a.request(r);
<add> }
<add> }
<add> }
<add> }
<add>
<add> /**
<add> * Requests the deferred amount if not zero.
<add> */
<add> protected final void requestDeferred() {
<add> long r = REQUESTED.getAndSet(this, 0L);
<add>
<add> if (r != 0L) {
<add> s.request(r);
<add> }
<add> }
<add>
<add> /**
<add> * Atomically sets the single subscription and requests the missed amount from it.
<add> *
<add> * @param s
<add> * @return false if this arbiter is cancelled or there was a subscription already set
<add> */
<add> protected final boolean set(Subscription s) {
<add> Objects.requireNonNull(s, "s");
<add> Subscription a = this.s;
<add> if (a == Operators.cancelledSubscription()) {
<add> s.cancel();
<add> return false;
<add> }
<add> if (a != null) {
<add> s.cancel();
<add> Operators.reportSubscriptionSet();
<add> return false;
<add> }
<add>
<add> if (S.compareAndSet(this, null, s)) {
<add>
<add> long r = REQUESTED.getAndSet(this, 0L);
<add>
<add> if (r != 0L) {
<add> s.request(r);
<add> }
<add>
<add> return true;
<add> }
<add>
<add> a = this.s;
<add>
<add> if (a != Operators.cancelledSubscription()) {
<add> s.cancel();
<add> return false;
<add> }
<add>
<add> Operators.reportSubscriptionSet();
<add> return false;
<add> }
<add>
<add> /**
<add> * Sets the Subscription once but does not request anything.
<add> * @param s the Subscription to set
<add> * @return true if successful, false if the current subscription is not null
<add> */
<add> protected final boolean setWithoutRequesting(Subscription s) {
<add> Objects.requireNonNull(s, "s");
<add> for (;;) {
<add> Subscription a = this.s;
<add> if (a == Operators.cancelledSubscription()) {
<add> s.cancel();
<add> return false;
<add> }
<add> if (a != null) {
<add> s.cancel();
<add> Operators.reportSubscriptionSet();
<add> return false;
<add> }
<add>
<add> if (S.compareAndSet(this, null, s)) {
<add> return true;
<add> }
<add> }
<add> }
<add>
<add> /**
<add> * Prepares and throws an AssertionError exception based on the message, cause, the
<add> * active state and the potential errors so far.
<add> *
<add> * @param message the message
<add> * @param cause the optional Throwable cause
<add> *
<add> * @throws AssertionError as expected
<add> */
<add> protected final void assertionError(String message, Throwable cause) {
<add> StringBuilder b = new StringBuilder();
<add>
<add> if (cdl.getCount() != 0) {
<add> b.append("(active) ");
<add> }
<add> b.append(message);
<add>
<add> List<Throwable> err = errors;
<add> if (!err.isEmpty()) {
<add> b.append(" (+ ")
<add> .append(err.size())
<add> .append(" errors)");
<add> }
<add> AssertionError e = new AssertionError(b.toString(), cause);
<add>
<add> for (Throwable t : err) {
<add> e.addSuppressed(t);
<add> }
<add>
<add> throw e;
<add> }
<add>
<add> protected final String fusionModeName(int mode) {
<add> switch (mode) {
<add> case -1:
<add> return "Disabled";
<add> case Fuseable.NONE:
<add> return "None";
<add> case Fuseable.SYNC:
<add> return "Sync";
<add> case Fuseable.ASYNC:
<add> return "Async";
<add> default:
<add> return "Unknown(" + mode + ")";
<add> }
<add> }
<add>
<add> protected final String valueAndClass(Object o) {
<add> if (o == null) {
<add> return null;
<add> }
<add> return o + " (" + o.getClass().getSimpleName() + ")";
<add> }
<add>
<add>}
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java
<ide> import org.junit.Test;
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.context.annotation.Bean;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.stereotype.Controller;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.bind.annotation.RequestBody;
<ide> import org.springframework.web.bind.annotation.RequestMapping;
<ide> import org.springframework.web.bind.annotation.ResponseBody;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/ResponseStatusExceptionHandlerTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.http.HttpMethod;
<ide> import org.springframework.http.HttpStatus;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.server.ResponseStatusException;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide> import org.springframework.web.server.adapter.DefaultServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.http.HttpMethod;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<ide> import org.springframework.stereotype.Controller;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.AntPathMatcher;
<ide> import org.springframework.util.PathMatcher;
<ide> import org.springframework.web.bind.annotation.RequestMapping;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.http.HttpMethod;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.ui.ModelMap;
<ide> import org.springframework.web.reactive.HandlerResult;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.annotation.AnnotatedElementUtils;
<ide> import org.springframework.core.annotation.AnnotationUtils;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<ide> import org.springframework.stereotype.Controller;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.ui.ModelMap;
<ide> import org.springframework.util.MultiValueMap;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.bind.annotation.CookieValue;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide> import org.springframework.web.server.ServerWebInputException;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityArgumentResolverTests.java
<ide> import reactor.adapter.RxJava1Adapter;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Observable;
<ide> import rx.Single;
<ide>
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.ui.ExtendedModelMap;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.validation.Validator;
<ide> import org.springframework.web.reactive.result.ResolvableMethod;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Observable;
<ide> import rx.Single;
<ide>
<ide> import org.springframework.http.codec.json.Jackson2JsonDecoder;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.validation.Errors;
<ide> import org.springframework.validation.Validator;
<ide> import org.springframework.validation.annotation.Validated;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Completable;
<ide> import rx.Observable;
<ide>
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ObjectUtils;
<ide> import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
<ide> import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.core.convert.ConversionService;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ModelMap;
<ide> import org.springframework.web.bind.annotation.PathVariable;
<ide> import org.springframework.web.reactive.HandlerMapping;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.core.DefaultParameterNameDiscoverer;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ReflectionUtils;
<ide> import org.springframework.web.bind.annotation.RequestAttribute;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyArgumentResolverTests.java
<ide> import reactor.adapter.RxJava1Adapter;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Observable;
<ide> import rx.Single;
<ide>
<ide> import org.springframework.http.codec.HttpMessageReader;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.validation.Validator;
<ide> import org.springframework.web.bind.annotation.RequestBody;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ReflectionUtils;
<ide> import org.springframework.web.bind.annotation.RequestHeader;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ReflectionUtils;
<ide> import org.springframework.web.bind.annotation.RequestParam;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Completable;
<ide> import rx.Single;
<ide>
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ObjectUtils;
<ide> import org.springframework.web.reactive.HandlerResult;
<ide> import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.core.DefaultParameterNameDiscoverer;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpRequest;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.util.ReflectionUtils;
<ide> import org.springframework.web.bind.annotation.SessionAttribute;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.annotation.AnnotationConfigApplicationContext;
<ide> import org.springframework.context.annotation.Bean;
<ide> import org.springframework.http.codec.SseEvent;
<ide> import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests;
<ide> import org.springframework.http.server.reactive.HttpHandler;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.bind.annotation.RequestMapping;
<ide> import org.springframework.web.bind.annotation.RestController;
<ide> import org.springframework.web.client.reactive.WebClient;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java
<ide>
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.MethodParameter;
<ide> import org.springframework.core.codec.CharSequenceEncoder;
<ide> import org.springframework.http.codec.xml.Jaxb2XmlEncoder;
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.ui.ModelMap;
<ide> import org.springframework.util.MimeType;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide> import rx.Completable;
<ide> import rx.Single;
<ide>
<ide> import org.springframework.http.server.reactive.MockServerHttpRequest;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.http.server.reactive.ServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.ui.Model;
<ide> import org.springframework.ui.ModelMap;
<ide><path>spring-web-reactive/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java
<ide> import org.junit.Rule;
<ide> import org.junit.Test;
<ide> import org.junit.rules.ExpectedException;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.context.ApplicationContextException;
<ide> import org.springframework.context.support.GenericApplicationContext;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<ide> import org.springframework.ui.ExtendedModelMap;
<ide> import org.springframework.ui.ModelMap;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.reactive.HandlerResult;
<ide> import org.springframework.web.server.ServerWebExchange;
<ide> import org.springframework.web.server.adapter.DefaultServerWebExchange;
<ide><path>spring-web/src/test/java/org/springframework/http/codec/SseEventHttpMessageWriterTests.java
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.codec.json.Jackson2JsonEncoder;
<ide> import org.springframework.http.server.reactive.MockServerHttpResponse;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide>
<ide><path>spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.codec.Pojo;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide>
<ide><path>spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.codec.Pojo;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide>
<ide><path>spring-web/src/test/java/org/springframework/http/codec/json/JsonObjectDecoderTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> /**
<ide> * @author Sebastien Deleuze
<ide><path>spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.http.codec.xml.jaxb.XmlType;
<ide> import org.springframework.http.codec.xml.jaxb.XmlTypeWithName;
<ide> import org.springframework.http.codec.xml.jaxb.XmlTypeWithNameAndNamespace;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide>
<ide><path>spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.ResolvableType;
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<ide> import org.springframework.core.io.buffer.support.DataBufferTestUtils;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.codec.Pojo;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.*;
<ide> import static org.xmlunit.matchers.CompareMatcher.*;
<ide><path>spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java
<ide>
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.junit.Assert.assertEquals;
<ide> import static org.junit.Assert.assertTrue;
<ide><path>spring-web/src/test/java/org/springframework/http/server/reactive/FlushingIntegrationTests.java
<ide> import org.reactivestreams.Publisher;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.client.reactive.ReactorClientHttpConnector;
<add>import org.springframework.tests.TestSubscriber;
<ide> import org.springframework.web.client.reactive.ClientWebRequestBuilders;
<ide> import org.springframework.web.client.reactive.ResponseExtractors;
<ide> import org.springframework.web.client.reactive.WebClient;
<ide><path>spring-web/src/test/java/org/springframework/web/client/reactive/DefaultResponseErrorHandlerTests.java
<ide> import org.junit.Before;
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.codec.StringDecoder;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.client.reactive.ClientHttpResponse;
<ide> import org.springframework.http.codec.DecoderHttpMessageReader;
<ide> import org.springframework.http.codec.HttpMessageReader;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.hamcrest.CoreMatchers.is;
<ide> import static org.junit.Assert.assertThat;
<ide><path>spring-web/src/test/java/org/springframework/web/client/reactive/ResponseExtractorsTests.java
<ide> import reactor.core.Exceptions;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.core.codec.StringDecoder;
<ide> import org.springframework.core.io.buffer.DataBuffer;
<ide> import org.springframework.http.codec.DecoderHttpMessageReader;
<ide> import org.springframework.http.codec.HttpMessageReader;
<ide> import org.springframework.http.codec.json.Jackson2JsonDecoder;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> import static org.hamcrest.CoreMatchers.*;
<ide> import static org.junit.Assert.*;
<ide><path>spring-web/src/test/java/org/springframework/web/client/reactive/WebClientIntegrationTests.java
<ide> import org.junit.Test;
<ide> import reactor.core.publisher.Flux;
<ide> import reactor.core.publisher.Mono;
<del>import reactor.test.TestSubscriber;
<ide>
<ide> import org.springframework.http.HttpHeaders;
<ide> import org.springframework.http.MediaType;
<ide> import org.springframework.http.ResponseEntity;
<ide> import org.springframework.http.client.reactive.ReactorClientHttpConnector;
<ide> import org.springframework.http.codec.Pojo;
<add>import org.springframework.tests.TestSubscriber;
<ide>
<ide> /**
<ide> * {@link WebClient} integration tests with the {@code Flux} and {@code Mono} API. | 39 |
PHP | PHP | continue work on stackphp compatibility | 02618b4190c08e1fe6e138eadb95473c92da6718 | <ide><path>src/Illuminate/Console/Application.php
<ide> class Application extends \Symfony\Component\Console\Application {
<ide> */
<ide> public static function start($app)
<ide> {
<add> // Here, we will go ahead and "boot" the application for usage. This simply
<add> // calls the boot method on all of the service providers so they get all
<add> // their work done and are ready to handle interacting with dev input.
<add> $app->boot();
<add>
<ide> $artisan = require __DIR__.'/start.php';
<ide>
<ide> $artisan->setAutoExit(false);
<ide><path>src/Illuminate/Exception/ExceptionServiceProvider.php
<ide> protected function registerWhoopsHandler()
<ide> */
<ide> protected function shouldReturnJson()
<ide> {
<del> $definitely = ($this->app['request']->ajax() or $this->app->runningInConsole());
<add> if ($this->app->runningInConsole()) return true;
<ide>
<del> return $definitely or $this->app['request']->wantsJson();
<add> return $app->isBooted() and $this->requestWantsJson();
<add> }
<add>
<add> /**
<add> * Determine if the request warrants a JSON response.
<add> *
<add> * @return bool
<add> */
<add> protected function requestWantsJson()
<add> {
<add> return $this->app['request']->ajax() or $this->app['request']->wantsJson();
<ide> }
<ide>
<ide> /**
<ide><path>src/Illuminate/Foundation/Application.php
<ide> use Illuminate\Exception\ExceptionServiceProvider;
<ide> use Symfony\Component\HttpFoundation\JsonResponse;
<ide> use Symfony\Component\HttpKernel\HttpKernelInterface;
<add>use Symfony\Component\HttpKernel\TerminableInterface;
<ide> use Symfony\Component\HttpFoundation\StreamedResponse;
<ide> use Symfony\Component\HttpKernel\Exception\HttpException;
<ide> use Symfony\Component\Debug\Exception\FatalErrorException;
<ide> use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
<ide> use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirect;
<ide>
<del>class Application extends Container implements HttpKernelInterface, ResponsePreparerInterface {
<add>class Application extends Container implements HttpKernelInterface, TerminableInterface, ResponsePreparerInterface {
<ide>
<ide> /**
<ide> * The Laravel framework version.
<ide> class Application extends Container implements HttpKernelInterface, ResponsePrep
<ide> */
<ide> public function __construct(Request $request = null)
<ide> {
<del> $this['request'] = $this->createRequest($request);
<del>
<ide> $this->registerBaseServiceProviders();
<ide> }
<ide>
<ide> public function isLocal()
<ide> /**
<ide> * Detect the application's current environment.
<ide> *
<del> * @param array|string $environments
<add> * @param array|string $envs
<ide> * @return string
<ide> */
<del> public function detectEnvironment($environments)
<add> public function detectEnvironment($envs)
<ide> {
<del> $this['env'] = with(new EnvironmentDetector($this['request']))->detect(
<del>
<del> $environments, $this->runningInConsole()
<del>
<del> );
<add> $this['env'] = with(new EnvironmentDetector())->detect($envs, $_SERVER['argv']);
<ide>
<ide> return $this['env'];
<ide> }
<ide> public function after($callback)
<ide> }
<ide>
<ide> /**
<del> * Register a "close" application filter.
<add> * Register a "close" application callback, or call them.
<ide> *
<ide> * @param Closure|string $callback
<ide> * @return void
<ide> */
<del> public function close($callback)
<add> public function close($callback = null)
<ide> {
<del> $this->closeCallbacks[] = $callback;
<add> if (is_null($callback))
<add> {
<add> $this->callCloseCallbacks();
<add> }
<add> else
<add> {
<add> $this->closeCallbacks[] = $callback;
<add> }
<ide> }
<ide>
<ide> /**
<ide> public function shutdown($callback = null)
<ide> }
<ide> }
<ide>
<add> /**
<add> * Determine if the application has booted.
<add> *
<add> * @return bool
<add> */
<add> public function isBooted()
<add> {
<add> return $this->booted;
<add> }
<add>
<ide> /**
<ide> * Boot the application's service providers.
<ide> *
<ide> public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MAS
<ide> {
<ide> $this->refreshRequest($request = Request::createFromBase($request));
<ide>
<add> $this->boot();
<add>
<ide> return $this->dispatch($request);
<ide> }
<ide>
<ide> public function dispatch(Request $request)
<ide> */
<ide> public function terminate(SymfonyRequest $request, SymfonyResponse $response)
<ide> {
<del> $this->callCloseCallbacks($request, $response);
<del>
<del> $response->send();
<del>
<ide> $this->callFinishCallbacks($request, $response);
<add>
<add> $this->shutdown();
<ide> }
<ide>
<ide> /**
<ide><path>src/Illuminate/Foundation/EnvironmentDetector.php
<ide> <?php namespace Illuminate\Foundation;
<ide>
<ide> use Closure;
<del>use Illuminate\Http\Request;
<ide>
<ide> class EnvironmentDetector {
<ide>
<del> /**
<del> * The request instance.
<del> *
<del> * @var \Illuminate\Http\Request
<del> */
<del> protected $request;
<del>
<del> /**
<del> * Create a new environment detector instance.
<del> *
<del> * @param \Illuminate\Http\Request $request
<del> * @return void
<del> */
<del> public function __construct(Request $request)
<del> {
<del> $this->request = $request;
<del> }
<del>
<ide> /**
<ide> * Detect the application's current environment.
<ide> *
<ide> * @param array|string $environments
<del> * @param bool $inConsole
<add> * @param array|null $consoleArgs
<ide> * @return string
<ide> */
<del> public function detect($environments, $inConsole = false)
<add> public function detect($environments, $consoleArgs = null)
<ide> {
<del> if ($inConsole)
<add> if ($consoleArgs)
<ide> {
<del> return $this->detectConsoleEnvironment($environments);
<add> return $this->detectConsoleEnvironment($environments, $consoleArgs);
<ide> }
<ide> else
<ide> {
<ide> protected function detectWebEnvironment($environments)
<ide> return call_user_func($environments);
<ide> }
<ide>
<del> $webHost = $this->getHost();
<del>
<ide> foreach ($environments as $environment => $hosts)
<ide> {
<ide> // To determine the current environment, we'll simply iterate through the possible
<ide> // environments and look for the host that matches the host for this request we
<ide> // are currently processing here, then return back these environment's names.
<ide> foreach ((array) $hosts as $host)
<ide> {
<del> if (str_is($host, $webHost) or $this->isMachine($host))
<del> {
<del> return $environment;
<del> }
<add> if ($this->isMachine($host)) return $environment;
<ide> }
<ide> }
<ide>
<ide> protected function detectWebEnvironment($environments)
<ide> * Set the application environment from command-line arguments.
<ide> *
<ide> * @param mixed $environments
<add> * @param array $args
<ide> * @return string
<ide> */
<del> protected function detectConsoleEnvironment($environments)
<add> protected function detectConsoleEnvironment($environments, array $args)
<ide> {
<ide> // First we will check if an environment argument was passed via console arguments
<ide> // and if it was that automatically overrides as the environment. Otherwise, we
<ide> // will check the environment as a "web" request like a typical HTTP request.
<del> if ( ! is_null($value = $this->getEnvironmentArgument()))
<add> if ( ! is_null($value = $this->getEnvironmentArgument($args)))
<ide> {
<ide> return head(array_slice(explode('=', $value), 1));
<ide> }
<ide> protected function detectConsoleEnvironment($environments)
<ide> /**
<ide> * Get the enviornment argument from the console.
<ide> *
<add> * @param array $args
<ide> * @return string|null
<ide> */
<del> protected function getEnvironmentArgument()
<add> protected function getEnvironmentArgument(array $args)
<ide> {
<del> return array_first($this->getConsoleArguments(), function($k, $v)
<add> return array_first($args, function($k, $v)
<ide> {
<ide> return starts_with($v, '--env');
<ide> });
<ide> }
<ide>
<del> /**
<del> * Get the actual host for the web request.
<del> *
<del> * @return string
<del> */
<del> protected function getHost()
<del> {
<del> return $this->request->getHost();
<del> }
<del>
<del> /**
<del> * Get the server console arguments.
<del> *
<del> * @return array
<del> */
<del> protected function getConsoleArguments()
<del> {
<del> return $this->request->server->get('argv');
<del> }
<del>
<ide> /**
<ide> * Determine if the name matches the machine name.
<ide> *
<ide> * @param string $name
<ide> * @return bool
<ide> */
<del> protected function isMachine($name)
<add> public function isMachine($name)
<ide> {
<ide> return str_is($name, gethostname());
<ide> }
<ide><path>src/Illuminate/Foundation/start.php
<ide>
<ide> if ( ! extension_loaded('mcrypt'))
<ide> {
<del> echo 'Laravel requires the Mcrypt PHP extension.'.PHP_EOL;
<add> echo 'Mcrypt PHP extension required.'.PHP_EOL;
<ide>
<ide> exit(1);
<ide> }
<ide> |
<ide> */
<ide>
<del>$config = new Config($app->getConfigLoader(), $env);
<add>$app->instance('config', $config = new Config(
<ide>
<del>$app->instance('config', $config);
<add> $app->getConfigLoader(), $env
<add>
<add>));
<ide>
<ide> /*
<ide> |--------------------------------------------------------------------------
<ide> |
<ide> */
<ide>
<del>AliasLoader::getInstance($config['aliases'])->register();
<add>$aliases = $config['aliases'];
<add>
<add>AliasLoader::getInstance($aliases)->register();
<ide>
<ide> /*
<ide> |--------------------------------------------------------------------------
<ide>
<ide> Request::enableHttpMethodParameterOverride();
<ide>
<del>/*
<del>|--------------------------------------------------------------------------
<del>| Set The Console Request If Necessary
<del>|--------------------------------------------------------------------------
<del>|
<del>| If we're running in a console context, we won't have a host on this
<del>| request so we'll need to re-bind a new request with a URL from a
<del>| configuration file. This will help the URL generator generate.
<del>|
<del>*/
<del>
<del>if ($app->runningInConsole())
<del>{
<del> $app->setRequestForConsoleEnvironment();
<del>}
<del>
<ide> /*
<ide> |--------------------------------------------------------------------------
<ide> | Register The Core Service Providers
<ide>
<ide> $app->getProviderRepository()->load($app, $providers);
<ide>
<del>/*
<del>|--------------------------------------------------------------------------
<del>| Boot The Application
<del>|--------------------------------------------------------------------------
<del>|
<del>| Before we handle the requests we need to make sure the application has
<del>| been booted up. The boot process will call the "boot" method on all
<del>| service provider giving all a chance to register their overrides.
<del>|
<del>*/
<del>
<del>$app->boot();
<del>
<ide> /*
<ide> |--------------------------------------------------------------------------
<ide> | Load The Application Start Script
<ide> |
<ide> */
<ide>
<del>if (file_exists($path = $app['path'].'/routes.php'))
<del>{
<del> require $path;
<del>}
<ide>\ No newline at end of file
<add>$routes = $app['path'].'/routes.php';
<add>
<add>if (file_exists($routes)) require $routes;
<ide><path>tests/Foundation/FoundationEnvironmentDetectorTest.php
<ide> public function tearDown()
<ide>
<ide> public function testEnvironmentDetection()
<ide> {
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('foo');
<del> $request->server = m::mock('StdClass');
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<del>
<add> $env = m::mock('Illuminate\Foundation\EnvironmentDetector')->makePartial();
<add> $env->shouldReceive('isMachine')->once()->with('localhost')->andReturn(false);
<ide> $result = $env->detect(array(
<ide> 'local' => array('localhost')
<ide> ));
<ide> $this->assertEquals('production', $result);
<ide>
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('localhost');
<del> $request->server = m::mock('StdClass');
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<ide>
<add> $env = m::mock('Illuminate\Foundation\EnvironmentDetector')->makePartial();
<add> $env->shouldReceive('isMachine')->once()->with('localhost')->andReturn(true);
<ide> $result = $env->detect(array(
<ide> 'local' => array('localhost')
<ide> ));
<ide> $this->assertEquals('local', $result);
<del>
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('localhost');
<del> $request->server = m::mock('StdClass');
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<del>
<del> $result = $env->detect(array(
<del> 'local' => array('local*')
<del> ));
<del> $this->assertEquals('local', $result);
<del>
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('localhost');
<del> $request->server = m::mock('StdClass');
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<del>
<del> $result = $env->detect(array(
<del> 'local' => array(gethostname())
<del> ));
<del> $this->assertEquals('local', $result);
<ide> }
<ide>
<ide>
<ide> public function testClosureCanBeUsedForCustomEnvironmentDetection()
<ide> {
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('foo');
<del> $request->server = m::mock('StdClass');
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<add> $env = new Illuminate\Foundation\EnvironmentDetector;
<ide>
<ide> $result = $env->detect(function() { return 'foobar'; });
<ide> $this->assertEquals('foobar', $result);
<ide> public function testClosureCanBeUsedForCustomEnvironmentDetection()
<ide>
<ide> public function testConsoleEnvironmentDetection()
<ide> {
<del> $request = m::mock('Illuminate\Http\Request');
<del> $request->shouldReceive('getHost')->andReturn('foo');
<del> $request->server = m::mock('StdClass');
<del> $request->server->shouldReceive('get')->once()->with('argv')->andReturn(array('--env=local'));
<del> $env = new Illuminate\Foundation\EnvironmentDetector($request);
<add> $env = new Illuminate\Foundation\EnvironmentDetector;
<ide>
<ide> $result = $env->detect(array(
<ide> 'local' => array('foobar')
<del> ), true);
<add> ), array('--env=local'));
<ide> $this->assertEquals('local', $result);
<ide> }
<ide> | 6 |
Javascript | Javascript | release reference to root components after destroy | bd60d853d76252e379dc4876b24475cb3c5d3a10 | <ide><path>packages/ember-glimmer/lib/renderer.js
<ide> class Renderer {
<ide> let root = roots[i];
<ide> if (root.isFor(view)) {
<ide> root.destroy();
<add> roots.splice(i, 1);
<ide> }
<ide> }
<ide> }
<ide><path>packages/ember-glimmer/tests/integration/components/append-test.js
<ide> class AbstractAppendTest extends RenderingTest {
<ide> this.assert.equal(willDestroyCalled, 1);
<ide> }
<ide>
<add> ['@test releasing a root component after it has been destroy'](assert) {
<add> let renderer = this.owner.lookup('renderer:-dom');
<add>
<add> this.registerComponent('x-component', {
<add> ComponentClass: Component.extend()
<add> });
<add>
<add> this.component = this.owner.factoryFor('component:x-component').create();
<add> this.append(this.component);
<add>
<add> assert.equal(renderer._roots.length, 1, 'added a root component');
<add>
<add> this.runTask(() => this.component.destroy());
<add>
<add> assert.equal(renderer._roots.length, 0, 'released the root component');
<add> }
<add>
<ide> ['@test appending, updating and destroying multiple components'](assert) {
<ide> let willDestroyCalled = 0;
<ide> | 2 |
PHP | PHP | fix version in path file | 4d3c68129b89c6bc8131aca765a63dba8fee92b0 | <ide><path>paths.php
<ide> * Laravel - A PHP Framework For Web Artisans
<ide> *
<ide> * @package Laravel
<del> * @version 3.2.8
<add> * @version 3.2.10
<ide> * @author Taylor Otwell <taylorotwell@gmail.com>
<ide> * @link http://laravel.com
<ide> */ | 1 |
Python | Python | delay_task returns pendingresult() | 2c3bd9f9e9ca2600b31d6e51f3d92ef02164ee6b | <ide><path>celery/backends/__init__.py
<ide> def get_backend_cls(backend):
<ide> return getattr(backend_module, 'Backend')
<ide>
<ide> get_default_backend_cls = partial(get_backend_cls, CELERY_BACKEND)
<del>
<del>
<ide> DefaultBackend = get_default_backend_cls()
<del>
<del>
<ide> default_backend = DefaultBackend()
<ide><path>celery/task.py
<ide> def delay_task(task_name, *args, **kwargs):
<ide> publisher = TaskPublisher(connection=DjangoAMQPConnection())
<ide> task_id = publisher.delay_task(task_name, *args, **kwargs)
<ide> publisher.close()
<del> return Job(task_id)
<add> return PendingResult(task_id)
<ide>
<ide>
<ide> def discard_all(): | 2 |
Text | Text | fix url for chainreactconf | 4e8326a82e782bcf9ce7ef51f41d968296e588cc | <ide><path>ECOSYSTEM.md
<ide> React Native's current set of partners include Callstack, Expo, Facebook, Infini
<ide> * **[Callstack](https://callstack.com/):** Manages releases, maintains the [React Native CLI](https://github.com/react-native-community/react-native-cli) and organizes [React Native EU](https://react-native.eu/)
<ide> * **[Expo](https://expo.io/):** Builds [expo](https://github.com/expo/expo) on top of React Native to simplify app development
<ide> * **[Facebook](https://opensource.facebook.com):** Oversees the React Native product and maintains the [React Native core repo](https://reactnative.dev/)
<del>* **[Infinite Red](https://infinite.red/):** Maintains the [ignite cli/boilerplate](https://github.com/infinitered/ignite), organizes [Chain React Conf](https://infinite.red/ChainReactConf)
<add>* **[Infinite Red](https://infinite.red/):** Maintains the [ignite cli/boilerplate](https://github.com/infinitered/ignite), organizes [Chain React Conf](https://cr.infinite.red/)
<ide> * **[Microsoft](http://aka.ms/reactnative):** Develops [React Native Windows](https://github.com/Microsoft/react-native-windows) and [React Native macOS](https://github.com/microsoft/react-native-macos) for building apps that target Windows and macOS
<ide> * **[Software Mansion](https://swmansion.com/):** Maintain core infrastructure including JSC, Animated, and other popular third-party plugins.
<ide> | 1 |
PHP | PHP | update viewcomponents to a subdirectory | e8f9bbebe96963cdb87d4be07c73ae15765614f9 | <ide><path>src/Illuminate/Foundation/Console/ComponentMakeCommand.php
<ide> protected function getStub()
<ide> */
<ide> protected function getDefaultNamespace($rootNamespace)
<ide> {
<del> return $rootNamespace.'\ViewComponents';
<add> return $rootNamespace.'\View\Components';
<ide> }
<ide>
<ide> /**
<ide><path>src/Illuminate/View/Compilers/BladeCompiler.php
<ide> public function check($name, ...$parameters)
<ide> public function component($class, $alias = null, $prefix = '')
<ide> {
<ide> if (is_null($alias)) {
<del> $alias = Str::contains($class, '\\ViewComponents\\')
<del> ? collect(explode('\\', Str::after($class, '\\ViewComponents\\')))->map(function ($segment) {
<add> $alias = Str::contains($class, '\\View\\Components\\')
<add> ? collect(explode('\\', Str::after($class, '\\View\\Components\\')))->map(function ($segment) {
<ide> return Str::kebab($segment);
<ide> })->implode(':')
<ide> : Str::kebab(class_basename($class));
<ide><path>src/Illuminate/View/Compilers/ComponentTagCompiler.php
<ide> public function guessClassName(string $component)
<ide> return ucfirst(Str::camel($componentPiece));
<ide> }, explode(':', $component));
<ide>
<del> return $namespace.'ViewComponents\\'.implode('\\', $componentPieces);
<add> return $namespace.'View\\Components\\'.implode('\\', $componentPieces);
<ide> }
<ide>
<ide> /**
<ide><path>tests/View/Blade/BladeComponentTagCompilerTest.php
<ide> public function testClassNamesCanBeGuessed()
<ide>
<ide> $result = (new ComponentTagCompiler([]))->guessClassName('alert');
<ide>
<del> $this->assertEquals("App\ViewComponents\Alert", trim($result));
<add> $this->assertEquals("App\View\Components\Alert", trim($result));
<ide>
<ide> Container::setInstance(null);
<ide> }
<ide> public function testClassNamesCanBeGuessedWithNamespaces()
<ide>
<ide> $result = (new ComponentTagCompiler([]))->guessClassName('base:alert');
<ide>
<del> $this->assertEquals("App\ViewComponents\Base\Alert", trim($result));
<add> $this->assertEquals("App\View\Components\Base\Alert", trim($result));
<ide>
<ide> Container::setInstance(null);
<ide> }
<ide><path>tests/View/ViewBladeCompilerTest.php
<ide> public function testComponentAliasesCanBeConventionallyDetermined()
<ide>
<ide> $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
<ide>
<del> $compiler->component('App\ViewComponents\Forms\Input');
<del> $this->assertEquals(['forms:input' => 'App\ViewComponents\Forms\Input'], $compiler->getClassComponentAliases());
<add> $compiler->component('App\View\Components\Forms\Input');
<add> $this->assertEquals(['forms:input' => 'App\View\Components\Forms\Input'], $compiler->getClassComponentAliases());
<ide>
<ide> $compiler = new BladeCompiler($files = $this->getFiles(), __DIR__);
<ide>
<del> $compiler->component('App\ViewComponents\Forms\Input', null, 'prefix');
<del> $this->assertEquals(['prefix-forms:input' => 'App\ViewComponents\Forms\Input'], $compiler->getClassComponentAliases());
<add> $compiler->component('App\View\Components\Forms\Input', null, 'prefix');
<add> $this->assertEquals(['prefix-forms:input' => 'App\View\Components\Forms\Input'], $compiler->getClassComponentAliases());
<ide> }
<ide>
<ide> protected function getFiles() | 5 |
PHP | PHP | fix bug in remote manager | 4d8cde80f54cca373c995c0ec1e6bee3aa41cc08 | <ide><path>src/Illuminate/Remote/RemoteManager.php
<ide> protected function setOutput(Connection $connection)
<ide> */
<ide> protected function getAuth(array $config)
<ide> {
<del> if (isset($config['key']))
<add> if (isset($config['key']) and trim($config['key']) != '')
<ide> {
<ide> return array('key' => $config['key']);
<ide> } | 1 |
PHP | PHP | add more documentation to application/filters.php | 1840989484ea6fa13eafc1966a526e6fcc40989f | <ide><path>application/filters.php
<ide> | Filters
<ide> |--------------------------------------------------------------------------
<ide> |
<del> | Filters provide a convenient method for filtering access to your route
<del> | functions. To make your life easier, we have already setup basic filters
<del> | for authentication and CSRF protection.
<add> | Filters provide a convenient method for attaching functionality to your
<add> | routes. Filters can run either before or after a route is exectued.
<add> |
<add> | The built-in "before" and "after" filters are called before and after
<add> | every request to your application; however, you may create other filters
<add> | that can be attached to individual routes.
<add> |
<add> | Filters also make common tasks such as authentication and CSRF protection
<add> | a breeze. If a filter that runs before a route returns a response, that
<add> | response will override the route action.
<add> |
<add> | Let's walk through an example...
<add> |
<add> | First, define a filter:
<add> |
<add> | 'simple_filter' => function()
<add> | {
<add> | return 'Filtered!';
<add> | }
<add> |
<add> | Next, attach the filter to a route:
<add> |
<add> | 'GET /' => array('before' => 'simple_filter', 'do' => function()
<add> | {
<add> | return 'Hello World!';
<add> | })
<add> |
<add> | Now every requests to http://example.com will return "Filtered!", since
<add> | the filter is overriding the route action by returning a value.
<add> |
<add> | To make your life easier, we have built authentication and CSRF filters
<add> | that are ready to attach to your routes. Enjoy.
<ide> |
<ide> | For more information, check out: http://laravel.com/docs/start/routes#filters
<ide> | | 1 |
Javascript | Javascript | convert inspector to call ref.measure | fa78a967391454a64882674bcfffb7c2830f9d51 | <ide><path>Libraries/Inspector/Inspector.js
<ide> const React = require('react');
<ide> const ReactNative = require('../Renderer/shims/ReactNative');
<ide> const StyleSheet = require('../StyleSheet/StyleSheet');
<ide> const Touchable = require('../Components/Touchable/Touchable');
<del>const UIManager = require('../ReactNative/UIManager');
<ide> const View = require('../Components/View/View');
<ide>
<ide> const invariant = require('invariant');
<ide> class Inspector extends React.Component<
<ide> _onAgentShowNativeHighlight = node => {
<ide> clearTimeout(this._hideTimeoutID);
<ide>
<del> if (typeof node !== 'number') {
<del> node = ReactNative.findNodeHandle(node);
<del> }
<del>
<del> UIManager.measure(node, (x, y, width, height, left, top) => {
<add> node.measure((x, y, width, height, left, top) => {
<ide> this.setState({
<ide> hierarchy: [],
<ide> inspected: { | 1 |
Ruby | Ruby | fix env for python3" | 5997812ed23164cf3f52fe328ec665fe8cf70622 | <ide><path>Library/Homebrew/requirements/python_requirement.rb
<ide> class PythonRequirement < Requirement
<ide> ENV.prepend_path "PATH", Formula["python"].opt_bin
<ide> end
<ide>
<del> ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{short_version}/site-packages"
<add> if python_binary == "python"
<add> ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{short_version}/site-packages"
<add> end
<ide> end
<ide>
<ide> def python_short_version
<ide> class Python3Requirement < PythonRequirement
<ide>
<ide> satisfy(:build_env => false) { which_python }
<ide>
<del> env do
<del> ENV["PYTHONPATH"] = "#{HOMEBREW_PREFIX}/lib/python#{python_short_version}/site-packages"
<del> end
<del>
<ide> def python_binary
<ide> "python3"
<ide> end | 1 |
Ruby | Ruby | fix some typos | a8df5bdc5d3cd5ad21758d8e421130bc9518b1dd | <ide><path>actionpack/lib/action_controller/metal/strong_parameters.rb
<ide> def hash_filter(params, filter)
<ide> # Declaration { comment_ids: [] }.
<ide> array_of_permitted_scalars_filter(params, key)
<ide> else
<del> # Declaration { user: :name } or { user: [:name, :age, { adress: ... }] }.
<add> # Declaration { user: :name } or { user: [:name, :age, { address: ... }] }.
<ide> params[key] = each_element(value) do |element|
<ide> if element.is_a?(Hash)
<ide> element = self.class.new(element) unless element.respond_to?(:permit)
<ide><path>actionpack/lib/action_dispatch/middleware/remote_ip.rb
<ide> class GetIp
<ide> (([0-9A-Fa-f]{1,4}:){0,4}:([0-9A-Fa-f]{1,4}:){1}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
<ide> (::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d) |(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)) | # ip v6 with compatible to v4
<ide> ([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4}) | # ip v6 with compatible to v4
<del> (::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4}) | # ip v6 with double colon at the begining
<add> (::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4}) | # ip v6 with double colon at the beginning
<ide> (([0-9A-Fa-f]{1,4}:){1,7}:) # ip v6 without ending
<ide> )$)
<ide> }x
<ide><path>railties/test/application/configuration_test.rb
<ide> def create
<ide> assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters
<ide> end
<ide>
<del> test "config.action_controller.action_on_unpermitted_parameters is :log by defaul on test" do
<add> test "config.action_controller.action_on_unpermitted_parameters is :log by default on test" do
<ide> ENV["RAILS_ENV"] = "test"
<ide>
<ide> require "#{app_path}/config/environment"
<ide><path>railties/test/application/initializers/load_path_test.rb
<ide> def teardown
<ide> assert $:.include?("#{app_path}/app/models")
<ide> end
<ide>
<del> test "initializing an application allows to load code on lib path inside application class definitation" do
<add> test "initializing an application allows to load code on lib path inside application class definition" do
<ide> app_file "lib/foo.rb", <<-RUBY
<ide> module Foo; end
<ide> RUBY
<ide><path>railties/test/application/middleware/cookies_test.rb
<ide> def teardown
<ide> assert_equal false, ActionDispatch::Cookies::CookieJar.always_write_cookie
<ide> end
<ide>
<del> test 'always_write_cookie can be overrided' do
<add> test 'always_write_cookie can be overridden' do
<ide> add_to_config <<-RUBY
<ide> config.action_dispatch.always_write_cookie = false
<ide> RUBY | 5 |
Javascript | Javascript | fix linter errors | a9da395f602ebaecbfa35f0fffa4d1765e7de11c | <ide><path>src/grammar-registry.js
<ide> class GrammarRegistry {
<ide> fileTypes = fileTypes.concat(customFileTypes)
<ide> }
<ide>
<del> if (!Array.isArray(fileTypes)) debugger
<del>
<ide> for (let i = 0; i < fileTypes.length; i++) {
<ide> const fileType = fileTypes[i]
<ide> const fileTypeComponents = fileType.toLowerCase().split(PATH_SPLIT_REGEX)
<ide><path>src/tree-sitter-language-mode.js
<ide> class LanguageLayer {
<ide> async _performUpdate (containingNodes) {
<ide> let includedRanges = []
<ide> if (containingNodes) {
<del> for (const node of containingNodes)
<add> for (const node of containingNodes) {
<ide> includedRanges.push(...this._rangesForInjectionNode(node))
<add> }
<ide> if (includedRanges.length === 0) return
<ide> }
<ide> | 2 |
Java | Java | add mechanism to expose mock server results | f500ab0f9b0185cb5ccf784622de753a052b8421 | <ide><path>spring-test/src/main/java/org/springframework/test/web/reactive/server/ExchangeResult.java
<ide> /*
<del> * Copyright 2002-2019 the original author or authors.
<add> * Copyright 2002-2020 the original author or authors.
<ide> *
<ide> * Licensed under the Apache License, Version 2.0 (the "License");
<ide> * you may not use this file except in compliance with the License.
<ide> public class ExchangeResult {
<ide> @Nullable
<ide> private final String uriTemplate;
<ide>
<add> @Nullable
<add> final Object mockServerResult;
<add>
<ide>
<ide> /**
<ide> * Create an instance with an HTTP request and response along with promises
<ide> public class ExchangeResult {
<ide> * @param responseBody capture of serialized response body content
<ide> * @param timeout how long to wait for content to materialize
<ide> * @param uriTemplate the URI template used to set up the request, if any
<add> * @param serverResult the result of a mock server exchange if applicable.
<ide> */
<ide> ExchangeResult(ClientHttpRequest request, ClientHttpResponse response,
<del> Mono<byte[]> requestBody, Mono<byte[]> responseBody, Duration timeout, @Nullable String uriTemplate) {
<add> Mono<byte[]> requestBody, Mono<byte[]> responseBody, Duration timeout, @Nullable String uriTemplate,
<add> @Nullable Object serverResult) {
<ide>
<ide> Assert.notNull(request, "ClientHttpRequest is required");
<ide> Assert.notNull(response, "ClientHttpResponse is required");
<ide> public class ExchangeResult {
<ide> this.responseBody = responseBody;
<ide> this.timeout = timeout;
<ide> this.uriTemplate = uriTemplate;
<add> this.mockServerResult = serverResult;
<ide> }
<ide>
<ide> /**
<ide> public class ExchangeResult {
<ide> this.responseBody = other.responseBody;
<ide> this.timeout = other.timeout;
<ide> this.uriTemplate = other.uriTemplate;
<add> this.mockServerResult = other.mockServerResult;
<ide> }
<ide>
<ide>
<ide> public byte[] getResponseBodyContent() {
<ide> return this.responseBody.block(this.timeout);
<ide> }
<ide>
<add> /**
<add> * Return the result from the mock server exchange, if applicable, for
<add> * further assertions on the state of the server response.
<add> * @since 5.3
<add> * @see org.springframework.test.web.servlet.client.MockMvcTestClient#resultActionsFor(ExchangeResult)
<add> */
<add> @Nullable
<add> public Object getMockServerResult() {
<add> return this.mockServerResult;
<add> }
<ide>
<ide> /**
<ide> * Execute the given Runnable, catch any {@link AssertionError}, decorate
<ide> public String toString() {
<ide> "< " + getStatus() + " " + getStatus().getReasonPhrase() + "\n" +
<ide> "< " + formatHeaders(getResponseHeaders(), "\n< ") + "\n" +
<ide> "\n" +
<del> formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n";
<add> formatBody(getResponseHeaders().getContentType(), this.responseBody) +"\n" +
<add> formatMockServerResult();
<ide> }
<ide>
<ide> private String formatHeaders(HttpHeaders headers, String delimiter) {
<ide> private String formatBody(@Nullable MediaType contentType, Mono<byte[]> body) {
<ide> .block(this.timeout);
<ide> }
<ide>
<add> private String formatMockServerResult() {
<add> return (this.mockServerResult != null ?
<add> "\n====================== MockMvc (Server) ===============================\n" +
<add> this.mockServerResult + "\n" : "");
<add> }
<add>
<ide> }
<ide><path>spring-test/src/main/java/org/springframework/test/web/reactive/server/MockServerClientHttpResponse.java
<add>/*
<add> * Copyright 2002-2020 the original author or authors.
<add> *
<add> * Licensed under the Apache License, Version 2.0 (the "License");
<add> * you may not use this file except in compliance with the License.
<add> * You may obtain a copy of the License at
<add> *
<add> * https://www.apache.org/licenses/LICENSE-2.0
<add> *
<add> * Unless required by applicable law or agreed to in writing, software
<add> * distributed under the License is distributed on an "AS IS" BASIS,
<add> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add> * See the License for the specific language governing permissions and
<add> * limitations under the License.
<add> */
<add>package org.springframework.test.web.reactive.server;
<add>
<add>import org.springframework.http.client.reactive.ClientHttpResponse;
<add>
<add>/**
<add> * Simple {@link ClientHttpResponse} extension that also exposes a result object
<add> * from the underlying mock server exchange for further assertions on the state
<add> * of the server response after the request is performed.
<add> *
<add> * @author Rossen Stoyanchev
<add> * @since 5.3
<add> */
<add>public interface MockServerClientHttpResponse extends ClientHttpResponse {
<add>
<add> /**
<add> * Return the result object with the server request and response.
<add> */
<add> Object getServerResult();
<add>
<add>}
<ide><path>spring-test/src/main/java/org/springframework/test/web/reactive/server/WiretapConnector.java
<ide> public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
<ide> * Create the {@link ExchangeResult} for the given "request-id" header value.
<ide> */
<ide> ExchangeResult getExchangeResult(String requestId, @Nullable String uriTemplate, Duration timeout) {
<del> ClientExchangeInfo info = this.exchanges.remove(requestId);
<del> Assert.state(info != null, () -> {
<add> ClientExchangeInfo clientInfo = this.exchanges.remove(requestId);
<add> Assert.state(clientInfo != null, () -> {
<ide> String header = WebTestClient.WEBTESTCLIENT_REQUEST_ID;
<ide> return "No match for " + header + "=" + requestId;
<ide> });
<del> return new ExchangeResult(info.getRequest(), info.getResponse(),
<del> info.getRequest().getRecorder().getContent(),
<del> info.getResponse().getRecorder().getContent(),
<del> timeout, uriTemplate);
<add> return new ExchangeResult(clientInfo.getRequest(), clientInfo.getResponse(),
<add> clientInfo.getRequest().getRecorder().getContent(),
<add> clientInfo.getResponse().getRecorder().getContent(),
<add> timeout, uriTemplate,
<add> clientInfo.getResponse().getMockServerResult());
<ide> }
<ide>
<ide>
<ide> public WiretapRecorder getRecorder() {
<ide> public Flux<DataBuffer> getBody() {
<ide> return Flux.from(this.recorder.getPublisherToUse());
<ide> }
<add>
<add> @Nullable
<add> public Object getMockServerResult() {
<add> return (getDelegate() instanceof MockServerClientHttpResponse ?
<add> ((MockServerClientHttpResponse) getDelegate()).getServerResult() : null);
<add> }
<ide> }
<ide>
<ide> }
<ide><path>spring-test/src/test/java/org/springframework/test/web/reactive/server/HeaderAssertionTests.java
<ide> private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) {
<ide> MonoProcessor<byte[]> emptyContent = MonoProcessor.fromSink(Sinks.one());
<ide> emptyContent.onComplete();
<ide>
<del> ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
<add> ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null, null);
<ide> return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class));
<ide> }
<ide>
<ide><path>spring-test/src/test/java/org/springframework/test/web/reactive/server/StatusAssertionTests.java
<ide> private StatusAssertions statusAssertions(int status) {
<ide> MonoProcessor<byte[]> emptyContent = MonoProcessor.fromSink(Sinks.one());
<ide> emptyContent.onComplete();
<ide>
<del> ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null);
<add> ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null, null);
<ide> return new StatusAssertions(result, mock(WebTestClient.ResponseSpec.class));
<ide> }
<ide> | 5 |
Python | Python | fix num_special_tokens in gpt 2 test | 44e9ddd7fe7a683994de81d1791b453cf7b0a54c | <ide><path>pytorch_pretrained_bert/modeling_gpt2.py
<ide> def from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs):
<ide> kwargs.pop('cache_dir', None)
<ide> from_tf = kwargs.get('from_tf', False)
<ide> kwargs.pop('from_tf', None)
<add> num_special_tokens = kwargs.get('num_special_tokens', None)
<add> kwargs.pop('num_special_tokens', None)
<ide>
<ide> if pretrained_model_name_or_path in PRETRAINED_MODEL_ARCHIVE_MAP:
<ide> archive_file = PRETRAINED_MODEL_ARCHIVE_MAP[pretrained_model_name_or_path] | 1 |
Text | Text | fix broken references in changelogs | b5f76dbd3ebdfa1ddecb57e8eb6479c4346c48e4 | <ide><path>CHANGELOG.md
<ide> release.
<ide>
<ide> ## 2015-09-15, io.js Version 3.3.1 @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#3.3.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.3.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#3.3.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.3.1</a>.
<ide>
<ide> ## 2015-09-08, Version 4.0.0 (Stable), @rvagg
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V4.md#4.0.0>Moved to doc/changelogs/CHANGELOG_V6.md#6.0.0</a>.
<ide>
<ide> ## 2015-09-02, Version 3.3.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#3.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.3.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#3.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.3.0</a>.
<ide>
<ide> ## 2015-08-25, Version 3.2.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#3.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.2.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#3.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.2.0</a>.
<ide>
<ide> ## 2015-08-18, Version 3.1.0, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#3.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.1.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#3.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.1.0</a>.
<ide>
<ide> ## 2015-08-04, Version 3.0.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#3.0.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.0.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#3.0.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#3.0.0</a>.
<ide>
<ide> ## 2015-07-28, Version 2.5.0, @cjihrig
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.5.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.5.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.5.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.5.0</a>.
<ide>
<ide> ## 2015-07-17, Version 2.4.0, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.4.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.4.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.4.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.4.0</a>.
<ide>
<ide> ## 2015-07-09, Version 2.3.4, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.3.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.4</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.3.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.4</a>.
<ide>
<ide> ## 2015-07-09, Version 1.8.4, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.8.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.4</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.8.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.4</a>.
<ide>
<ide> ## 2015-07-09, Version 0.12.7 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V012.md#0.12.7">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.7</a>.
<ide>
<ide> ## 2015-07-04, Version 2.3.3, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.3.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.3</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.3.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.3</a>.
<ide>
<ide> ## 2015-07-04, Version 1.8.3, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.8.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.3</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.8.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.3</a>.
<ide>
<ide> ## 2015-07-03, Version 0.12.6 (Stable)
<ide>
<del><a href="doc/changelogs/CHANGELOG_V010.md#0.12.6">Moved to doc/changelogs/CHANGELOG_V010.md#0.12.6</a>.
<add><a href="doc/changelogs/CHANGELOG_V012.md#0.12.6">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.6</a>.
<ide>
<ide> ## 2015-07-01, Version 2.3.2, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.3.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.3.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.2</a>.
<ide>
<ide> ## 2015-06-23, Version 2.3.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.3.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.3.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.1</a>.
<ide>
<ide> ## 2015-06-22, Version 0.12.5 (Stable)
<ide>
<del><a href="doc/changelogs/CHANGELOG_V010.md#0.12.5">Moved to doc/changelogs/CHANGELOG_V010.md#0.12.5</a>.
<add><a href="doc/changelogs/CHANGELOG_V012.md#0.12.5">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.5</a>.
<ide>
<ide> ## 2015-06-18, Version 0.10.39 (Maintenance)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V010.md#0.10.39">Moved to doc/changelogs/CHANGELOG_V010.md#0.10.39</a>.
<ide>
<ide> ## 2015-06-13, Version 2.3.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.3.0</a>.
<ide>
<ide> ## 2015-06-01, Version 2.2.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.2.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.2.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.2.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.2.1</a>.
<ide>
<ide> ## 2015-05-31, Version 2.2.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.2.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.2.0</a>.
<ide>
<ide> ## 2015-05-24, Version 2.1.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.1.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.1.0</a>.
<ide>
<ide> ## 2015-05-22, Version 0.12.4 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V012.md#0.12.4">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.4</a>.
<ide>
<ide> ## 2015-05-17, Version 1.8.2, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.8.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.8.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.2</a>.
<ide>
<ide> ## 2015-05-15, Version 2.0.2, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.0.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.0.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.2</a>.
<ide>
<ide> ## 2015-05-13, Version 0.12.3 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V012.md#0.12.3">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.3</a>.
<ide>
<ide> ## 2015-05-07, Version 2.0.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.0.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.0.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.1</a>.
<ide>
<ide> ## 2015-05-04, Version 2.0.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#2.0.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#2.0.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#2.0.0</a>.
<ide>
<ide> ## 2015-04-20, Version 1.8.1, @chrisdickinson
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.8.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.8.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.8.1</a>.
<ide>
<ide> ## 2015-04-14, Version 1.7.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.7.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.7.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.7.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.7.1</a>.
<ide>
<ide> ## 2015-04-14, Version 1.7.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.7.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.7.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.7.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.7.0</a>.
<ide>
<ide> ## 2015-04-06, Version 1.6.4, @Fishrock123
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.6.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.4</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.6.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.4</a>.
<ide>
<ide> ## 2015-03-31, Version 1.6.3, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.6.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.3</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.6.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.3</a>.
<ide>
<ide> ## 2015-03-31, Version 0.12.2 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V012.md#0.12.2">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.2</a>.
<ide>
<ide> ## 2015-03-23, Version 1.6.2, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.6.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.6.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.2</a>.
<ide>
<ide> ## 2015-03-23, Version 0.12.1 (Stable)
<ide>
<ide> release.
<ide>
<ide> ## 2015-03-20, Version 1.6.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.6.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.6.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.1</a>.
<ide>
<ide> ## 2015-03-19, Version 1.6.0, @chrisdickinson
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.6.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.6.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.6.0</a>.
<ide>
<ide> ## 2015-03-11, Version 0.10.37 (Maintenance)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V010.md#0.10.37">Moved to doc/changelogs/CHANGELOG_V010.md#0.10.37</a>.
<ide>
<ide> ## 2015-03-09, Version 1.5.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.5.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.5.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.5.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.5.1</a>.
<ide>
<ide> ## 2015-03-06, Version 1.5.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.5.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.5.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.5.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.5.0</a>.
<ide>
<ide> ## 2015-03-02, Version 1.4.3, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.4.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.3</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.4.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.3</a>.
<ide>
<ide> ## 2015-02-28, Version 1.4.2, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.4.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.4.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.2</a>.
<ide>
<ide> ## 2015-02-26, Version 1.4.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.4.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.4.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.4.1</a>.
<ide>
<ide> ## 2015-02-20, Version 1.3.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.3.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.3.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.3.0</a>.
<ide>
<ide> ## 2015-02-10, Version 1.2.0, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.2.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.2.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.2.0</a>.
<ide>
<ide> ## 2015-02-06, Version 0.12.0 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V012.md#0.12.0">Moved to doc/changelogs/CHANGELOG_V012.md#0.12.0</a>.
<ide>
<ide> ## 2015-02-03, Version 1.1.0, @chrisdickinson
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.1.0</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.1.0">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.1.0</a>.
<ide>
<ide> ## 2015-01-26, Version 0.10.36 (Stable)
<ide>
<ide> <a href="doc/changelogs/CHANGELOG_V010.md#0.10.36">Moved to doc/changelogs/CHANGELOG_V010.md#0.10.36</a>.
<ide>
<ide> ## 2015-01-24, Version 1.0.4, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.0.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.4</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.0.4">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.4</a>.
<ide>
<ide> ## 2015-01-20, Version 1.0.3, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.0.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.3</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.0.3">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.3</a>.
<ide>
<ide> ## 2015-01-16, Version 1.0.2, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.0.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.2</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.0.2">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.2</a>.
<ide>
<ide> ## 2015-01-14, Version 1.0.1, @rvagg
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#1.0.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.1</a>.
<add><a href="doc/changelogs/CHANGELOG_IOJS.md#1.0.1">Moved to doc/changelogs/CHANGELOG_IOJS.md#1.0.1</a>.
<ide>
<ide> ## 2014.09.24, Version 0.11.14 (Unstable)
<ide>
<ide> release.
<ide>
<ide> ## 2013.05.24, Version 0.10.8 (Stable)
<ide>
<del><a href="doc/changelogs/CHANGELOG_V6.md#0.10.8">Moved to doc/changelogs/CHANGELOG_V6.md#0.10.8</a>.
<add><a href="doc/changelogs/CHANGELOG_V010.md#0.10.8">Moved to doc/changelogs/CHANGELOG_V010.md#0.10.8</a>.
<ide>
<ide> ## 2013.05.17, Version 0.10.7 (Stable)
<ide>
<ide> release.
<ide>
<ide> ## 2013.02.06, Version 0.8.19 (Stable)
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#0.8.29">Moved to doc/changelogs/CHANGELOG_ARCHIVE.md#0.8.29</a>.
<add><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#0.8.19">Moved to doc/changelogs/CHANGELOG_ARCHIVE.md#0.8.19</a>.
<ide>
<ide> ## 2013.01.18, Version 0.8.18 (Stable)
<ide>
<ide> release.
<ide>
<ide> ## 2009.12.19, Version 0.1.22
<ide>
<del><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#01.1.22">Moved to doc/changelogs/CHANGELOG_ARCHIVE.md#01.1.22</a>.
<add><a href="doc/changelogs/CHANGELOG_ARCHIVE.md#0.1.22">Moved to doc/changelogs/CHANGELOG_ARCHIVE.md#0.1.22</a>.
<ide>
<ide> ## 2009.12.06, Version 0.1.21
<ide>
<ide><path>doc/changelogs/CHANGELOG_ARCHIVE.md
<ide> https://github.com/nodejs/node/commit/c1a1ab067721ea17ef7b05ec5c68b01321017f05
<ide> * http: Don't try to destroy nonexistent sockets (isaacs)
<ide> * handle_wrap: fix NULL pointer dereference (Ben Noordhuis)
<ide>
<del><a id="0.8.22"></a>
<add><a id="0.8.23"></a>
<ide> ## 2013.04.09, Version 0.8.23 (maintenance)
<ide>
<ide> https://github.com/nodejs/node/commit/c67f8d0500fe15637a623eb759d2ad7eb9fb3b0b
<ide> https://github.com/nodejs/node/commit/99059aad8d654acda4abcfaa68df182b50f2ec90
<ide> * http: fix case where http-parser is freed twice (koichik)
<ide> * Windows: disable RTTI and exceptions (Bert Belder)
<ide>
<del><a id="0.7.12"></a>
<add><a id="0.7.2"></a>
<ide> ## 2012.02.01, Version 0.7.2 (unstable)
<ide>
<ide> https://github.com/nodejs/node/commit/ec79acb3a6166e30f0bf271fbbfda1fb575b3321
<ide><path>doc/changelogs/CHANGELOG_IOJS.md
<ide> <a href="#1.4.3">1.4.3</a><br/>
<ide> <a href="#1.4.2">1.4.2</a><br/>
<ide> <a href="#1.4.1">1.4.1</a><br/>
<del><a href="#1.4.0">1.4.0</a><br/>
<add><a href="#1.4.1">1.4.0</a><br/>
<ide> <a href="#1.3.0">1.3.0</a><br/>
<ide> <a href="#1.2.0">1.2.0</a><br/>
<ide> <a href="#1.1.0">1.1.0</a><br/> | 3 |
Text | Text | fix misunderstanding in tutorial | 109c9a91e27f4c71667e893a2c60ee6c466788c3 | <ide><path>docs/docs/tutorial.md
<ide> var CommentBox = React.createClass({
<ide> });
<ide> ```
<ide>
<del>Here, `componentDidMount` is a method called automatically by React when a component is rendered. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
<add>Here, `componentDidMount` is a method called automatically by React after a component is rendered for the first time. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
<ide>
<ide> ```javascript{3,15,20-21,35}
<ide> // tutorial14.js | 1 |
Javascript | Javascript | add failing vm tests to known_issues | 363091dea5fc23b1661160a378116512235a240f | <ide><path>test/known_issues/test-vm-ownkeys.js
<add>'use strict';
<add>
<add>require('../common');
<add>const vm = require('vm');
<add>const assert = require('assert');
<add>
<add>const sym1 = Symbol('1');
<add>const sym2 = Symbol('2');
<add>const sandbox = {
<add> a: true,
<add> [sym1]: true
<add>};
<add>Object.defineProperty(sandbox, 'b', { value: true });
<add>Object.defineProperty(sandbox, sym2, { value: true });
<add>
<add>const ctx = vm.createContext(sandbox);
<add>
<add>// Sanity check
<add>// Please uncomment these when the test is no longer broken
<add>// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
<add>// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
<add>// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
<add>
<add>const nativeKeys = vm.runInNewContext('Reflect.ownKeys(this);');
<add>const ownKeys = vm.runInContext('Reflect.ownKeys(this);', ctx);
<add>const restKeys = ownKeys.filter((key) => !nativeKeys.includes(key));
<add>// this should not fail
<add>assert.deepStrictEqual(Array.from(restKeys), ['a', 'b', sym1, sym2]);
<ide><path>test/known_issues/test-vm-ownpropertynames.js
<add>'use strict';
<add>
<add>require('../common');
<add>const vm = require('vm');
<add>const assert = require('assert');
<add>
<add>const sym1 = Symbol('1');
<add>const sym2 = Symbol('2');
<add>const sandbox = {
<add> a: true,
<add> [sym1]: true
<add>};
<add>Object.defineProperty(sandbox, 'b', { value: true });
<add>Object.defineProperty(sandbox, sym2, { value: true });
<add>
<add>const ctx = vm.createContext(sandbox);
<add>
<add>// Sanity check
<add>// Please uncomment these when the test is no longer broken
<add>// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
<add>// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
<add>// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
<add>
<add>const nativeNames = vm.runInNewContext('Object.getOwnPropertyNames(this);');
<add>const ownNames = vm.runInContext('Object.getOwnPropertyNames(this);', ctx);
<add>const restNames = ownNames.filter((name) => !nativeNames.includes(name));
<add>// this should not fail
<add>assert.deepStrictEqual(Array.from(restNames), ['a', 'b']);
<ide><path>test/known_issues/test-vm-ownpropertysymbols.js
<add>'use strict';
<add>
<add>require('../common');
<add>const vm = require('vm');
<add>const assert = require('assert');
<add>
<add>const sym1 = Symbol('1');
<add>const sym2 = Symbol('2');
<add>const sandbox = {
<add> a: true,
<add> [sym1]: true
<add>};
<add>Object.defineProperty(sandbox, 'b', { value: true });
<add>Object.defineProperty(sandbox, sym2, { value: true });
<add>
<add>const ctx = vm.createContext(sandbox);
<add>
<add>// Sanity check
<add>// Please uncomment these when the test is no longer broken
<add>// assert.deepStrictEqual(Reflect.ownKeys(sandbox), ['a', 'b', sym1, sym2]);
<add>// assert.deepStrictEqual(Object.getOwnPropertyNames(sandbox), ['a', 'b']);
<add>// assert.deepStrictEqual(Object.getOwnPropertySymbols(sandbox), [sym1, sym2]);
<add>
<add>const nativeSym = vm.runInNewContext('Object.getOwnPropertySymbols(this);');
<add>const ownSym = vm.runInContext('Object.getOwnPropertySymbols(this);', ctx);
<add>const restSym = ownSym.filter((sym) => !nativeSym.includes(sym));
<add>// this should not fail
<add>assert.deepStrictEqual(Array.from(restSym), [sym1, sym2]); | 3 |
Ruby | Ruby | move storm to the boneyard | 99ebf05b9cf28ed7dbeb7114189b9cfbc4e5cf22 | <ide><path>Library/Homebrew/tap_migrations.rb
<ide> "slicot" => "homebrew/science",
<ide> "shark" => "homebrew/boneyard",
<ide> "solfege" => "homebrew/boneyard",
<add> "storm" => "homebrew/boneyard",
<ide> "syslog-ng" => "homebrew/boneyard",
<ide> "urweb" => "homebrew/boneyard",
<ide> "wkhtmltopdf" => "homebrew/boneyard", | 1 |
PHP | PHP | add nested joins to query builder | 83c2ec751d46b427ca9e53644fced4cc439564a5 | <ide><path>src/Illuminate/Database/Query/Grammars/Grammar.php
<ide> protected function compileFrom(Builder $query, $table)
<ide> */
<ide> protected function compileJoins(Builder $query, $joins)
<ide> {
<del> return collect($joins)->map(function ($join) {
<add> return collect($joins)->map(function ($join) use ($query) {
<ide> $table = $this->wrapTable($join->table);
<add> $nestedJoins = is_null($join->joins) ? '' : ' '.$this->compileJoins($query, $join->joins);
<ide>
<del> return trim("{$join->type} join {$table} {$this->compileWheres($join)}");
<add> return trim("{$join->type} join {$table}{$nestedJoins} {$this->compileWheres($join)}");
<ide> })->implode(' ');
<ide> }
<ide>
<ide><path>tests/Database/DatabaseQueryBuilderTest.php
<ide> public function testJoinsWithAdvancedSubqueryCondition()
<ide> $this->assertEquals(['1', true], $builder->getBindings());
<ide> }
<ide>
<add> public function testJoinsWithNestedJoins()
<add> {
<add> $builder = $this->getBuilder();
<add> $builder->select('users.id', 'contacts.id', 'contact_types.id')->from('users')->leftJoin('contacts', function ($j) {
<add> $j->on('users.id', 'contacts.id')->join('contact_types', 'contacts.contact_type_id', '=', 'contact_types.id');
<add> });
<add> $this->assertEquals('select "users"."id", "contacts"."id", "contact_types"."id" from "users" left join "contacts" inner join "contact_types" on "contacts"."contact_type_id" = "contact_types"."id" on "users"."id" = "contacts"."id"', $builder->toSql());
<add> }
<add>
<add> public function testJoinsWithMultipleNestedJoins()
<add> {
<add> $builder = $this->getBuilder();
<add> $builder->select('users.id', 'contacts.id', 'contact_types.id', 'countrys.id', 'planets.id')->from('users')->leftJoin('contacts', function ($j) {
<add> $j->on('users.id', 'contacts.id')
<add> ->join('contact_types', 'contacts.contact_type_id', '=', 'contact_types.id')
<add> ->leftJoin('countrys', function ($q) {
<add> $q->on('contacts.country', '=', 'countrys.country')
<add> ->join('planets', function ($q) {
<add> $q->on('countrys.planet_id', '=', 'planet.id')
<add> ->where('planet.is_settled', '=', 1)
<add> ->where('planet.population', '>=', 10000);
<add> });
<add> });
<add> });
<add> $this->assertEquals('select "users"."id", "contacts"."id", "contact_types"."id", "countrys"."id", "planets"."id" from "users" left join "contacts" inner join "contact_types" on "contacts"."contact_type_id" = "contact_types"."id" left join "countrys" inner join "planets" on "countrys"."planet_id" = "planet"."id" and "planet"."is_settled" = ? and "planet"."population" >= ? on "contacts"."country" = "countrys"."country" on "users"."id" = "contacts"."id"', $builder->toSql());
<add> $this->assertEquals(['1', 10000], $builder->getBindings());
<add> }
<add>
<add> public function testJoinsWithNestedJoinWithAdvancedSubqueryCondition()
<add> {
<add> $builder = $this->getBuilder();
<add> $builder->select('users.id', 'contacts.id', 'contact_types.id')->from('users')->leftJoin('contacts', function ($j) {
<add> $j->on('users.id', 'contacts.id')
<add> ->join('contact_types', 'contacts.contact_type_id', '=', 'contact_types.id')
<add> ->whereExists(function ($q) {
<add> $q->select('*')->from('countrys')
<add> ->whereColumn('contacts.country', '=', 'countrys.country')
<add> ->join('planets', function ($q) {
<add> $q->on('countrys.planet_id', '=', 'planet.id')
<add> ->where('planet.is_settled', '=', 1);
<add> })
<add> ->where('planet.population', '>=', 10000);
<add> });
<add> });
<add> $this->assertEquals('select "users"."id", "contacts"."id", "contact_types"."id" from "users" left join "contacts" inner join "contact_types" on "contacts"."contact_type_id" = "contact_types"."id" on "users"."id" = "contacts"."id" and exists (select * from "countrys" inner join "planets" on "countrys"."planet_id" = "planet"."id" and "planet"."is_settled" = ? where "contacts"."country" = "countrys"."country" and "planet"."population" >= ?)', $builder->toSql());
<add> $this->assertEquals(['1', 10000], $builder->getBindings());
<add> }
<add>
<ide> public function testRawExpressionsInSelect()
<ide> {
<ide> $builder = $this->getBuilder(); | 2 |
Javascript | Javascript | set language back to en after every language test | e5f429df97be36477bc9e96546dcf8588d3052d8 | <ide><path>test/lang/bg.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:bg"] = {
<add> setUp: function(cb) {
<add> moment.lang('bg');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('bg');
<ide> var tests = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:bg"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('bg');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'неделя, февруари 14-ти 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'нед, 3PM'],
<ide> exports["lang:bg"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('bg');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1-ви', '1-ви');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2-ри', '2-ри');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3-ти', '3-ти');
<ide> exports["lang:bg"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('bg');
<ide> var expected = 'януари янр_февруари фев_март мар_април апр_май май_юни юни_юли юли_август авг_септември сеп_октомври окт_ноември ное_декември дек'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:bg"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('bg');
<ide> var expected = 'неделя нед нд_понеделник пон пн_вторник вто вт_сряда сря ср_четвъртък чет чт_петък пет пт_събота съб сб'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:bg"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('bg');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "няколко секунди", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "минута", "45 seconds = a minute");
<ide> exports["lang:bg"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('bg');
<ide> test.equal(moment(30000).from(0), "след няколко секунди", "prefix");
<ide> test.equal(moment(0).from(30000), "преди няколко секунди", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('bg');
<ide> test.equal(moment().fromNow(), "преди няколко секунди", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('bg');
<ide> test.equal(moment().add({s:30}).fromNow(), "след няколко секунди", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "след 5 дни", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('bg');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:bg"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('bg');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:bg"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('bg');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:bg"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('bg');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/ca.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:ca"] = {
<add> setUp: function(cb) {
<add> moment.lang('ca');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ca');
<del>
<add>
<ide> var tests = "Gener Gen._Febrer Febr._Març Mar._Abril Abr._Maig Mai._Juny Jun._Juliol Jul._Agost Ag._Setembre Set._Octubre Oct._Novembre Nov._Desembre Des.".split("_");
<del>
<add>
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
<ide> exports["lang:ca"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('ca');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:ca"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:ca"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:ca"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ca');
<ide> var expected = "Gener Gen._Febrer Febr._Març Mar._Abril Abr._Maig Mai._Juny Jun._Juliol Jul._Agost Ag._Setembre Set._Octubre Oct._Novembre Nov._Desembre Des.".split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ca"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ca');
<ide> var expected = "Diumenge Dg. Dg_Dilluns Dl. Dl_Dimarts Dt. Dt_Dimecres Dc. Dc_Dijous Dj. Dj_Divendres Dv. Dv_Dissabte Ds. Ds".split("_");
<del>
<add>
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
<ide> exports["lang:ca"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('ca');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "uns segons", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minut", "45 seconds = a minute");
<ide> exports["lang:ca"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ca');
<ide> test.equal(moment(30000).from(0), "en uns segons", "prefix");
<ide> test.equal(moment(0).from(30000), "fa uns segons", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('ca');
<ide> test.equal(moment().fromNow(), "fa uns segons", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ca');
<ide> test.equal(moment().add({s:30}).fromNow(), "en uns segons", "en uns segons");
<ide> test.equal(moment().add({d:5}).fromNow(), "en 5 dies", "en 5 dies");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ca');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "avui a les 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "avui a les 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "avui a les 3:00", "Now plus 1 hour");
<ide> exports["lang:ca"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ca');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today + " + i + " days current time");
<ide> exports["lang:ca"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ca');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[el] dddd [passat a ' + ((m.hours() !== 1) ? 'les' : 'la') + '] LT'), "Today - " + i + " days current time");
<ide> exports["lang:ca"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ca');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/cs.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:cs"] = {
<add> setUp: function(cb) {
<add> moment.lang('cs');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('cs');
<ide> var tests = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split("_");
<ide> function equalTest(input, mmm, monthIndex) {
<ide> test.equal(moment(input, mmm).month(), monthIndex, input + ' should be month ' + (monthIndex + 1));
<ide> exports["lang:cs"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('cs');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss', 'neděle, únor 14. 2010, 3:25:50'],
<ide> ['ddd, h', 'ne, 3'],
<ide> exports["lang:cs"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('cs');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:cs"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:cs"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:cs"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('cs');
<ide> var expected = 'leden led_únor úno_březen bře_duben dub_květen kvě_červen čvn_červenec čvc_srpen srp_září zář_říjen říj_listopad lis_prosinec pro'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:cs"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('cs');
<ide> var expected = 'neděle ne ne_pondělí po po_úterý út út_středa st st_čtvrtek čt čt_pátek pá pá_sobota so so'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:cs"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('cs');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "pár vteřin", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minuta", "45 seconds = a minute");
<ide> exports["lang:cs"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('cs');
<ide> test.equal(moment(30000).from(0), "za pár vteřin", "prefix");
<ide> test.equal(moment(0).from(30000), "před pár vteřinami", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('cs');
<ide> test.equal(moment().fromNow(), "před pár vteřinami", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow (future)" : function(test) {
<ide> test.expect(16);
<del> moment.lang('cs');
<ide> test.equal(moment().add({s:30}).fromNow(), "za pár vteřin", "in a few seconds");
<ide> test.equal(moment().add({m:1}).fromNow(), "za minutu", "in a minute");
<ide> test.equal(moment().add({m:3}).fromNow(), "za 3 minuty", "in 3 minutes");
<ide> exports["lang:cs"] = {
<ide>
<ide> "fromNow (past)" : function(test) {
<ide> test.expect(16);
<del> moment.lang('cs');
<ide> test.equal(moment().subtract({s:30}).fromNow(), "před pár vteřinami", "a few seconds ago");
<ide> test.equal(moment().subtract({m:1}).fromNow(), "před minutou", "a minute ago");
<ide> test.equal(moment().subtract({m:3}).fromNow(), "před 3 minutami", "3 minutes ago");
<ide> exports["lang:cs"] = {
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('cs');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "dnes v 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "dnes v 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "dnes v 3:00", "Now plus 1 hour");
<ide> exports["lang:cs"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('cs');
<del>
<add>
<ide> for (var i = 2; i < 7; i++) {
<ide> var m = moment().add({ d: i });
<ide> var nextDay = '';
<ide> exports["lang:cs"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('cs');
<del>
<add>
<ide> for (var i = 2; i < 7; i++) {
<ide> var m = moment().subtract({ d: i });
<ide> var lastDay = '';
<ide> exports["lang:cs"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('cs');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide> },
<ide>
<ide> "humanize duration" : function(test) {
<ide> test.expect(4);
<del> moment.lang('cs');
<ide> test.equal(moment.duration(1, "minutes").humanize(), "minuta", "a minute (future)");
<ide> test.equal(moment.duration(1, "minutes").humanize(true), "za minutu", "in a minute");
<ide> test.equal(moment.duration(-1, "minutes").humanize(), "minuta", "a minute (past)");
<ide><path>test/lang/cv.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:cv"] = {
<add> setUp: function(cb) {
<add> moment.lang('cv');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('cv');
<ide> var tests = 'кăрлач кăр_нарăс нар_пуш пуш_ака ака_май май_çĕртме çĕр_утă утă_çурла çур_авăн ав_юпа юпа_чӳк чӳк_раштав раш'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:cv"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('cv');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'вырсарникун, нарăс 14-мĕш 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'выр, 3PM'],
<ide> exports["lang:cv"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('cv');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1-мĕш', '1-мĕш');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2-мĕш', '2-мĕш');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3-мĕш', '3-мĕш');
<ide> exports["lang:cv"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8-мĕш', '8-мĕш');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9-мĕш', '9-мĕш');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10-мĕш', '10-мĕш');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11-мĕш', '11-мĕш');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12-мĕш', '12-мĕш');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13-мĕш', '13-мĕш');
<ide> exports["lang:cv"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18-мĕш', '18-мĕш');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19-мĕш', '19-мĕш');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20-мĕш', '20-мĕш');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21-мĕш', '21-мĕш');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22-мĕш', '22-мĕш');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23-мĕш', '23-мĕш');
<ide> exports["lang:cv"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28-мĕш', '28-мĕш');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29-мĕш', '29-мĕш');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30-мĕш', '30-мĕш');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31-мĕш', '31-мĕш');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('cv');
<ide> var expected = 'кăрлач кăр_нарăс нар_пуш пуш_ака ака_май май_çĕртме çĕр_утă утă_çурла çур_авăн ав_юпа юпа_чӳк чӳк_раштав раш'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:cv"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('cv');
<ide> var expected = 'вырсарникун выр вр_тунтикун тун тн_ытларикун ытл ыт_юнкун юн юн_кĕçнерникун кĕç кç_эрнекун эрн эр_шăматкун шăм шм'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:cv"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('cv');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "пĕр-ик çеккунт", "44 sekunder = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "пĕр минут", "45 seconds = a minute");
<ide> exports["lang:cv"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('cv');
<ide> test.equal(moment(30000).from(0), "пĕр-ик çеккунтран", "prefix");
<ide> test.equal(moment(0).from(30000), "пĕр-ик çеккунт каялла", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('cv');
<ide> test.equal(moment().fromNow(), "пĕр-ик çеккунт каялла", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(4);
<del> moment.lang('cv');
<ide> test.equal(moment().add({s:30}).fromNow(), "пĕр-ик çеккунтран", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 кунран", "in 5 days");
<ide> test.equal(moment().add({h:2}).fromNow(), "2 сехетрен", "in 2 hours, the right suffix!");
<ide> exports["lang:cv"] = {
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('cv');
<del> var a = moment().hours(2).minutes(0).seconds(0);
<add> var a = moment().hours(2).minutes(0).seconds(0);
<ide> test.equal(moment(a).calendar(), "Паян 02:00 сехетре", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Паян 02:25 сехетре", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Паян 03:00 сехетре", "Now plus 1 hour");
<ide> exports["lang:cv"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('cv');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('[Çитес] dddd LT [сехетре]'), "Today + " + i + " days current time");
<ide> exports["lang:cv"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('cv');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[Иртнĕ] dddd LT [сехетре]'), "Today - " + i + " days current time");
<ide> exports["lang:cv"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('cv');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/da.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:da"] = {
<add> setUp: function(cb) {
<add> moment.lang('da');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('da');
<ide> var tests = 'Januar Jan_Februar Feb_Marts Mar_April Apr_Maj Maj_Juni Jun_Juli Jul_August Aug_September Sep_Oktober Okt_November Nov_December Dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:da"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('da');
<ide> var a = [
<ide> ['dddd \\den MMMM Do YYYY, h:mm:ss a', 'Søndag den Februar 14. 2010, 3:25:50 pm'],
<ide> ['ddd hA', 'Søn 3PM'],
<ide> exports["lang:da"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('da');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:da"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:da"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:da"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('da');
<ide> var expected = 'Januar Jan_Februar Feb_Marts Mar_April Apr_Maj Maj_Juni Jun_Juli Jul_August Aug_September Sep_Oktober Okt_November Nov_December Dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:da"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('da');
<ide> var expected = 'Søndag Søn Sø_Mandag Man Ma_Tirsdag Tir Ti_Onsdag Ons On_Torsdag Tor To_Fredag Fre Fr_Lørdag Lør Lø'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:da"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('da');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "få sekunder", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minut", "45 seconds = a minute");
<ide> exports["lang:da"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('da');
<ide> test.equal(moment(30000).from(0), "om få sekunder", "prefix");
<ide> test.equal(moment(0).from(30000), "få sekunder siden", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('da');
<ide> test.equal(moment().fromNow(), "få sekunder siden", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('da');
<ide> test.equal(moment().add({s:30}).fromNow(), "om få sekunder", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "om 5 dage", "in 5 days");
<ide> test.done();
<ide><path>test/lang/de.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:de"] = {
<add> setUp: function(cb) {
<add> moment.lang('de');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('de');
<ide> var tests = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:de"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('de');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, h:mm:ss a', 'Sonntag, 14. Februar 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'So., 3PM'],
<ide> exports["lang:de"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('de');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:de"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:de"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:de"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('de');
<ide> var expected = 'Januar Jan._Februar Febr._März Mrz._April Apr._Mai Mai_Juni Jun._Juli Jul._August Aug._September Sept._Oktober Okt._November Nov._Dezember Dez.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:de"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('de');
<ide> var expected = 'Sonntag So. So_Montag Mo. Mo_Dienstag Di. Di_Mittwoch Mi. Mi_Donnerstag Do. Do_Freitag Fr. Fr_Samstag Sa. Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:de"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('de');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "ein paar Sekunden", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "einer Minute", "45 seconds = a minute");
<ide> exports["lang:de"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('de');
<ide> test.equal(moment(30000).from(0), "in ein paar Sekunden", "prefix");
<ide> test.equal(moment(0).from(30000), "vor ein paar Sekunden", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('de');
<ide> test.equal(moment().add({s:30}).fromNow(), "in ein paar Sekunden", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "in 5 Tagen", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('de');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Heute um 2:00 Uhr", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Heute um 2:25 Uhr", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Heute um 3:00 Uhr", "Now plus 1 hour");
<ide> exports["lang:de"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('de');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [um] LT'), "Today + " + i + " days current time");
<ide> exports["lang:de"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('de');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[letzten] dddd [um] LT'), "Today + " + i + " days current time");
<ide> exports["lang:de"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('de');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/en-ca.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:en-ca"] = {
<add> setUp: function(cb) {
<add> moment.lang('en-ca');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('en-ca');
<ide> var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('en-ca');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Sun, 3PM'],
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('en-gb');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
<ide> exports["lang:en-ca"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
<ide> exports["lang:en-ca"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
<ide> exports["lang:en-ca"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('en-gb');
<ide> var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('en-gb');
<ide> var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('en-gb');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "a few seconds", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "a minute", "45 seconds = a minute");
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en-gb');
<ide> test.equal(moment(30000).from(0), "in a few seconds", "prefix");
<ide> test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('en-gb');
<ide> test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en-gb');
<ide> test.equal(moment().add({s:30}).fromNow(), "in a few seconds", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('en-gb');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Today at 2:00 AM", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 2:25 AM", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 3:00 AM", "Now plus 1 hour");
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en-gb');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en-gb');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[last] dddd [at] LT'), "Today - " + i + " days current time");
<ide> exports["lang:en-ca"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('en-gb');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/en-gb.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:en-gb"] = {
<add> setUp: function(cb) {
<add> moment.lang('en-gb');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('en-gb');
<ide> var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('en-gb');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Sun, 3PM'],
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('en-gb');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
<ide> exports["lang:en-gb"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
<ide> exports["lang:en-gb"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
<ide> exports["lang:en-gb"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('en-gb');
<ide> var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('en-gb');
<ide> var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('en-gb');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "a few seconds", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "a minute", "45 seconds = a minute");
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en-gb');
<ide> test.equal(moment(30000).from(0), "in a few seconds", "prefix");
<ide> test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('en-gb');
<ide> test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en-gb');
<ide> test.equal(moment().add({s:30}).fromNow(), "in a few seconds", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('en-gb');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Today at 2:00 AM", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 2:25 AM", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 3:00 AM", "Now plus 1 hour");
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en-gb');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en-gb');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[last] dddd [at] LT'), "Today - " + i + " days current time");
<ide> exports["lang:en-gb"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('en-gb');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/en.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:en"] = {
<add> setUp: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('en');
<ide> var tests = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:en"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('en');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Sunday, February 14th 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Sun, 3PM'],
<ide> exports["lang:en"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('en');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
<ide> exports["lang:en"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8th', '8th');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9th', '9th');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10th', '10th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11th', '11th');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12th', '12th');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13th', '13th');
<ide> exports["lang:en"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18th', '18th');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19th', '19th');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20th', '20th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21st', '21st');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22nd', '22nd');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23rd', '23rd');
<ide> exports["lang:en"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28th', '28th');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29th', '29th');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30th', '30th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31st', '31st');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('en');
<ide> var expected = 'January Jan_February Feb_March Mar_April Apr_May May_June Jun_July Jul_August Aug_September Sep_October Oct_November Nov_December Dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('en');
<ide> var expected = 'Sunday Sun Su_Monday Mon Mo_Tuesday Tue Tu_Wednesday Wed We_Thursday Thu Th_Friday Fri Fr_Saturday Sat Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('en');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "a few seconds", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "a minute", "45 seconds = a minute");
<ide> exports["lang:en"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en');
<ide> test.equal(moment(30000).from(0), "in a few seconds", "prefix");
<ide> test.equal(moment(0).from(30000), "a few seconds ago", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('en');
<ide> test.equal(moment().fromNow(), "a few seconds ago", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('en');
<ide> test.equal(moment().add({s:30}).fromNow(), "in a few seconds", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('en');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Today at 2:00 AM", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Today at 2:25 AM", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Today at 3:00 AM", "Now plus 1 hour");
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [at] LT'), "Today + " + i + " days current time");
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('en');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[last] dddd [at] LT'), "Today - " + i + " days current time");
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('en');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/eo.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:eo"] = {
<add> setUp: function(cb) {
<add> moment.lang('eo');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('eo');
<ide> var tests = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:eo"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('eo');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Dimanĉo, februaro 14a 2010, 3:25:50 p.t.m.'],
<ide> ['ddd, hA', 'Dim, 3P.T.M.'],
<ide> exports["lang:eo"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('eo');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3a', '3a');
<ide> exports["lang:eo"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8a', '8a');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9a', '9a');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10a', '10a');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11a', '11a');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12a', '12a');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13a', '13a');
<ide> exports["lang:eo"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18a', '18a');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19a', '19a');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20a', '20a');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23a', '23a');
<ide> exports["lang:eo"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28a', '28a');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29a', '29a');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30a', '30a');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('eo');
<ide> var expected = 'januaro jan_februaro feb_marto mar_aprilo apr_majo maj_junio jun_julio jul_aŭgusto aŭg_septembro sep_oktobro okt_novembro nov_decembro dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:eo"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('eo');
<ide> var expected = 'Dimanĉo Dim Di_Lundo Lun Lu_Mardo Mard Ma_Merkredo Merk Me_Ĵaŭdo Ĵaŭ Ĵa_Vendredo Ven Ve_Sabato Sab Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:eo"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('eo');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "sekundoj", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minuto", "45 seconds = a minute");
<ide> exports["lang:eo"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('eo');
<ide> test.equal(moment(30000).from(0), "je sekundoj", "je prefix");
<ide> test.equal(moment(0).from(30000), "antaŭ sekundoj", "antaŭ prefix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('eo');
<ide> test.equal(moment().fromNow(), "antaŭ sekundoj", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('eo');
<ide> test.equal(moment().add({s:30}).fromNow(), "je sekundoj", "je sekundoj");
<ide> test.equal(moment().add({d:5}).fromNow(), "je 5 tagoj", "je 5 tagoj");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('eo');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Hodiaŭ je 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Hodiaŭ je 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Hodiaŭ je 03:00", "Now plus 1 hour");
<ide> exports["lang:eo"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('eo');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [je] LT'), "Today + " + i + " days current time");
<ide> exports["lang:eo"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('eo');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[pasinta] dddd [je] LT'), "Today - " + i + " days current time");
<ide> exports["lang:eo"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('eo');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/es.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:es"] = {
<add> setUp: function(cb) {
<add> moment.lang('es');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('es');
<ide> var tests = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:es"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('es');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'domingo, febrero 14º 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'dom., 3PM'],
<ide> exports["lang:es"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('es');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:es"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:es"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:es"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('es');
<ide> var expected = 'enero ene._febrero feb._marzo mar._abril abr._mayo may._junio jun._julio jul._agosto ago._septiembre sep._octubre oct._noviembre nov._diciembre dic.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:es"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('es');
<ide> var expected = 'domingo dom. Do_lunes lun. Lu_martes mar. Ma_miércoles mié. Mi_jueves jue. Ju_viernes vie. Vi_sábado sáb. Sá'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:es"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('es');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "unos segundos", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minuto", "45 seconds = a minute");
<ide> exports["lang:es"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('es');
<ide> test.equal(moment(30000).from(0), "en unos segundos", "prefix");
<ide> test.equal(moment(0).from(30000), "hace unos segundos", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('es');
<ide> test.equal(moment().fromNow(), "hace unos segundos", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('es');
<ide> test.equal(moment().add({s:30}).fromNow(), "en unos segundos", "en unos segundos");
<ide> test.equal(moment().add({d:5}).fromNow(), "en 5 días", "en 5 días");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(7);
<del> moment.lang('es');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "hoy a las 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "hoy a las 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "hoy a las 3:00", "Now plus 1 hour");
<ide> exports["lang:es"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('es');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today + " + i + " days current time");
<ide> exports["lang:es"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('es');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[el] dddd [pasado a la' + ((m.hours() !== 1) ? 's' : '') + '] LT'), "Today - " + i + " days current time");
<ide> exports["lang:es"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('es');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/et.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:et"] = {
<add> setUp: function(cb) {
<add> moment.lang('et');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('et');
<ide> var tests = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:et"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('et');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, H:mm:ss', 'pühapäev, 14. veebruar 2010, 15:25:50'],
<ide> ['ddd, h', 'P, 3'],
<ide> exports["lang:et"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('et');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:et"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:et"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:et"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('et');
<ide> var expected = 'jaanuar jaan_veebruar veebr_märts märts_aprill apr_mai mai_juuni juuni_juuli juuli_august aug_september sept_oktoober okt_november nov_detsember dets'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:et"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('et');
<ide> var expected = 'pühapäev P P_esmaspäev E E_teisipäev T T_kolmapäev K K_neljapäev N N_reede R R_laupäev L L'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:et"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('et');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "paari sekundi", "44 seconds = paari sekundi");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minut", "45 seconds = minut");
<ide> exports["lang:et"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('et');
<ide> test.equal(moment(30000).from(0), "paari sekundi pärast", "prefix");
<ide> test.equal(moment(0).from(30000), "paar sekundit tagasi", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('et');
<ide> test.equal(moment().fromNow(), "paar sekundit tagasi", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('et');
<ide> test.equal(moment().add({s:30}).fromNow(), "paari sekundi pärast", "paari sekundi pärast");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 päeva pärast", "5 päeva pärast");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('et');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Täna, 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Täna, 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Täna, 3:00", "Now plus 1 hour");
<ide> exports["lang:et"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('et');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('[Järgmine] dddd LT'), "Today + " + i + " days current time");
<ide> exports["lang:et"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('et');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[Eelmine] dddd LT'), "Today - " + i + " days current time");
<ide> exports["lang:et"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('en');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 nädal tagasi");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "1 nädala pärast");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 nädalat tagasi");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "2 nädala pärast");
<ide> test.done();
<ide><path>test/lang/eu.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:eu"] = {
<add> setUp: function(cb) {
<add> moment.lang('eu');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('eu');
<ide> var tests = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:eu"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('eu');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'igandea, otsaila 14. 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'ig., 3PM'],
<ide> exports["lang:eu"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('eu');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:eu"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:eu"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:eu"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('eu');
<ide> var expected = 'urtarrila urt._otsaila ots._martxoa mar._apirila api._maiatza mai._ekaina eka._uztaila uzt._abuztua abu._iraila ira._urria urr._azaroa aza._abendua abe.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:eu"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('eu');
<ide> var expected = 'igandea ig. ig_astelehena al. al_asteartea ar. ar_asteazkena az. az_osteguna og. og_ostirala ol. ol_larunbata lr. lr'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:eu"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('eu');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "segundo batzuk", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minutu bat", "45 seconds = a minute");
<ide> exports["lang:eu"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('eu');
<ide> test.equal(moment(30000).from(0), "segundo batzuk barru", "prefix");
<ide> test.equal(moment(0).from(30000), "duela segundo batzuk", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('eu');
<ide> test.equal(moment().fromNow(), "duela segundo batzuk", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('eu');
<ide> test.equal(moment().add({s:30}).fromNow(), "segundo batzuk barru", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 egun barru", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('eu');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "gaur 02:00etan", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "gaur 02:25etan", "now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "gaur 03:00etan", "now plus 1 hour");
<ide> exports["lang:eu"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('eu');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd LT[etan]'), "Today + " + i + " days current time");
<ide> exports["lang:eu"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('eu');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[aurreko] dddd LT[etan]'), "Today - " + i + " days current time");
<ide> exports["lang:eu"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('eu');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/fi.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:fi"] = {
<add> setUp: function(cb) {
<add> moment.lang('fi');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('fi');
<ide> var tests = 'tammikuu tam_helmikuu hel_maaliskuu maa_huhtikuu huh_toukokuu tou_kesäkuu kes_heinäkuu hei_elokuu elo_syyskuu syys_lokakuu lok_marraskuu mar_joulukuu jou'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:fi"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('fi');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'sunnuntai, helmikuu 14. 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'su, 3PM'],
<ide> exports["lang:fi"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('fi');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1st');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2nd');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3rd');
<ide> exports["lang:fi"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('fi');
<ide> var expected = 'tammikuu tam_helmikuu hel_maaliskuu maa_huhtikuu huh_toukokuu tou_kesäkuu kes_heinäkuu hei_elokuu elo_syyskuu syy_lokakuu lok_marraskuu mar_joulukuu jou'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fi"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('fi');
<ide> var expected = 'sunnuntai su su_maanantai ma ma_tiistai ti ti_keskiviikko ke ke_torstai to to_perjantai pe pe_lauantai la la'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fi"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('fi');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "muutama sekunti", "44 seconds = few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minuutti", "45 seconds = a minute");
<ide> exports["lang:fi"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fi');
<ide> test.equal(moment(30000).from(0), "muutaman sekunnin päästä", "prefix");
<ide> test.equal(moment(0).from(30000), "muutama sekunti sitten", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('fi');
<ide> test.equal(moment().fromNow(), "muutama sekunti sitten", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fi');
<ide> test.equal(moment().add({s:30}).fromNow(), "muutaman sekunnin päästä", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "viiden päivän päästä", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('fi');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:fi"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fi');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:fi"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fi');
<ide>
<ide> for (var i = 2; i < 7; i++) {
<ide> var m = moment().subtract({ d: i });
<ide> exports["lang:fi"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('fi');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/fr-ca.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:fr-ca"] = {
<add> setUp: function(cb) {
<add> moment.lang('fr-ca');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('fr-ca');
<ide> var tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('fr-ca');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14ème 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'dim., 3PM'],
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('fr');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
<ide> exports["lang:fr-ca"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10ème', '10ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11ème', '11ème');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12ème', '12ème');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13ème', '13ème');
<ide> exports["lang:fr-ca"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18ème', '18ème');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19ème', '19ème');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
<ide> exports["lang:fr-ca"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('fr');
<ide> var expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('fr');
<ide> var expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('fr');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "quelques secondes", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "une minute", "45 seconds = a minute");
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fr');
<ide> test.equal(moment(30000).from(0), "dans quelques secondes", "prefix");
<ide> test.equal(moment(0).from(30000), "il y a quelques secondes", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fr');
<ide> test.equal(moment().add({s:30}).fromNow(), "dans quelques secondes", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "dans 5 jours", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "same day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('fr');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Aujourd'hui à 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Aujourd'hui à 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Aujourd'hui à 03:00", "Now plus 1 hour");
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "same next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fr');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [à] LT'), "Today + " + i + " days current time");
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "same last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fr');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [dernier à] LT'), "Today - " + i + " days current time");
<ide> exports["lang:fr-ca"] = {
<ide>
<ide> "same all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('fr');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/fr.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:fr"] = {
<add> setUp: function(cb) {
<add> moment.lang('fr');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('fr');
<ide> var tests = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:fr"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('fr');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'dimanche, février 14ème 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'dim., 3PM'],
<ide> exports["lang:fr"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('fr');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1er', '1er');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2ème', '2ème');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3ème', '3ème');
<ide> exports["lang:fr"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8ème', '8ème');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9ème', '9ème');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10ème', '10ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11ème', '11ème');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12ème', '12ème');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13ème', '13ème');
<ide> exports["lang:fr"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18ème', '18ème');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19ème', '19ème');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20ème', '20ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21ème', '21ème');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22ème', '22ème');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23ème', '23ème');
<ide> exports["lang:fr"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28ème', '28ème');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29ème', '29ème');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30ème', '30ème');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31ème', '31ème');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('fr');
<ide> var expected = 'janvier janv._février févr._mars mars_avril avr._mai mai_juin juin_juillet juil._août août_septembre sept._octobre oct._novembre nov._décembre déc.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fr"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('fr');
<ide> var expected = 'dimanche dim. Di_lundi lun. Lu_mardi mar. Ma_mercredi mer. Me_jeudi jeu. Je_vendredi ven. Ve_samedi sam. Sa'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:fr"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('fr');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "quelques secondes", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "une minute", "45 seconds = a minute");
<ide> exports["lang:fr"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fr');
<ide> test.equal(moment(30000).from(0), "dans quelques secondes", "prefix");
<ide> test.equal(moment(0).from(30000), "il y a quelques secondes", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('fr');
<ide> test.equal(moment().add({s:30}).fromNow(), "dans quelques secondes", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "dans 5 jours", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "same day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('fr');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Aujourd'hui à 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Aujourd'hui à 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Aujourd'hui à 03:00", "Now plus 1 hour");
<ide> exports["lang:fr"] = {
<ide>
<ide> "same next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fr');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [à] LT'), "Today + " + i + " days current time");
<ide> exports["lang:fr"] = {
<ide>
<ide> "same last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('fr');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [dernier à] LT'), "Today - " + i + " days current time");
<ide> exports["lang:fr"] = {
<ide>
<ide> "same all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('fr');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/gl.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:gl"] = {
<add> setUp: function(cb) {
<add> moment.lang('gl');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('gl');
<ide> var tests = "Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Octubro Out._Novembro Nov._Decembro Dec.".split("_");
<del>
<add>
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> test.equal(moment(input, mmm).month(), i, input + ' should be month ' + (i + 1));
<ide> exports["lang:gl"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('es');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:gl"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:gl"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:gl"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('gl');
<ide> var expected = "Xaneiro Xan._Febreiro Feb._Marzo Mar._Abril Abr._Maio Mai._Xuño Xuñ._Xullo Xul._Agosto Ago._Setembro Set._Octubro Out._Novembro Nov._Decembro Dec.".split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:gl"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('gl');
<ide> var expected = "Domingo Dom. Do_Luns Lun. Lu_Martes Mar. Ma_Mércores Mér. Mé_Xoves Xov. Xo_Venres Ven. Ve_Sábado Sáb. Sá".split("_");
<del>
<add>
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
<ide> exports["lang:gl"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('gl');
<ide> var start = moment([2007, 1, 28]);
<del>
<add>
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "uns segundo", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minuto", "45 seconds = a minute");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:89}), true), "un minuto", "89 seconds = a minute");
<ide> exports["lang:gl"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('gl');
<ide> test.equal(moment(30000).from(0), "en uns segundo", "prefix");
<ide> test.equal(moment(0).from(30000), "fai uns segundo", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('gl');
<ide> test.equal(moment().fromNow(), "fai uns segundo", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('gl');
<ide> test.equal(moment().add({s:30}).fromNow(), "en uns segundo", "en unos segundos");
<ide> test.equal(moment().add({d:5}).fromNow(), "en 5 días", "en 5 días");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(7);
<del> moment.lang('gl');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "hoxe ás 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "hoxe ás 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "hoxe ás 3:00", "Now plus 1 hour");
<ide> exports["lang:gl"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('gl');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), "Today + " + i + " days current time");
<ide> exports["lang:gl"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('gl');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[o] dddd [pasado ' + ((m.hours() !== 1) ? 'ás' : 'a') + '] LT'), "Today - " + i + " days current time");
<ide> exports["lang:gl"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('gl');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide> },
<ide>
<ide> "regression tests" : function(test) {
<ide> test.expect(1);
<del> moment.lang('gl');
<ide>
<ide> var lastWeek = moment().subtract({ d: 4 }).hours(1);
<ide> test.equal(lastWeek.calendar(), lastWeek.format('[o] dddd [pasado a] LT'), "1 o'clock bug");
<del>
<add>
<ide>
<ide> test.done();
<ide> }
<ide><path>test/lang/he.js
<ide> *************************************************/
<ide>
<ide> exports["lang:he"] = {
<add> setUp: function(cb) {
<add> moment.lang('he');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('he');
<ide> var tests = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:he"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('he');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'ראשון, פברואר 14 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'א׳, 3PM'],
<ide> exports["lang:he"] = {
<ide> // no need on hebrew
<ide>
<ide> // test.expect(31);
<del>// moment.lang('en');
<ide> // test.equal(moment([2011, 0, 1]).format('DDDo'), '1st', '1st');
<ide> // test.equal(moment([2011, 0, 2]).format('DDDo'), '2nd', '2nd');
<ide> // test.equal(moment([2011, 0, 3]).format('DDDo'), '3rd', '3rd');
<ide> exports["lang:he"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('he');
<ide> var expected = 'ינואר ינו׳_פברואר פבר׳_מרץ מרץ_אפריל אפר׳_מאי מאי_יוני יוני_יולי יולי_אוגוסט אוג׳_ספטמבר ספט׳_אוקטובר אוק׳_נובמבר נוב׳_דצמבר דצמ׳'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:he"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('he');
<ide> var expected = 'ראשון א׳ א|שני ב׳ ב|שלישי ג׳ ג|רביעי ד׳ ד|חמישי ה׳ ה|שישי ו׳ ו|שבת ש׳ ש'.split("|");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:he"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('he');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "מספר שניות", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "דקה", "45 seconds = a minute");
<ide> exports["lang:he"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('he');
<ide> test.equal(moment(30000).from(0), "בעוד מספר שניות", "prefix");
<ide> test.equal(moment(0).from(30000), "לפני מספר שניות", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('he');
<ide> test.equal(moment().fromNow(), "לפני מספר שניות", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('he');
<ide> test.equal(moment().add({s:30}).fromNow(), "בעוד מספר שניות", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "בעוד 5 ימים", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('he');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:he"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('he');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:he"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('he');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:he"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('he');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/hu.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:hu"] = {
<add> setUp: function(cb) {
<add> moment.lang('hu');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('hu');
<ide> var tests = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:hu"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(16);
<del> moment.lang('hu');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, HH:mm:ss', 'vasárnap, február 14. 2010, 15:25:50'],
<ide> ['ddd, HH', 'v, 15'],
<ide> exports["lang:hu"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('hu');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:hu"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('hu');
<ide> var expected = 'január jan_február feb_március márc_április ápr_május máj_június jún_július júl_augusztus aug_szeptember szept_október okt_november nov_december dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:hu"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('hu');
<ide> var expected = 'vasárnap v_hétfő h_kedd k_szerda sze_csütörtök cs_péntek p_szombat szo'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:hu"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('hu');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "néhány másodperc", "44 másodperc = néhány másodperc");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "egy perc", "45 másodperc = egy perc");
<ide> exports["lang:hu"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('hu');
<ide> test.equal(moment(30000).from(0), "néhány másodperc múlva", "prefix");
<ide> test.equal(moment(0).from(30000), "néhány másodperce", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('hu');
<ide> test.equal(moment().fromNow(), "néhány másodperce", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('hu');
<ide> test.equal(moment().add({s:30}).fromNow(), "néhány másodperc múlva", "néhány másodperc múlva");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 nap múlva", "5 nap múlva");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('hu');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:hu"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('hu');
<ide>
<ide> var i;
<ide> var m;
<ide> var days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('['+days[m.day()]+'] LT[-kor]'), "today + " + i + " days current time");
<ide> exports["lang:hu"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('hu');
<ide>
<ide> var days = 'vasárnap_hétfőn_kedden_szerdán_csütörtökön_pénteken_szombaton'.split('_');
<ide>
<ide> exports["lang:hu"] = {
<ide> m.hours(23).minutes(59).seconds(59).milliseconds(999);
<ide> test.equal(m.calendar(), m.format('múlt ['+days[m.day()]+'] LT[-kor]'), "today - " + i + " days end of day");
<ide> }
<del>
<add>
<ide> test.done();
<ide> },
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('hu');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/id.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:id"] = {
<add> setUp: function(cb) {
<add> moment.lang('id');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('id');
<ide> var tests = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:id"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('id');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Minggu, Februari 14 2010, 3:25:50 sore'],
<ide> ['ddd, hA', 'Min, 3sore'],
<ide> exports["lang:id"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('id');
<ide> var expected = 'Januari Jan_Februari Feb_Maret Mar_April Apr_Mei Mei_Juni Jun_Juli Jul_Agustus Ags_September Sep_Oktober Okt_November Nov_Desember Des'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:id"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('id');
<ide> var expected = 'Minggu Min Mg_Senin Sen Sn_Selasa Sel Sl_Rabu Rab Rb_Kamis Kam Km_Jumat Jum Jm_Sabtu Sab Sb'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:id"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('id');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "beberapa detik", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "semenit", "45 seconds = a minute");
<ide> exports["lang:id"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('id');
<ide> test.equal(moment(30000).from(0), "dalam beberapa detik", "prefix");
<ide> test.equal(moment(0).from(30000), "beberapa detik yang lalu", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('id');
<ide> test.equal(moment().fromNow(), "beberapa detik yang lalu", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('id');
<ide> test.equal(moment().add({s:30}).fromNow(), "dalam beberapa detik", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "dalam 5 hari", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('id');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Hari ini pukul 02.00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Hari ini pukul 02.25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Hari ini pukul 03.00", "Now plus 1 hour");
<ide> exports["lang:id"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('id');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [pukul] LT'), "Today + " + i + " days current time");
<ide> exports["lang:id"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('id');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [lalu pukul] LT'), "Today - " + i + " days current time");
<ide> exports["lang:id"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('id');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/is.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:is"] = {
<add> setUp: function(cb) {
<add> moment.lang('is');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('is');
<ide> var tests = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:is"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('is');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, h:mm:ss a', 'sunnudagur, 14. febrúar 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'sun, 3PM'],
<ide> exports["lang:is"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('is');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:is"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:is"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:is"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('is');
<ide> var expected = 'janúar jan_febrúar feb_mars mar_apríl apr_maí maí_júní jún_júlí júl_ágúst ágú_september sep_október okt_nóvember nóv_desember des'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:is"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('is');
<ide> var expected = 'sunnudagur sun Su_mánudagur mán Má_þriðjudagur þri Þr_miðvikudagur mið Mi_fimmtudagur fim Fi_föstudagur fös Fö_laugardagur lau La'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:is"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(34);
<del> moment.lang('is');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "nokkrar sekúndur", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "mínúta", "45 seconds = a minute");
<ide> exports["lang:is"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(3);
<del> moment.lang('is');
<ide> test.equal(moment(30000).from(0), "eftir nokkrar sekúndur", "prefix");
<ide> test.equal(moment(0).from(30000), "fyrir nokkrum sekúndum síðan", "suffix");
<ide> test.equal(moment().subtract({m:1}).fromNow(), "fyrir mínútu síðan", "a minute ago");
<ide> exports["lang:is"] = {
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('is');
<ide> test.equal(moment().fromNow(), "fyrir nokkrum sekúndum síðan", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(3);
<del> moment.lang('is');
<ide> test.equal(moment().add({s:30}).fromNow(), "eftir nokkrar sekúndur", "in a few seconds");
<ide> test.equal(moment().add({m:1}).fromNow(), "eftir mínútu", "in a minute");
<ide> test.equal(moment().add({d:5}).fromNow(), "eftir 5 daga", "in 5 days");
<ide> exports["lang:is"] = {
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('is');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "í dag kl. 2:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "í dag kl. 2:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "í dag kl. 3:00", "Now plus 1 hour");
<ide> exports["lang:is"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('is');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [kl.] LT'), "Today + " + i + " days current time");
<ide> exports["lang:is"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('is');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[síðasta] dddd [kl.] LT'), "Today - " + i + " days current time");
<ide> exports["lang:is"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('is');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/it.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:it"] = {
<add> setUp: function(cb) {
<add> moment.lang('it');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('it');
<ide> var tests = 'Gennaio Gen_Febbraio Feb_Marzo Mar_Aprile Apr_Maggio Mag_Giugno Giu_Luglio Lug_Agosto Ago_Settembre Set_Ottobre Ott_Novembre Nov_Dicembre Dic'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:it"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('it');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domenica, Febbraio 14º 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Dom, 3PM'],
<ide> exports["lang:it"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('it');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:it"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:it"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:it"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('it');
<ide> var expected = 'Gennaio Gen_Febbraio Feb_Marzo Mar_Aprile Apr_Maggio Mag_Giugno Giu_Luglio Lug_Agosto Ago_Settembre Set_Ottobre Ott_Novembre Nov_Dicembre Dic'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:it"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('it');
<ide> var expected = 'Domenica Dom D_Lunedì Lun L_Martedì Mar Ma_Mercoledì Mer Me_Giovedì Gio G_Venerdì Ven V_Sabato Sab S'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:it"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('it');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "secondi", "44 seconds = seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minuto", "45 seconds = a minute");
<ide> exports["lang:it"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('it');
<ide> test.equal(moment(30000).from(0), "in secondi", "prefix");
<ide> test.equal(moment(0).from(30000), "secondi fa", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('it');
<ide> test.equal(moment().add({s:30}).fromNow(), "in secondi", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "in 5 giorni", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('it');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Oggi alle 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Oggi alle 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Oggi alle 03:00", "Now plus 1 hour");
<ide> exports["lang:it"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('it');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [alle] LT'), "Today + " + i + " days current time");
<ide> exports["lang:it"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('it');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[lo scorso] dddd [alle] LT'), "Today - " + i + " days current time");
<ide> exports["lang:it"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('it');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/ja.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:jp"] = {
<add> setUp: function(cb) {
<add> moment.lang('ja');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ja');
<ide> var tests = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('ja');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
<ide> ['ddd, Ah', '日, 午後3'],
<ide> exports["lang:jp"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ja');
<ide> var expected = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ja');
<ide> var expected = '日曜日 日 日_月曜日 月 月_火曜日 火 火_水曜日 水 水_木曜日 木 木_金曜日 金 金_土曜日 土 土'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('ja');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "数秒", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "1分", "45 seconds = a minute");
<ide> exports["lang:jp"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ja');
<ide> test.equal(moment(30000).from(0), "数秒後", "prefix");
<ide> test.equal(moment(0).from(30000), "数秒前", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('ja');
<ide> test.equal(moment().fromNow(), "数秒前", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ja');
<ide> test.equal(moment().add({s:30}).fromNow(), "数秒後", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5日後", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('ja');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ja');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ja');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ja');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/jp.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:jp"] = {
<add> setUp: function(cb) {
<add> moment.lang('jp');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('jp');
<ide> var tests = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('jp');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, a h:mm:ss', '日曜日, 2月 14 2010, 午後 3:25:50'],
<ide> ['ddd, Ah', '日, 午後3'],
<ide> exports["lang:jp"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('jp');
<ide> var expected = '1月 1月_2月 2月_3月 3月_4月 4月_5月 5月_6月 6月_7月 7月_8月 8月_9月 9月_10月 10月_11月 11月_12月 12月'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('jp');
<ide> var expected = '日曜日 日 日_月曜日 月 月_火曜日 火 火_水曜日 水 水_木曜日 木 木_金曜日 金 金_土曜日 土 土'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:jp"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('jp');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "数秒", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "1分", "45 seconds = a minute");
<ide> exports["lang:jp"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('jp');
<ide> test.equal(moment(30000).from(0), "数秒後", "prefix");
<ide> test.equal(moment(0).from(30000), "数秒前", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('jp');
<ide> test.equal(moment().fromNow(), "数秒前", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('jp');
<ide> test.equal(moment().add({s:30}).fromNow(), "数秒後", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5日後", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('jp');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('jp');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('jp');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:jp"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('jp');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/ko.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:kr"] = {
<add> setUp: function(cb) {
<add> moment.lang('ko');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ko');
<ide> var tests = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:kr"] = {
<ide> },
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('ko');
<ide> var a = [
<ide> ['YYYY년 MMMM Do dddd a h:mm:ss', '2010년 2월 14일 일요일 오후 3:25:50'],
<ide> ['ddd A h', '일 오후 3'],
<ide> exports["lang:kr"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('ko');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1일', '1일');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2일', '2일');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3일', '3일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8일', '8일');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9일', '9일');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10일', '10일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11일', '11일');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12일', '12일');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13일', '13일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18일', '18일');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19일', '19일');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20일', '20일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21일', '21일');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22일', '22일');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23일', '23일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28일', '28일');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29일', '29일');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30일', '30일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31일', '31일');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ko');
<ide> var expected = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:kr"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ko');
<ide> var expected = '일요일 일 일_월요일 월 월_화요일 화 화_수요일 수 수_목요일 목 목_금요일 금 금_토요일 토 토'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:kr"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('ko');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "몇초", "44초 = 몇초");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "일분", "45초 = 일분");
<ide> exports["lang:kr"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ko');
<ide> test.equal(moment(30000).from(0), "몇초 후", "prefix");
<ide> test.equal(moment(0).from(30000), "몇초 전", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('ko');
<ide> test.equal(moment().fromNow(), "몇초 전", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ko');
<ide> test.equal(moment().add({s:30}).fromNow(), "몇초 후", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5일 후", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('ko');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "오늘 오전 2시 00분", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "오늘 오전 2시 25분", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "오늘 오전 3시 00분", "Now plus 1 hour");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ko');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd LT'), "Today + " + i + " days current time");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ko');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('지난주 dddd LT'), "Today - " + i + " days current time");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ko');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/kr.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:kr"] = {
<add> setUp: function(cb) {
<add> moment.lang('kr');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('kr');
<ide> var tests = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:kr"] = {
<ide> },
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('kr');
<ide> var a = [
<ide> ['YYYY년 MMMM Do dddd a h:mm:ss', '2010년 2월 14일 일요일 오후 3:25:50'],
<ide> ['ddd A h', '일 오후 3'],
<ide> exports["lang:kr"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('kr');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1일', '1일');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2일', '2일');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3일', '3일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8일', '8일');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9일', '9일');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10일', '10일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11일', '11일');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12일', '12일');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13일', '13일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18일', '18일');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19일', '19일');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20일', '20일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21일', '21일');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22일', '22일');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23일', '23일');
<ide> exports["lang:kr"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28일', '28일');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29일', '29일');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30일', '30일');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31일', '31일');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('kr');
<ide> var expected = '1월 1월_2월 2월_3월 3월_4월 4월_5월 5월_6월 6월_7월 7월_8월 8월_9월 9월_10월 10월_11월 11월_12월 12월'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:kr"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('kr');
<ide> var expected = '일요일 일 일_월요일 월 월_화요일 화 화_수요일 수 수_목요일 목 목_금요일 금 금_토요일 토 토'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:kr"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('kr');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "몇초", "44초 = 몇초");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "일분", "45초 = 일분");
<ide> exports["lang:kr"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('kr');
<ide> test.equal(moment(30000).from(0), "몇초 후", "prefix");
<ide> test.equal(moment(0).from(30000), "몇초 전", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('kr');
<ide> test.equal(moment().fromNow(), "몇초 전", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('kr');
<ide> test.equal(moment().add({s:30}).fromNow(), "몇초 후", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5일 후", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('kr');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "오늘 오전 2시 00분", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "오늘 오전 2시 25분", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "오늘 오전 3시 00분", "Now plus 1 hour");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('kr');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd LT'), "Today + " + i + " days current time");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('kr');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('지난주 dddd LT'), "Today - " + i + " days current time");
<ide> exports["lang:kr"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('kr');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/lv.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:lv"] = {
<add> setUp: function(cb) {
<add> moment.lang('lv');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('lv');
<ide> var tests = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:lv"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('lv');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, h:mm:ss a', 'svētdiena, 14. februāris 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Sv, 3PM'],
<ide> exports["lang:lv"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('lv');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:lv"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('lv');
<ide> var expected = 'janvāris jan_februāris feb_marts mar_aprīlis apr_maijs mai_jūnijs jūn_jūlijs jūl_augusts aug_septembris sep_oktobris okt_novembris nov_decembris dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:lv"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('lv');
<ide> var expected = 'svētdiena Sv Sv_pirmdiena P P_otrdiena O O_trešdiena T T_ceturtdiena C C_piektdiena Pk Pk_sestdiena S S'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:lv"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('lv');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "dažas sekundes", "44 seconds = seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minūti", "45 seconds = a minute");
<ide> exports["lang:lv"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('lv');
<ide> test.equal(moment(30000).from(0), "dažas sekundes vēlāk", "prefix");
<ide> test.equal(moment(0).from(30000), "dažas sekundes agrāk", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('lv');
<ide> test.equal(moment().fromNow(), "dažas sekundes agrāk", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('lv');
<ide> test.equal(moment().add({s:30}).fromNow(), "dažas sekundes vēlāk", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 dienas vēlāk", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('lv');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:lv"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('lv');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:lv"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('lv');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:lv"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('lv');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/nb.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:nb"] = {
<add> setUp: function(cb) {
<add> moment.lang('nb');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('nb');
<ide> var tests = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:nb"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('nb');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'søndag, februar 14. 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'søn, 3PM'],
<ide> exports["lang:nb"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('nb');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:nb"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:nb"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:nb"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('nb');
<ide> var expected = 'januar jan_februar feb_mars mar_april apr_mai mai_juni jun_juli jul_august aug_september sep_oktober okt_november nov_desember des'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:nb"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('nb');
<ide> var expected = 'søndag søn sø_mandag man ma_tirsdag tir ti_onsdag ons on_torsdag tor to_fredag fre fr_lørdag lør lø'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:nb"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('nb');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "noen sekunder", "44 sekunder = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "ett minutt", "45 seconds = a minute");
<ide> exports["lang:nb"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('nb');
<ide> test.equal(moment(30000).from(0), "om noen sekunder", "prefix");
<ide> test.equal(moment(0).from(30000), "for noen sekunder siden", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('nb');
<ide> test.equal(moment().fromNow(), "for noen sekunder siden", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('nb');
<ide> test.equal(moment().add({s:30}).fromNow(), "om noen sekunder", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "om 5 dager", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('nb');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "I dag klokken 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "I dag klokken 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "I dag klokken 03:00", "Now plus 1 hour");
<ide> exports["lang:nb"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('nb');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [klokken] LT'), "Today + " + i + " days current time");
<ide> exports["lang:nb"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('nb');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[Forrige] dddd [klokken] LT'), "Today - " + i + " days current time");
<ide> exports["lang:nb"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('nb');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/ne.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:ne"] = {
<add> setUp: function(cb) {
<add> moment.lang('ne');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ne');
<ide> var tests = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:ne"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(17);
<del> moment.lang('ne');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, aको h:mm:ss बजे','आइतबार, १४ फेब्रुवरी २०१०, बेलुकाको ३:२५:५० बजे'],
<ide> ['ddd, aको h बजे', 'आइत., बेलुकाको ३ बजे'],
<ide> exports["lang:ne"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('ne');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '१', '१');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '२', '२');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '३', '३');
<ide> exports["lang:ne"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '८', '८');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '९', '९');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '१०', '१०');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '११', '११');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '१२', '१२');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '१३', '१३');
<ide> exports["lang:ne"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '१८', '१८');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '१९', '१९');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '२०', '२०');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '२१', '२१');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '२२','२२');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '२३', '२३');
<ide> exports["lang:ne"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '२८','२८');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '२९','२९');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '३०', '३०');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '३१', '३१');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ne');
<ide> var expected = 'जनवरी जन._फेब्रुवरी फेब्रु._मार्च मार्च_अप्रिल अप्रि._मई मई_जुन जुन_जुलाई जुलाई._अगष्ट अग._सेप्टेम्बर सेप्ट._अक्टोबर अक्टो._नोभेम्बर नोभे._डिसेम्बर डिसे.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ne"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ne');
<ide> var expected = 'आइतबार आइत. आइ._सोमबार सोम. सो._मङ्गलबार मङ्गल. मङ्_बुधबार बुध. बु._बिहिबार बिहि. बि._शुक्रबार शुक्र. शु._शनिबार शनि. श.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ne"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('ne');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "केही समय", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "एक मिनेट", "45 seconds = a minute");
<ide> exports["lang:ne"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ne');
<ide> test.equal(moment(30000).from(0), "केही समयमा", "prefix");
<ide> test.equal(moment(0).from(30000), "केही समय अगाडी", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('ne');
<ide> test.equal(moment().fromNow(), "केही समय अगाडी", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ne');
<ide> test.equal(moment().add({s:30}).fromNow(), "केही समयमा", "केही समयमा");
<ide> test.equal(moment().add({d:5}).fromNow(), "५ दिनमा", "५ दिनमा");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('ne');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "आज रातीको २:०० बजे", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "आज रातीको २:२५ बजे", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "आज बिहानको ३:०० बजे", "Now plus 1 hour");
<ide> exports["lang:ne"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ne');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('[आउँदो] dddd[,] LT'), "Today + " + i + " days current time");
<ide> exports["lang:ne"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ne');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[गएको] dddd[,] LT'), "Today - " + i + " days current time");
<ide> exports["lang:ne"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ne');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide> },
<ide>
<ide> "meridiem" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ne');
<ide>
<ide> test.equal(moment([2011, 2, 23, 2, 30]).format('a'), "राती", "before dawn");
<ide> test.equal(moment([2011, 2, 23, 9, 30]).format('a'), "बिहान", "morning");
<ide><path>test/lang/nl.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:nl"] = {
<add> setUp: function(cb) {
<add> moment.lang('nl');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('nl');
<ide> var tests = 'januari jan._februari feb._maart mrt._april apr._mei mei._juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:nl"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('nl');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, HH:mm:ss', 'zondag, februari 14de 2010, 15:25:50'],
<ide> ['ddd, HH', 'zo., 15'],
<ide> exports["lang:nl"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('nl');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1ste', '1ste');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2de', '2de');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3de', '3de');
<ide> exports["lang:nl"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8ste', '8ste');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9de', '9de');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10de', '10de');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11de', '11de');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12de', '12de');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13de', '13de');
<ide> exports["lang:nl"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18de', '18de');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19de', '19de');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20ste', '20ste');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21ste', '21ste');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22ste', '22ste');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23ste', '23ste');
<ide> exports["lang:nl"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28ste', '28ste');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29ste', '29ste');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30ste', '30ste');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31ste', '31ste');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('nl');
<ide> var expected = 'januari jan._februari feb._maart mrt._april apr._mei mei_juni jun._juli jul._augustus aug._september sep._oktober okt._november nov._december dec.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:nl"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('nl');
<ide> var expected = 'zondag zo. Zo_maandag ma. Ma_dinsdag di. Di_woensdag wo. Wo_donderdag do. Do_vrijdag vr. Vr_zaterdag za. Za'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:nl"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('nl');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "een paar seconden", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "één minuut", "45 seconds = a minute");
<ide> exports["lang:nl"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('nl');
<ide> test.equal(moment(30000).from(0), "over een paar seconden", "prefix");
<ide> test.equal(moment(0).from(30000), "een paar seconden geleden", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('nl');
<ide> test.equal(moment().fromNow(), "een paar seconden geleden", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('nl');
<ide> test.equal(moment().add({s:30}).fromNow(), "over een paar seconden", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "over 5 dagen", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('nl');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Vandaag om 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Vandaag om 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Vandaag om 03:00", "Now plus 1 hour");
<ide> exports["lang:nl"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('nl');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [om] LT'), "Today + " + i + " days current time");
<ide> exports["lang:nl"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('nl');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[afgelopen] dddd [om] LT'), "Today - " + i + " days current time");
<ide> exports["lang:nl"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('nl');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide> },
<ide>
<ide> "month abbreviation" : function(test) {
<ide> test.expect(2);
<del> moment.lang('nl');
<del>
<add>
<ide> test.equal(moment([2012, 5, 23]).format('D-MMM-YYYY'), '23-jun-2012', 'format month abbreviation surrounded by dashes should not include a dot');
<ide> test.equal(moment([2012, 5, 23]).format('D MMM YYYY'), '23 jun. 2012', 'format month abbreviation not surrounded by dashes should include a dot');
<ide>
<ide><path>test/lang/pl.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:pl"] = {
<add> setUp: function(cb) {
<add> moment.lang('pl');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('pl');
<ide> var tests = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:pl"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('pl');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'niedziela, luty 14. 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'nie, 3PM'],
<ide> exports["lang:pl"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('pl');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:pl"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
<ide> exports["lang:pl"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
<ide> exports["lang:pl"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('pl');
<ide> var expected = 'styczeń sty_luty lut_marzec mar_kwiecień kwi_maj maj_czerwiec cze_lipiec lip_sierpień sie_wrzesień wrz_październik paź_listopad lis_grudzień gru'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pl"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('pl');
<ide> var expected = 'niedziela nie N_poniedziałek pon Pn_wtorek wt Wt_środa śr Śr_czwartek czw Cz_piątek pt Pt_sobota sb So'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pl"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('pl');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "kilka sekund", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "minuta", "45 seconds = a minute");
<ide> exports["lang:pl"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('pl');
<ide> test.equal(moment(30000).from(0), "za kilka sekund", "prefix");
<ide> test.equal(moment(0).from(30000), "kilka sekund temu", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('pl');
<ide> test.equal(moment().fromNow(), "kilka sekund temu", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(3);
<del> moment.lang('pl');
<ide> test.equal(moment().add({s:30}).fromNow(), "za kilka sekund", "in a few seconds");
<ide> test.equal(moment().add({h:1}).fromNow(), "za godzinę", "in an hour");
<ide> test.equal(moment().add({d:5}).fromNow(), "za 5 dni", "in 5 days");
<ide> exports["lang:pl"] = {
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('pl');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Dziś o 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Dziś o 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Dziś o 03:00", "Now plus 1 hour");
<ide> exports["lang:pl"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pl');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('[W] dddd [o] LT'), "Today + " + i + " days current time");
<ide> exports["lang:pl"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pl');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[W zeszły/łą] dddd [o] LT'), "Today - " + i + " days current time");
<ide> exports["lang:pl"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('pl');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/pt-br.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:pt-br"] = {
<add> setUp: function(cb) {
<add> moment.lang('pt-br');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('pt-br');
<ide> var tests = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('pt-br');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Dom, 3PM'],
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('pt-br');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:pt-br"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:pt-br"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:pt-br"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('pt-br');
<ide> var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('pt-br');
<ide> var expected = 'Domingo Dom_Segunda-feira Seg_Terça-feira Ter_Quarta-feira Qua_Quinta-feira Qui_Sexta-feira Sex_Sábado Sáb'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('pt-br');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "segundos", "44 seconds = seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "um minuto", "45 seconds = a minute");
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('pt-br');
<ide> test.equal(moment(30000).from(0), "em segundos", "prefix");
<ide> test.equal(moment(0).from(30000), "segundos atrás", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('pt-br');
<ide> test.equal(moment().add({s:30}).fromNow(), "em segundos", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('pt-br');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Hoje às 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Hoje às 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Hoje às 03:00", "Now plus 1 hour");
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pt-br');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [às] LT'), "Today + " + i + " days current time");
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pt-br');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), "Today - " + i + " days current time");
<ide> exports["lang:pt-br"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('pt-br');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/pt.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:pt"] = {
<add> setUp: function(cb) {
<add> moment.lang('pt');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('pt');
<ide> var tests = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:pt"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('pt');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Domingo, Fevereiro 14º 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Dom, 3PM'],
<ide> exports["lang:pt"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('pt');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1º', '1º');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2º', '2º');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3º', '3º');
<ide> exports["lang:pt"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8º', '8º');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9º', '9º');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10º', '10º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11º', '11º');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12º', '12º');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13º', '13º');
<ide> exports["lang:pt"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18º', '18º');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19º', '19º');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20º', '20º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21º', '21º');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22º', '22º');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23º', '23º');
<ide> exports["lang:pt"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28º', '28º');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29º', '29º');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30º', '30º');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31º', '31º');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('pt');
<ide> var expected = 'Janeiro Jan_Fevereiro Fev_Março Mar_Abril Abr_Maio Mai_Junho Jun_Julho Jul_Agosto Ago_Setembro Set_Outubro Out_Novembro Nov_Dezembro Dez'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pt"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('pt');
<ide> var expected = 'Domingo Dom Dom_Segunda-feira Seg 2ª_Terça-feira Ter 3ª_Quarta-feira Qua 4ª_Quinta-feira Qui 5ª_Sexta-feira Sex 6ª_Sábado Sáb Sáb'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:pt"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('pt');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "segundos", "44 seconds = seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "um minuto", "45 seconds = a minute");
<ide> exports["lang:pt"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('pt');
<ide> test.equal(moment(30000).from(0), "em segundos", "prefix");
<ide> test.equal(moment(0).from(30000), "segundos atrás", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('pt');
<ide> test.equal(moment().add({s:30}).fromNow(), "em segundos", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "em 5 dias", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('pt');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Hoje às 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Hoje às 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Hoje às 03:00", "Now plus 1 hour");
<ide> exports["lang:pt"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pt');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [às] LT'), "Today + " + i + " days current time");
<ide> exports["lang:pt"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('pt');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format((m.day() === 0 || m.day() === 6) ? '[Último] dddd [às] LT' : '[Última] dddd [às] LT'), "Today - " + i + " days current time");
<ide> exports["lang:pt"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('pt');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/ro.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:ro"] = {
<add> setUp: function(cb) {
<add> moment.lang('ro');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ro');
<ide> var tests = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:ro"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('ro');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss A', 'Duminică, Februarie 14 2010, 3:25:50 PM'],
<ide> ['ddd, hA', 'Dum, 3PM'],
<ide> exports["lang:ro"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('ro');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
<ide> exports["lang:ro"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ro');
<ide> var expected = 'Ianuarie Ian_Februarie Feb_Martie Mar_Aprilie Apr_Mai Mai_Iunie Iun_Iulie Iul_August Aug_Septembrie Sep_Octombrie Oct_Noiembrie Noi_Decembrie Dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ro"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ro');
<ide> var expected = 'Duminică Dum Du_Luni Lun Lu_Marţi Mar Ma_Miercuri Mie Mi_Joi Joi Jo_Vineri Vin Vi_Sâmbătă Sâm Sâ'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ro"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('ro');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "câteva secunde", "44 secunde = câteva secunde");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "un minut", "45 secunde = un minut");
<ide> exports["lang:ro"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ro');
<ide> test.equal(moment(30000).from(0), "peste câteva secunde", "prefix");
<ide> test.equal(moment(0).from(30000), "câteva secunde în urmă", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('ro');
<ide> test.equal(moment().fromNow(), "câteva secunde în urmă", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ro');
<ide> test.equal(moment().add({s:30}).fromNow(), "peste câteva secunde", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "peste 5 zile", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('ro');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:ro"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ro');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:ro"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ro');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:ro"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ro');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/ru.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:ru"] = {
<add> setUp: function(cb) {
<add> moment.lang('ru');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('ru');
<ide> var tests = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июн_июль июл_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:ru"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('ru');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'воскресенье, февраль 14. 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'вск, 3PM'],
<ide> exports["lang:ru"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('ru');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:ru"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('ru');
<ide> var expected = 'январь янв_февраль фев_март мар_апрель апр_май май_июнь июн_июль июл_август авг_сентябрь сен_октябрь окт_ноябрь ноя_декабрь дек'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ru"] = {
<ide>
<ide> "format month case" : function(test) {
<ide> test.expect(24);
<del> moment.lang('ru');
<ide> var months = {
<ide> 'nominative': 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
<ide> 'accusative': 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_')
<ide> exports["lang:ru"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('ru');
<ide> var expected = 'воскресенье вск вс_понедельник пнд пн_вторник втр вт_среда срд ср_четверг чтв чт_пятница птн пт_суббота сбт сб'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:ru"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(32);
<del> moment.lang('ru');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "несколько секунд", "44 seconds = seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "минута", "45 seconds = a minute");
<ide> exports["lang:ru"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ru');
<ide> test.equal(moment(30000).from(0), "через несколько секунд", "prefix");
<ide> test.equal(moment(0).from(30000), "несколько секунд назад", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('ru');
<ide> test.equal(moment().add({s:30}).fromNow(), "через несколько секунд", "in seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "через 5 дней", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('ru');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:ru"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ru');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:ru"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('ru');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:ru"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('ru');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/sl.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:en"] = {
<add> setUp: function(cb) {
<add> moment.lang('sl');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('sl');
<ide> var tests = 'januar jan._februar feb._marec mar._april apr._maj maj_junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:en"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('sl');
<ide> var a = [
<ide> ['dddd, Do MMMM YYYY, h:mm:ss a', 'nedelja, 14. februar 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'ned., 3PM'],
<ide> exports["lang:en"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('sl');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1.', '1.');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2.', '2.');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3.', '3.');
<ide> exports["lang:en"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('sl');
<ide> var expected = 'januar jan._februar feb._marec mar._april apr._maj maj._junij jun._julij jul._avgust avg._september sep._oktober okt._november nov._december dec.'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('sl');
<ide> var expected = 'nedelja ned. ne_ponedeljek pon. po_torek tor. to_sreda sre. sr_četrtek čet. če_petek pet. pe_sobota sob. so'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:en"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('sl');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "nekaj sekund", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "ena minuta", "45 seconds = a minute");
<ide> exports["lang:en"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('sl');
<ide> test.equal(moment(30000).from(0), "čez nekaj sekund", "prefix");
<ide> test.equal(moment(0).from(30000), "nekaj sekund nazaj", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('sl');
<ide> test.equal(moment().fromNow(), "nekaj sekund nazaj", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('sl');
<ide> test.equal(moment().add({s:30}).fromNow(), "čez nekaj sekund", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "čez 5 dni", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('sl');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('sl');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('sl');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:en"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('sl');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide><path>test/lang/sv.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:sv"] = {
<add> setUp: function(cb) {
<add> moment.lang('sv');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('sv');
<ide> var tests = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:sv"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('sv');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'söndag, februari 14e 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'sön, 3PM'],
<ide> exports["lang:sv"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('sv');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1a', '1a');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2a', '2a');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3e', '3e');
<ide> exports["lang:sv"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8e', '8e');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9e', '9e');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10e', '10e');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11e', '11e');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12e', '12e');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13e', '13e');
<ide> exports["lang:sv"] = {
<ide> test.equal(moment([2011, 0, 18]).format('DDDo'), '18e', '18e');
<ide> test.equal(moment([2011, 0, 19]).format('DDDo'), '19e', '19e');
<ide> test.equal(moment([2011, 0, 20]).format('DDDo'), '20e', '20e');
<del>
<add>
<ide> test.equal(moment([2011, 0, 21]).format('DDDo'), '21a', '21a');
<ide> test.equal(moment([2011, 0, 22]).format('DDDo'), '22a', '22a');
<ide> test.equal(moment([2011, 0, 23]).format('DDDo'), '23e', '23e');
<ide> exports["lang:sv"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28e', '28e');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29e', '29e');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30e', '30e');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31a', '31a');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('sv');
<ide> var expected = 'januari jan_februari feb_mars mar_april apr_maj maj_juni jun_juli jul_augusti aug_september sep_oktober okt_november nov_december dec'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:sv"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('sv');
<ide> var expected = 'söndag sön sö_måndag mån må_tisdag tis ti_onsdag ons on_torsdag tor to_fredag fre fr_lördag lör lö'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:sv"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('sv');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "några sekunder", "44 sekunder = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "en minut", "45 seconds = a minute");
<ide> exports["lang:sv"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('sv');
<ide> test.equal(moment(30000).from(0), "om några sekunder", "prefix");
<ide> test.equal(moment(0).from(30000), "för några sekunder sen", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('sv');
<ide> test.equal(moment().fromNow(), "för några sekunder sen", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('sv');
<ide> test.equal(moment().add({s:30}).fromNow(), "om några sekunder", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "om 5 dagar", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('sv');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "Idag klockan 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "Idag klockan 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "Idag klockan 03:00", "Now plus 1 hour");
<ide> exports["lang:sv"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('sv');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('dddd [klockan] LT'), "Today + " + i + " days current time");
<ide> exports["lang:sv"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('sv');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[Förra] dddd[en klockan] LT'), "Today - " + i + " days current time");
<ide> exports["lang:sv"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('sv');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/tr.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:tr"] = {
<add> setUp: function(cb) {
<add> moment.lang('tr');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('tr');
<ide> var tests = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:tr"] = {
<ide> },
<ide>
<ide> "format" : function(test) {
<del> moment.lang('tr');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, h:mm:ss a', 'Pazar, Şubat 14\'üncü 2010, 3:25:50 pm'],
<ide> ['ddd, hA', 'Paz, 3PM'],
<ide> exports["lang:tr"] = {
<ide>
<ide> "format ordinal" : function(test) {
<ide> test.expect(31);
<del> moment.lang('tr');
<ide> test.equal(moment([2011, 0, 1]).format('DDDo'), '1\'inci', '1st');
<ide> test.equal(moment([2011, 0, 2]).format('DDDo'), '2\'nci', '2nd');
<ide> test.equal(moment([2011, 0, 3]).format('DDDo'), '3\'üncü', '3rd');
<ide> exports["lang:tr"] = {
<ide> test.equal(moment([2011, 0, 8]).format('DDDo'), '8\'inci', '8th');
<ide> test.equal(moment([2011, 0, 9]).format('DDDo'), '9\'uncu', '9th');
<ide> test.equal(moment([2011, 0, 10]).format('DDDo'), '10\'uncu', '10th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 11]).format('DDDo'), '11\'inci', '11th');
<ide> test.equal(moment([2011, 0, 12]).format('DDDo'), '12\'nci', '12th');
<ide> test.equal(moment([2011, 0, 13]).format('DDDo'), '13\'üncü', '13th');
<ide> exports["lang:tr"] = {
<ide> test.equal(moment([2011, 0, 28]).format('DDDo'), '28\'inci', '28th');
<ide> test.equal(moment([2011, 0, 29]).format('DDDo'), '29\'uncu', '29th');
<ide> test.equal(moment([2011, 0, 30]).format('DDDo'), '30\'uncu', '30th');
<del>
<add>
<ide> test.equal(moment([2011, 0, 31]).format('DDDo'), '31\'inci', '31st');
<ide> test.done();
<ide> },
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('tr');
<ide> var expected = 'Ocak Oca_Şubat Şub_Mart Mar_Nisan Nis_Mayıs May_Haziran Haz_Temmuz Tem_Ağustos Ağu_Eylül Eyl_Ekim Eki_Kasım Kas_Aralık Ara'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:tr"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('tr');
<ide> var expected = 'Pazar Paz Pz_Pazartesi Pts Pt_Salı Sal Sa_Çarşamba Çar Ça_Perşembe Per Pe_Cuma Cum Cu_Cumartesi Cts Ct'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:tr"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('tr');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "birkaç saniye", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "bir dakika", "45 seconds = a minute");
<ide> exports["lang:tr"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('tr');
<ide> test.equal(moment(30000).from(0), "birkaç saniye sonra", "prefix");
<ide> test.equal(moment(0).from(30000), "birkaç saniye önce", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('tr');
<ide> test.equal(moment().fromNow(), "birkaç saniye önce", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('tr');
<ide> test.equal(moment().add({s:30}).fromNow(), "birkaç saniye sonra", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5 gün sonra", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('tr');
<del>
<add>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<del>
<add>
<ide> test.equal(moment(a).calendar(), "bugün saat 02:00", "today at the same time");
<ide> test.equal(moment(a).add({ m: 25 }).calendar(), "bugün saat 02:25", "Now plus 25 min");
<ide> test.equal(moment(a).add({ h: 1 }).calendar(), "bugün saat 03:00", "Now plus 1 hour");
<ide> exports["lang:tr"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('tr');
<del>
<add>
<ide> var i;
<ide> var m;
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().add({ d: i });
<ide> test.equal(m.calendar(), m.format('[haftaya] dddd [saat] LT'), "Today + " + i + " days current time");
<ide> exports["lang:tr"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('tr');
<del>
<add>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> test.equal(m.calendar(), m.format('[geçen hafta] dddd [saat] LT'), "Today - " + i + " days current time");
<ide> exports["lang:tr"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('tr');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
<del>
<add>
<ide> weeksAgo = moment().subtract({ w: 2 });
<ide> weeksFromNow = moment().add({ w: 2 });
<del>
<add>
<ide> test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
<ide> test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
<ide> test.done();
<ide><path>test/lang/zh-cn.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:zh-cn"] = {
<add> setUp: function(cb) {
<add> moment.lang('zh-cn');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('zh-cn');
<ide> var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('zh-cn');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14 2010, 下午 3:25:50'],
<ide> ['ddd, Ah', '周日, 下午3'],
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('zh-cn');
<ide> var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('zh-cn');
<ide> var expected = '星期日 周日 日_星期一 周一 一_星期二 周二 二_星期三 周三 三_星期四 周四 四_星期五 周五 五_星期六 周六 六'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('zh-cn');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "几秒", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "1分钟", "45 seconds = a minute");
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('zh-cn');
<ide> test.equal(moment(30000).from(0), "几秒内", "prefix");
<ide> test.equal(moment(0).from(30000), "几秒前", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('zh-cn');
<ide> test.equal(moment().fromNow(), "几秒前", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('zh-cn');
<ide> test.equal(moment().add({s:30}).fromNow(), "几秒内", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5天内", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('zh-cn');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('zh-cn');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('zh-cn');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('zh-cn');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide> exports["lang:zh-cn"] = {
<ide>
<ide> "meridiem" : function(test) {
<ide> test.expect(10);
<del> moment.lang('zh-cn');
<ide>
<ide> test.equal(moment([2011, 2, 23, 0, 0]).format('a'), "早上", "morning");
<ide> test.equal(moment([2011, 2, 23, 9, 0]).format('a'), "上午", "before noon");
<ide><path>test/lang/zh-tw.js
<ide> var moment = require("../../moment");
<ide> *************************************************/
<ide>
<ide> exports["lang:zh-tw"] = {
<add> setUp: function(cb) {
<add> moment.lang('zh-tw');
<add> cb();
<add> },
<add>
<add> tearDown: function(cb) {
<add> moment.lang('en');
<add> cb();
<add> },
<add>
<ide> "parse" : function(test) {
<ide> test.expect(96);
<del> moment.lang('zh-tw');
<ide> var tests = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
<ide> var i;
<ide> function equalTest(input, mmm, i) {
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "format" : function(test) {
<ide> test.expect(18);
<del> moment.lang('zh-tw');
<ide> var a = [
<ide> ['dddd, MMMM Do YYYY, a h:mm:ss', '星期日, 二月 14 2010, 下午 3:25:50'],
<ide> ['ddd, Ah', '週日, 下午3'],
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "format month" : function(test) {
<ide> test.expect(12);
<del> moment.lang('zh-tw');
<ide> var expected = '一月 1月_二月 2月_三月 3月_四月 4月_五月 5月_六月 6月_七月 7月_八月 8月_九月 9月_十月 10月_十一月 11月_十二月 12月'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "format week" : function(test) {
<ide> test.expect(7);
<del> moment.lang('zh-tw');
<ide> var expected = '星期日 週日 日_星期一 週一 一_星期二 週二 二_星期三 週三 三_星期四 週四 四_星期五 週五 五_星期六 週六 六'.split("_");
<ide> var i;
<ide> for (i = 0; i < expected.length; i++) {
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "from" : function(test) {
<ide> test.expect(30);
<del> moment.lang('zh-tw');
<ide> var start = moment([2007, 1, 28]);
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:44}), true), "幾秒", "44 seconds = a few seconds");
<ide> test.equal(start.from(moment([2007, 1, 28]).add({s:45}), true), "一分鐘", "45 seconds = a minute");
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "suffix" : function(test) {
<ide> test.expect(2);
<del> moment.lang('zh-tw');
<ide> test.equal(moment(30000).from(0), "幾秒內", "prefix");
<ide> test.equal(moment(0).from(30000), "幾秒前", "suffix");
<ide> test.done();
<ide> },
<ide>
<ide> "now from now" : function(test) {
<ide> test.expect(1);
<del> moment.lang('zh-tw');
<ide> test.equal(moment().fromNow(), "幾秒前", "now from now should display as in the past");
<ide> test.done();
<ide> },
<ide>
<ide> "fromNow" : function(test) {
<ide> test.expect(2);
<del> moment.lang('zh-tw');
<ide> test.equal(moment().add({s:30}).fromNow(), "幾秒內", "in a few seconds");
<ide> test.equal(moment().add({d:5}).fromNow(), "5天內", "in 5 days");
<ide> test.done();
<ide> },
<ide>
<ide> "calendar day" : function(test) {
<ide> test.expect(6);
<del> moment.lang('zh-tw');
<ide>
<ide> var a = moment().hours(2).minutes(0).seconds(0);
<ide>
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "calendar next week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('zh-tw');
<ide>
<ide> var i;
<ide> var m;
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "calendar last week" : function(test) {
<ide> test.expect(15);
<del> moment.lang('zh-tw');
<ide>
<ide> for (i = 2; i < 7; i++) {
<ide> m = moment().subtract({ d: i });
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "calendar all else" : function(test) {
<ide> test.expect(4);
<del> moment.lang('zh-tw');
<ide> var weeksAgo = moment().subtract({ w: 1 });
<ide> var weeksFromNow = moment().add({ w: 1 });
<ide>
<ide> exports["lang:zh-tw"] = {
<ide>
<ide> "meridiem" : function(test) {
<ide> test.expect(10);
<del> moment.lang('zh-cn');
<ide>
<ide> test.equal(moment([2011, 2, 23, 0, 0]).format('a'), "早上", "morning");
<ide> test.equal(moment([2011, 2, 23, 9, 0]).format('a'), "上午", "before noon"); | 40 |
Ruby | Ruby | expose the root node and call it | c6c4869612cfc365e69588965d266ed93f8aa05d | <ide><path>activerecord/lib/active_record/associations/join_dependency.rb
<ide> class JoinDependency # :nodoc:
<ide> autoload :JoinBase, 'active_record/associations/join_dependency/join_base'
<ide> autoload :JoinAssociation, 'active_record/associations/join_dependency/join_association'
<ide>
<del> attr_reader :alias_tracker, :base_klass
<add> attr_reader :alias_tracker, :base_klass, :join_root
<ide>
<ide> def self.make_tree(associations)
<ide> hash = {}
<ide> def initialize(base, associations, joins)
<ide> build tree, @join_root, Arel::InnerJoin
<ide> end
<ide>
<del> def join_parts
<del> @join_root.to_a
<del> end
<del>
<ide> def graft(*associations)
<del> join_assocs = join_associations
<del>
<del> associations.reject { |association|
<del> join_assocs.detect { |a| node_cmp association, a }
<add> associations.reject { |join_node|
<add> find_node join_node
<ide> }.each { |join_node|
<del> parent = find_node(join_node.parent) || @join_root
<add> parent = find_node(join_node.parent) || join_root
<ide> reflection = join_node.reflection
<ide> type = join_node.join_type
<ide>
<ide> def graft(*associations)
<ide> end
<ide>
<ide> def join_associations
<del> join_parts.drop 1
<add> join_root.drop 1
<ide> end
<ide>
<ide> def reflections
<ide> def join_relation(relation)
<ide> end
<ide>
<ide> def columns
<del> join_parts.collect { |join_part|
<add> join_root.collect { |join_part|
<ide> table = join_part.aliased_table
<ide> join_part.column_names_with_alias.collect{ |column_name, aliased_name|
<ide> table[column_name].as Arel.sql(aliased_name)
<ide> def columns
<ide> end
<ide>
<ide> def instantiate(result_set)
<del> primary_key = join_base.aliased_primary_key
<add> primary_key = join_root.aliased_primary_key
<ide> parents = {}
<ide>
<ide> type_caster = result_set.column_type primary_key
<del> assoc = @join_root.children
<add> assoc = join_root.children
<ide>
<ide> records = result_set.map { |row_hash|
<ide> primary_id = type_caster.type_cast row_hash[primary_key]
<del> parent = parents[primary_id] ||= join_base.instantiate(row_hash)
<add> parent = parents[primary_id] ||= join_root.instantiate(row_hash)
<ide> construct(parent, assoc, row_hash, result_set)
<ide> parent
<ide> }.uniq
<ide> def instantiate(result_set)
<ide> def find_node(target_node)
<ide> stack = target_node.parents << target_node
<ide>
<del> left = [@join_root]
<add> left = [join_root]
<ide> right = stack.shift
<ide>
<ide> loop {
<ide> def node_cmp(parent, join_part)
<ide> end
<ide> end
<ide>
<del> def join_base
<del> @join_root
<del> end
<del>
<ide> def remove_duplicate_results!(base, records, associations)
<ide> associations.each do |node|
<ide> reflection = base.reflect_on_association(node.name)
<ide> def build_join_association(reflection, parent, join_type)
<ide> raise EagerLoadPolymorphicError.new(reflection)
<ide> end
<ide>
<del> JoinAssociation.new(reflection, join_parts.length, parent, join_type, alias_tracker)
<add> JoinAssociation.new(reflection, join_root.to_a.length, parent, join_type, alias_tracker)
<ide> end
<ide>
<ide> def construct(parent, nodes, row, rs) | 1 |
Javascript | Javascript | fix typos in whatwg-webstreams explanations | 8068f40313a550423145081e0a9c94e52bd21a08 | <ide><path>test/parallel/test-whatwg-webstreams-transfer.js
<ide> const theData = 'hello';
<ide> // Like the ReadableStream test above, this sets up a pipeline
<ide> // through which the data flows...
<ide> //
<del> // We start with WritableStream W1, which is transfered to port1.
<add> // We start with WritableStream W1, which is transferred to port1.
<ide> // Doing so creates an internal ReadableStream R1 and WritableStream W2,
<ide> // which are coupled together with MessagePorts P1 and P2.
<ide> // The port1.onmessage callback receives WritableStream W2 and
<ide> const theData = 'hello';
<ide> // We start with TransformStream T1, which creates ReadableStream R1,
<ide> // and WritableStream W1.
<ide> //
<del> // When T1 is transfered to port1.onmessage, R1 and W1 are individually
<del> // transfered.
<add> // When T1 is transferred to port1.onmessage, R1 and W1 are individually
<add> // transferred.
<ide> //
<del> // When R1 is transfered, it creates internal WritableStream W2, and
<add> // When R1 is transferred, it creates internal WritableStream W2, and
<ide> // new ReadableStream R2, coupled together via MessagePorts P1 and P2.
<ide> //
<del> // When W1 is transfered, it creates internal ReadableStream R3 and
<add> // When W1 is transferred, it creates internal ReadableStream R3 and
<ide> // new WritableStream W3, coupled together via MessagePorts P3 and P4.
<ide> //
<ide> // A new TransformStream T2 is created that owns ReadableStream R2 and
<ide> // WritableStream W3. The port1.onmessage callback immediately transfers
<ide> // that to port2.onmessage.
<ide> //
<del> // When T2 is transfered, R2 and W3 are individually transfered.
<add> // When T2 is transferred, R2 and W3 are individually transferred.
<ide> //
<del> // When R2 is transfered, it creates internal WritableStream W4, and
<add> // When R2 is transferred, it creates internal WritableStream W4, and
<ide> // ReadableStream R4, coupled together via MessagePorts P5 and P6.
<ide> //
<del> // When W3 is transfered, it creates internal ReadableStream R5, and
<add> // When W3 is transferred, it creates internal ReadableStream R5, and
<ide> // WritableStream W5, coupled together via MessagePorts P7 and P8.
<ide> //
<ide> // A new TransformStream T3 is created that owns ReadableStream R4 and | 1 |
Python | Python | clarify documentation of depthwiseconv2d | 751469e85442895dc020bfa4841a871d96b3cfc1 | <ide><path>keras/layers/convolutional.py
<ide> def call(self, inputs):
<ide> class DepthwiseConv2D(Conv2D):
<ide> """Depthwise 2D convolution.
<ide>
<del> Depthwise convolution is a type of convolution in which a single convolutional
<del> filter is apply to each input channel (i.e. in a depthwise way).
<del> You can understand depthwise convolution as being
<del> the first step in a depthwise separable convolution.
<del>
<del> It is implemented via the following steps:
<add> Depthwise convolution is a type of convolution in which each input channel is
<add> convolved with a different filter of depth 1 (called a depthwise kernel). You
<add> can understand depthwise convolution as the first step in a depthwise
<add> separable convolution.
<ide>
<add> It could be implemented via the following steps:
<add>
<ide> - Split the input into individual channels.
<del> - Convolve each input with the layer's kernel (called a depthwise kernel).
<add> - Repeat each input channel `depth_multiplier` many times.
<add> - Convolve each channel with an individual depthwise kernel.
<ide> - Stack the convolved outputs together (along the channels axis).
<ide>
<ide> Unlike a regular 2D convolution, depthwise convolution does not mix
<ide> information across different input channels.
<ide>
<del> The `depth_multiplier` argument controls how many
<del> output channels are generated per input channel in the depthwise step.
<add> The `depth_multiplier` argument determines how many filter are applied to one
<add> input channel. Thereby, it controls the amount of output channels that are
<add> generated per input channel in the depthwise step.
<ide>
<ide> Args:
<ide> kernel_size: An integer or tuple/list of 2 integers, specifying the
<ide> class DepthwiseConv2D(Conv2D):
<ide> `"valid"` means no padding. `"same"` results in padding with zeros evenly
<ide> to the left/right or up/down of the input such that output has the same
<ide> height/width dimension as the input.
<del> depth_multiplier: The number of depthwise convolution output channels
<del> for each input channel.
<del> The total number of depthwise convolution output
<del> channels will be equal to `filters_in * depth_multiplier`.
<add> depth_multiplier: The number of depthwise kernels that are applied to one
<add> input channel.
<add> The total number of depthwise convolution output channels per input
<add> channel will be equal to `filters_in * depth_multiplier`.
<ide> data_format: A string,
<ide> one of `channels_last` (default) or `channels_first`.
<ide> The ordering of the dimensions in the inputs. | 1 |
Text | Text | revive truncated text in readme | 6ac6b992b05f18d757b74f6f79484f3f9d75a967 | <ide><path>readme.md
<ide> app.prepare().then(() => {
<ide> ```
<ide>
<ide> The `next` API is as follows:
<del>- `next(path: string, opts: object)` - `path` is
<add>- `next(path: string, opts: object)` - `path` is where the Next project is located
<ide> - `next(opts: object)`
<ide>
<ide> Supported options: | 1 |
Javascript | Javascript | fix our karma.dump bridge | d1cdd4d026968993db9d0130390bb5138b942224 | <ide><path>src/ng/rootScope.js
<ide> function $RootScopeProvider(){
<ide> *
<ide> * @description
<ide> * Broadcasted when a scope and its children are being destroyed.
<del> *
<add> *
<ide> * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
<ide> * clean up DOM bindings before an element is removed from the DOM.
<ide> */
<ide> function $RootScopeProvider(){
<ide> * Just before a scope is destroyed a `$destroy` event is broadcasted on this scope.
<ide> * Application code can register a `$destroy` event handler that will give it chance to
<ide> * perform any necessary cleanup.
<del> *
<add> *
<ide> * Note that, in AngularJS, there is also a `$destroy` jQuery event, which can be used to
<ide> * clean up DOM bindings before an element is removed from the DOM.
<ide> */
<ide><path>src/ngMock/angular-mocks.js
<ide> angular.mock.dump = function(object) {
<ide> } else if (object instanceof Error) {
<ide> out = object.stack || ('' + object.name + ': ' + object.message);
<ide> } else {
<add> // TODO(i): this prevents methods to be logged, we should have a better way to serialize objects
<ide> out = angular.toJson(object, true);
<ide> }
<ide> } else {
<ide><path>test/testabilityPatch.js
<ide> function trace(name) {
<ide>
<ide> var karmaDump = dump;
<ide> window.dump = function () {
<del> karmaDump(angular.mock.dump.apply(undefined, arguments));
<add> karmaDump.apply(undefined, map(arguments, function(arg) {
<add> return angular.mock.dump(arg);
<add> }));
<ide> }; | 3 |
Javascript | Javascript | add missing return | 803a87fd0e0db8053e44acf3f3af32e1a2f9cd44 | <ide><path>hot/only-dev-server.js
<ide> if(module.hot) {
<ide> return;
<ide> }
<ide>
<del> module.hot.apply({
<add> return module.hot.apply({
<ide> ignoreUnaccepted: true,
<ide> ignoreDeclined: true,
<ide> ignoreErrored: true, | 1 |
Text | Text | add changelog.md entry for add caching | a26801c73f535b2e57366b9d6de0453e7c732884 | <ide><path>CHANGELOG.md
<ide> # Changelog
<ide>
<add>#### Builder
<add>
<add>- ADD now uses image cache, based on sha256 of added content.
<add>
<ide> ## 0.7.2 (2013-12-16)
<ide>
<ide> #### Runtime | 1 |
PHP | PHP | add a command to run all options | afa6baab2db97d619b0365149cf9d1cf0fb39c63 | <ide><path>lib/Cake/Console/Command/UpgradeShell.php
<ide> function startup() {
<ide> $this->out('<warning>Dry-run mode enabled!</warning>', 1, Shell::QUIET);
<ide> }
<ide> }
<add>
<add> function all() {
<add> foreach($this->OptionParser->subcommands() as $command) {
<add> $name = $command->name();
<add> if ($name === 'all') {
<add> continue;
<add> }
<add> $this->out('Running ' . $name);
<add> $this->$name();
<add> }
<add> }
<add>
<ide> /**
<ide> * Update helpers.
<ide> *
<ide> function getOptionParser() {
<ide> return parent::getOptionParser()
<ide> ->description("A shell to help automate upgrading from CakePHP 1.3 to 2.0. \n" .
<ide> "Be sure to have a backup of your application before running these commands.")
<add> ->addSubcommand('all', array(
<add> 'help' => 'Run all upgrade commands.',
<add> 'parser' => $subcommandParser
<add> ))
<ide> ->addSubcommand('i18n', array(
<ide> 'help' => 'Update the i18n translation method calls.',
<ide> 'parser' => $subcommandParser | 1 |
Go | Go | add devzero helper | 2f8d3e1c33f77187c68893803018756d43daff15 | <ide><path>internal/testutil/helpers.go
<ide> package testutil
<ide>
<ide> import (
<add> "io"
<add>
<ide> "github.com/stretchr/testify/assert"
<ide> "github.com/stretchr/testify/require"
<ide> )
<ide> func ErrorContains(t require.TestingT, err error, expectedError string, msgAndAr
<ide> require.Error(t, err, msgAndArgs...)
<ide> assert.Contains(t, err.Error(), expectedError, msgAndArgs...)
<ide> }
<add>
<add>// DevZero acts like /dev/zero but in an OS-independent fashion.
<add>var DevZero io.Reader = devZero{}
<add>
<add>type devZero struct{}
<add>
<add>func (d devZero) Read(p []byte) (n int, err error) {
<add> for i := 0; i < len(p); i++ {
<add> p[i] = '\x00'
<add> }
<add> return len(p), nil
<add>} | 1 |
Ruby | Ruby | consolidate shared install and upgrade logic | 13e1457249ce68a158eae72300a3de4f7361c148 | <ide><path>Library/Homebrew/install.rb
<ide> require "fileutils"
<ide> require "hardware"
<ide> require "development_tools"
<add>require "upgrade"
<ide>
<ide> module Homebrew
<ide> # Helper module for performing (pre-)install checks.
<ide> def install_formula(
<ide> f.print_tap_action
<ide> build_options = f.build
<ide>
<del> if !Homebrew::EnvConfig.no_install_upgrade? && f.outdated? && !f.head?
<del> outdated_formulae = [f, *f.old_installed_formulae]
<del> version_upgrade = "#{f.linked_version} -> #{f.pkg_version}"
<del>
<del> oh1 <<~EOS
<del> #{f.name} #{f.linked_version} is installed but outdated
<del> Upgrading #{Formatter.identifier(f.name)} #{version_upgrade}
<del> EOS
<del> outdated_kegs = outdated_formulae.map(&:linked_keg)
<del> .select(&:directory?)
<del> .map { |k| Keg.new(k.resolved_path) }
<del> linked_kegs = outdated_kegs.select(&:linked?)
<del> end
<del>
<ide> fi = FormulaInstaller.new(
<ide> f,
<ide> options: build_options.used_options,
<ide> def install_formula(
<ide> quiet: quiet,
<ide> verbose: verbose,
<ide> )
<add>
<add> if !Homebrew::EnvConfig.no_install_upgrade? && f.outdated? && !f.head?
<add> kegs = Upgrade.outdated_kegs(f)
<add> linked_kegs = kegs.select(&:linked?)
<add> Upgrade.print_upgrade_message(f, fi.options)
<add> end
<add>
<ide> fi.prelude
<ide> fi.fetch
<ide>
<del> outdated_kegs.each(&:unlink) if outdated_kegs.present?
<add> kegs.each(&:unlink) if kegs.present?
<ide>
<ide> fi.install
<ide> fi.finish
<ide><path>Library/Homebrew/upgrade.rb
<ide> def upgrade_formulae(
<ide> end
<ide> end
<ide>
<add> def outdated_kegs(formula)
<add> [formula, *formula.old_installed_formulae].map(&:linked_keg)
<add> .select(&:directory?)
<add> .map { |k| Keg.new(k.resolved_path) }
<add> end
<add>
<add> def print_upgrade_message(formula, fi_options)
<add> version_upgrade = if formula.optlinked?
<add> "#{Keg.new(formula.opt_prefix).version} -> #{formula.pkg_version}"
<add> else
<add> "-> #{formula.pkg_version}"
<add> end
<add> oh1 <<~EOS
<add> Upgrading #{Formatter.identifier(formula.full_specified_name)}
<add> #{version_upgrade} #{fi_options.to_a.join(" ")}
<add> EOS
<add> end
<add>
<ide> def upgrade_formula(
<ide> formula,
<ide> flags:,
<ide> def upgrade_formula(
<ide> keg_was_linked = keg.linked?
<ide> end
<ide>
<del> formulae_maybe_with_kegs = [formula] + formula.old_installed_formulae
<del> outdated_kegs = formulae_maybe_with_kegs.map(&:linked_keg)
<del> .select(&:directory?)
<del> .map { |k| Keg.new(k.resolved_path) }
<del> linked_kegs = outdated_kegs.select(&:linked?)
<add> kegs = outdated_kegs(formula)
<add> linked_kegs = kegs.select(&:linked?)
<ide>
<ide> if formula.opt_prefix.directory?
<ide> keg = Keg.new(formula.opt_prefix.resolved_path)
<ide> def upgrade_formula(
<ide> }.compact,
<ide> )
<ide>
<del> upgrade_version = if formula.optlinked?
<del> "#{Keg.new(formula.opt_prefix).version} -> #{formula.pkg_version}"
<del> else
<del> "-> #{formula.pkg_version}"
<del> end
<del> oh1 "Upgrading #{Formatter.identifier(formula.full_specified_name)} " \
<del> "#{upgrade_version} #{fi.options.to_a.join(" ")}"
<add> print_upgrade_message(formula, fi.options)
<ide>
<ide> fi.prelude
<ide> fi.fetch
<ide>
<ide> # first we unlink the currently active keg for this formula otherwise it is
<ide> # possible for the existing build to interfere with the build we are about to
<ide> # do! Seriously, it happens!
<del> outdated_kegs.each(&:unlink)
<add> kegs.each(&:unlink)
<ide>
<ide> fi.install
<ide> fi.finish | 2 |
Ruby | Ruby | cache unserialized attributes | 4b7b8d9e19b662d8a1135fec73b422202f97472a | <ide><path>activerecord/lib/active_record/attribute_methods/read.rb
<ide> def cache_attributes(*attribute_names)
<ide> # Returns the attributes which are cached. By default time related columns
<ide> # with datatype <tt>:datetime, :timestamp, :time, :date</tt> are cached.
<ide> def cached_attributes
<del> @cached_attributes ||=
<del> columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map{|col| col.name}.to_set
<add> @cached_attributes ||= columns.select { |c| cacheable_column?(c) }.map { |col| col.name }.to_set
<ide> end
<ide>
<ide> # Returns +true+ if the provided attribute is being cached.
<ide> def cache_attribute?(attr_name)
<ide>
<ide> protected
<ide> def define_method_attribute(attr_name)
<del> if self.serialized_attributes[attr_name]
<add> if serialized_attributes.include?(attr_name)
<ide> define_read_method_for_serialized_attribute(attr_name)
<ide> else
<ide> define_read_method(attr_name.to_sym, attr_name, columns_hash[attr_name])
<ide> def define_method_attribute(attr_name)
<ide> end
<ide>
<ide> private
<add> def cacheable_column?(column)
<add> serialized_attributes.include?(column.name) || attribute_types_cached_by_default.include?(column.type)
<add> end
<add>
<ide> # Define read method for serialized attribute.
<ide> def define_read_method_for_serialized_attribute(attr_name)
<del> generated_attribute_methods.module_eval("def #{attr_name}; unserialize_attribute('#{attr_name}'); end", __FILE__, __LINE__)
<add> access_code = "@attributes_cache['#{attr_name}'] ||= unserialize_attribute('#{attr_name}')"
<add> generated_attribute_methods.module_eval("def #{attr_name}; #{access_code}; end", __FILE__, __LINE__)
<ide> end
<ide>
<ide> # Define an attribute reader method. Cope with nil column.
<ide> def read_attribute(attr_name)
<ide>
<ide> # Returns true if the attribute is of a text column and marked for serialization.
<ide> def unserializable_attribute?(attr_name, column)
<del> column.text? && self.class.serialized_attributes[attr_name]
<add> column.text? && self.class.serialized_attributes.include?(attr_name)
<ide> end
<ide>
<ide> # Returns the unserialized object of the attribute.
<ide><path>activerecord/lib/active_record/base.rb
<ide> class Base
<ide> class_inheritable_accessor :default_scoping, :instance_writer => false
<ide> self.default_scoping = []
<ide>
<add> # Returns a hash of all the attributes that have been specified for serialization as
<add> # keys and their class restriction as values.
<add> class_attribute :serialized_attributes
<add> self.serialized_attributes = {}
<add>
<ide> class << self # Class methods
<ide> delegate :find, :first, :last, :all, :destroy, :destroy_all, :exists?, :delete, :delete_all, :update, :update_all, :to => :scoped
<ide> delegate :find_each, :find_in_batches, :to => :scoped
<ide> def serialize(attr_name, class_name = Object)
<ide> serialized_attributes[attr_name.to_s] = class_name
<ide> end
<ide>
<del> # Returns a hash of all the attributes that have been specified for serialization as
<del> # keys and their class restriction as values.
<del> def serialized_attributes
<del> read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {})
<del> end
<del>
<ide> # Guesses the table name (in forced lower-case) based on the name of the class in the
<ide> # inheritance hierarchy descending directly from ActiveRecord::Base. So if the hierarchy
<ide> # looks like: Reply < Message < ActiveRecord::Base, then Message is used
<ide><path>activerecord/test/cases/attribute_methods_test.rb
<ide> def test_declaring_attributes_as_cached_adds_them_to_the_attributes_cached_by_de
<ide> Topic.instance_variable_set "@cached_attributes", nil
<ide> end
<ide>
<del> def test_time_related_columns_are_actually_cached
<del> column_types = %w(datetime timestamp time date).map(&:to_sym)
<del> column_names = Topic.columns.select{|c| column_types.include?(c.type) }.map(&:name)
<del>
<del> assert_equal column_names.sort, Topic.cached_attributes.sort
<del> assert_equal time_related_columns_on_topic.sort, Topic.cached_attributes.sort
<add> def test_cacheable_columns_are_actually_cached
<add> assert_equal cached_columns.sort, Topic.cached_attributes.sort
<ide> end
<ide>
<ide> def test_accessing_cached_attributes_caches_the_converted_values_and_nothing_else
<ide> def test_accessing_cached_attributes_caches_the_converted_values_and_nothing_els
<ide> assert cache.empty?
<ide>
<ide> all_columns = Topic.columns.map(&:name)
<del> cached_columns = time_related_columns_on_topic
<del> uncached_columns = all_columns - cached_columns
<add> uncached_columns = all_columns - cached_columns
<ide>
<ide> all_columns.each do |attr_name|
<ide> attribute_gets_cached = Topic.cache_attribute?(attr_name)
<ide> def title; "private!"; end
<ide>
<ide>
<ide> private
<add> def cached_columns
<add> @cached_columns ||= (time_related_columns_on_topic + serialized_columns_on_topic).map(&:name)
<add> end
<add>
<ide> def time_related_columns_on_topic
<del> Topic.columns.select{|c| [:time, :date, :datetime, :timestamp].include?(c.type)}.map(&:name)
<add> Topic.columns.select { |c| [:time, :date, :datetime, :timestamp].include?(c.type) }
<add> end
<add>
<add> def serialized_columns_on_topic
<add> Topic.columns.select { |c| Topic.serialized_attributes.include?(c.name) }
<ide> end
<ide>
<ide> def in_time_zone(zone) | 3 |
Python | Python | fix bug in irfftn | 88a02920daf0b408086106439c53bd488e73af29 | <ide><path>numpy/fft/fftpack.py
<ide> def _cook_nd_args(a, s=None, axes=None, invreal=0):
<ide> if len(s) != len(axes):
<ide> raise ValueError("Shape and axes have different lengths.")
<ide> if invreal and shapeless:
<del> s[axes[-1]] = (s[axes[-1]] - 1) * 2
<add> s[-1] = (a.shape[axes[-1]] - 1) * 2
<ide> return s, axes
<ide>
<ide>
<ide><path>numpy/fft/tests/test_helper.py
<ide> """ Test functions for fftpack.helper module
<ide> """
<ide>
<add>import numpy as np
<ide> from numpy.testing import *
<del>from numpy.fft import fftshift,ifftshift,fftfreq
<del>
<add>from numpy import fft
<ide> from numpy import pi
<ide>
<ide> def random(size):
<ide> class TestFFTShift(TestCase):
<ide> def test_definition(self):
<ide> x = [0,1,2,3,4,-4,-3,-2,-1]
<ide> y = [-4,-3,-2,-1,0,1,2,3,4]
<del> assert_array_almost_equal(fftshift(x),y)
<del> assert_array_almost_equal(ifftshift(y),x)
<add> assert_array_almost_equal(fft.fftshift(x),y)
<add> assert_array_almost_equal(fft.ifftshift(y),x)
<ide> x = [0,1,2,3,4,-5,-4,-3,-2,-1]
<ide> y = [-5,-4,-3,-2,-1,0,1,2,3,4]
<del> assert_array_almost_equal(fftshift(x),y)
<del> assert_array_almost_equal(ifftshift(y),x)
<add> assert_array_almost_equal(fft.fftshift(x),y)
<add> assert_array_almost_equal(fft.ifftshift(y),x)
<ide>
<ide> def test_inverse(self):
<ide> for n in [1,4,9,100,211]:
<ide> x = random((n,))
<del> assert_array_almost_equal(ifftshift(fftshift(x)),x)
<del>
<add> assert_array_almost_equal(fft.ifftshift(fft.fftshift(x)),x)
<add>
<ide> def test_axes_keyword(self):
<ide> freqs = [[ 0, 1, 2], [ 3, 4, -4], [-3, -2, -1]]
<ide> shifted = [[-1, -3, -2], [ 2, 0, 1], [-4, 3, 4]]
<del> assert_array_almost_equal(fftshift(freqs, axes=(0, 1)), shifted)
<del> assert_array_almost_equal(fftshift(freqs, axes=0), fftshift(freqs, axes=(0,)))
<del> assert_array_almost_equal(ifftshift(shifted, axes=(0, 1)), freqs)
<del> assert_array_almost_equal(ifftshift(shifted, axes=0), ifftshift(shifted, axes=(0,)))
<add> assert_array_almost_equal(fft.fftshift(freqs, axes=(0, 1)), shifted)
<add> assert_array_almost_equal(fft.fftshift(freqs, axes=0),
<add> fft.fftshift(freqs, axes=(0,)))
<add> assert_array_almost_equal(fft.ifftshift(shifted, axes=(0, 1)), freqs)
<add> assert_array_almost_equal(fft.ifftshift(shifted, axes=0),
<add> fft.ifftshift(shifted, axes=(0,)))
<ide>
<ide>
<ide> class TestFFTFreq(TestCase):
<ide> def test_definition(self):
<ide> x = [0,1,2,3,4,-4,-3,-2,-1]
<del> assert_array_almost_equal(9*fftfreq(9),x)
<del> assert_array_almost_equal(9*pi*fftfreq(9,pi),x)
<add> assert_array_almost_equal(9*fft.fftfreq(9),x)
<add> assert_array_almost_equal(9*pi*fft.fftfreq(9,pi),x)
<ide> x = [0,1,2,3,4,-5,-4,-3,-2,-1]
<del> assert_array_almost_equal(10*fftfreq(10),x)
<del> assert_array_almost_equal(10*pi*fftfreq(10,pi),x)
<add> assert_array_almost_equal(10*fft.fftfreq(10),x)
<add> assert_array_almost_equal(10*pi*fft.fftfreq(10,pi),x)
<add>
<add>class TestIRFFTN(TestCase):
<add>
<add> def test_not_last_axis_success(self):
<add> ar, ai = np.random.random((2, 16, 8, 32))
<add> a = ar + 1j*ai
<add>
<add> axes = (-2,)
<add>
<add> # Should not raise error
<add> fft.irfftn(a, axes=axes)
<ide>
<ide>
<ide> if __name__ == "__main__": | 2 |
Python | Python | remove unused function | eb2a3c5971710af0e52ddb8e3c5df1154ade8618 | <ide><path>spacy/_ml.py
<ide> def finish_update(d_X, sgd=None):
<ide> return (X, lengths), finish_update
<ide>
<ide>
<del>@layerize
<del>def _logistic(X, drop=0.):
<del> xp = get_array_module(X)
<del> if not isinstance(X, xp.ndarray):
<del> X = xp.asarray(X)
<del> # Clip to range (-10, 10)
<del> X = xp.minimum(X, 10., X)
<del> X = xp.maximum(X, -10., X)
<del> Y = 1. / (1. + xp.exp(-X))
<del>
<del> def logistic_bwd(dY, sgd=None):
<del> dX = dY * (Y * (1-Y))
<del> return dX
<del>
<del> return Y, logistic_bwd
<del>
<del>
<ide> def _zero_init(model):
<ide> def _zero_init_impl(self, X, y):
<ide> self.W.fill(0)
<ide> def build_text_classifier(nr_class, width=64, **cfg):
<ide> _preprocess_doc
<ide> >> LinearModel(nr_class)
<ide> )
<del> #model = linear_model >> logistic
<del>
<ide> model = (
<ide> (linear_model | cnn_model)
<ide> >> zero_init(Affine(nr_class, nr_class*2, drop_factor=0.0)) | 1 |
Javascript | Javascript | add blockquote tag (already in jsx) | f7901a2380a11c035a76110b4052e8f2e180c4b6 | <ide><path>src/core/ReactDOM.js
<ide> var ReactDOM = objMapKeyVal({
<ide> address: false,
<ide> audio: false,
<ide> b: false,
<add> blockquote: false,
<ide> body: false,
<ide> br: true,
<ide> button: false, | 1 |
Python | Python | use new api for save and load | a1fe4ba9c9e449cfe8ee96e3190c38b7dce91a76 | <ide><path>examples/lm_finetuning/finetune_on_pregenerated.py
<ide> def main():
<ide> # Save a trained model
<ide> if n_gpu > 1 and torch.distributed.get_rank() == 0 or n_gpu <=1 :
<ide> logging.info("** ** * Saving fine-tuned model ** ** * ")
<del> model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self
<del>
<del> output_model_file = os.path.join(args.output_dir, WEIGHTS_NAME)
<del> output_config_file = os.path.join(args.output_dir, CONFIG_NAME)
<del>
<del> torch.save(model_to_save.state_dict(), output_model_file)
<del> model_to_save.config.to_json_file(output_config_file)
<del> tokenizer.save_vocabulary(args.output_dir)
<add> model.save_pretrained(args.output_dir)
<add> tokenizer.save_pretrained(args.output_dir)
<ide>
<ide>
<ide> if __name__ == '__main__':
<ide><path>examples/lm_finetuning/simple_lm_finetuning.py
<ide> from pytorch_transformers import WEIGHTS_NAME, CONFIG_NAME
<ide> from pytorch_transformers.modeling_bert import BertForPreTraining
<ide> from pytorch_transformers.tokenization_bert import BertTokenizer
<del>from pytorch_transformers.optimization import BertAdam, WarmupLinearSchedule
<add>from pytorch_transformers.optimization import AdamW, WarmupLinearSchedule
<ide>
<ide> logging.basicConfig(format='%(asctime)s - %(levelname)s - %(name)s - %(message)s',
<ide> datefmt='%m/%d/%Y %H:%M:%S',
<ide> def main():
<ide> # Save a trained model
<ide> if args.do_train and ( n_gpu > 1 and torch.distributed.get_rank() == 0 or n_gpu <=1):
<ide> logger.info("** ** * Saving fine - tuned model ** ** * ")
<del> model_to_save = model.module if hasattr(model, 'module') else model # Only save the model it-self
<del> output_model_file = os.path.join(args.output_dir, WEIGHTS_NAME)
<del> output_config_file = os.path.join(args.output_dir, CONFIG_NAME)
<del> torch.save(model_to_save.state_dict(), output_model_file)
<del> model_to_save.config.to_json_file(output_config_file)
<del> tokenizer.save_vocabulary(args.output_dir)
<add> model.save_pretrained(args.output_dir)
<add> tokenizer.save_pretrained(args.output_dir)
<ide>
<ide>
<ide> def _truncate_seq_pair(tokens_a, tokens_b, max_length): | 2 |
Text | Text | remove unused import from doc | 447cea8e726b2102b19be0ec4039a6243e465c31 | <ide><path>docs/api/compose.md
<ide> You might want to use it to apply several [store enhancers](../Glossary.md#store
<ide> This example demonstrates how to use `compose` to enhance a [store](Store.md) with [`applyMiddleware`](applyMiddleware.md) and a few developer tools from the [redux-devtools](https://github.com/gaearon/redux-devtools) package.
<ide>
<ide> ```js
<del>import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
<add>import { createStore, applyMiddleware, compose } from 'redux'
<ide> import thunk from 'redux-thunk'
<ide> import DevTools from './containers/DevTools'
<ide> import reducer from '../reducers/index' | 1 |
Javascript | Javascript | fix key name required with accessing cameraroll | 9a2d6da8bb2169faa8d45279810ab3d26ac78fe7 | <ide><path>Libraries/CameraRoll/CameraRoll.js
<ide> var getPhotosReturnChecker = createStrictShapeTypeChecker({
<ide> *
<ide> * ### Permissions
<ide> * The user's permission is required in order to access the Camera Roll on devices running iOS 10 or later.
<del> * Fill out the `NSCameraUsageDescription` key in your `Info.plist` with a string that describes how your
<del> * app will use this data. This key will appear as `Privacy - Camera Usage Description` in Xcode.
<add> * Add the `NSPhotoLibraryUsageDescription` key in your `Info.plist` with a string that describes how your
<add> * app will use this data. This key will appear as `Privacy - Photo Library Usage Description` in Xcode.
<ide> *
<ide> */
<ide> class CameraRoll { | 1 |
PHP | PHP | return null if cache value is not found | 7a871be756f4e3aee28109fbafe6edfe31bcf052 | <ide><path>src/Illuminate/Cache/RedisStore.php
<ide> public function many(array $keys)
<ide> }, $keys));
<ide>
<ide> foreach ($values as $index => $value) {
<del> $results[$keys[$index]] = $this->unserialize($value);
<add> $results[$keys[$index]] = ! is_null($value) ? $this->unserialize($value) : null;
<ide> }
<ide>
<ide> return $results;
<ide><path>tests/Cache/CacheRedisStoreTest.php
<ide> public function testRedisMultipleValuesAreReturned()
<ide> {
<ide> $redis = $this->getRedis();
<ide> $redis->getRedis()->shouldReceive('connection')->once()->with('default')->andReturn($redis->getRedis());
<del> $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf'])
<add> $redis->getRedis()->shouldReceive('mget')->once()->with(['prefix:foo', 'prefix:fizz', 'prefix:norf', 'prefix:null'])
<ide> ->andReturn([
<ide> serialize('bar'),
<ide> serialize('buzz'),
<ide> serialize('quz'),
<add> null,
<ide> ]);
<del> $this->assertEquals([
<del> 'foo' => 'bar',
<del> 'fizz' => 'buzz',
<del> 'norf' => 'quz',
<del> ], $redis->many([
<del> 'foo', 'fizz', 'norf',
<del> ]));
<add>
<add> $results = $redis->many(['foo', 'fizz', 'norf', 'null']);
<add>
<add> $this->assertEquals('bar', $results['foo']);
<add> $this->assertEquals('buzz', $results['fizz']);
<add> $this->assertEquals('quz', $results['norf']);
<add> $this->assertNull($results['null']);
<ide> }
<ide>
<ide> public function testRedisValueIsReturnedForNumerics() | 2 |
Javascript | Javascript | add test case for defineplugin | 8b1f5f757f4f1628bc3f88ff194c41483efbed00 | <ide><path>test/configCases/plugins/define-plugin/index.js
<ide> it("should define process.env.DEFINED_NESTED_KEY", function() {
<ide> });
<ide> it("should define process.env.DEFINED_NESTED_KEY_STRING", function() {
<ide> if(process.env.DEFINED_NESTED_KEY_STRING !== "string") require("fail");
<del>})
<add>});
<add>it("should assign to process.env", function() {
<add> process.env.TEST = "test";
<add> process.env.TEST.should.be.eql("test");
<add>}); | 1 |
Text | Text | fix syntax errors in transformer/ | 7406641a35a70896b11f91fba841ad17a4b52f04 | <ide><path>official/nlp/transformer/README.md
<ide> This is an implementation of the Transformer translation model as described in
<ide> the [Attention is All You Need](https://arxiv.org/abs/1706.03762) paper. The
<ide> implementation leverages tf.keras and makes sure it is compatible with TF 2.x.
<ide>
<del>**Warning: this transformer features has been fully intergrated in nlp/modeling.
<add>**Warning: the features in the `transformer/` folder have been fully intergrated
<add>into nlp/modeling.
<ide> Due to its dependencies, we will remove this folder after the model
<ide> garden 2.5 release. The model in `nlp/modeling/models/seq2seq_transformer.py` is
<ide> identical to the model in this folder.** | 1 |
Javascript | Javascript | compute parametricgeometry normals from derivative | 63e96283bc23e6ea7f9544d4f31881b5518c724a | <ide><path>src/geometries/ParametricGeometry.js
<ide> ParametricGeometry.prototype.constructor = ParametricGeometry;
<ide>
<ide> import { BufferGeometry } from '../core/BufferGeometry';
<ide> import { Float32BufferAttribute } from '../core/BufferAttribute';
<add>import { Vector3 } from '../math/Vector3';
<ide>
<ide> function ParametricBufferGeometry( func, slices, stacks ) {
<ide>
<ide> function ParametricBufferGeometry( func, slices, stacks ) {
<ide>
<ide> var indices = [];
<ide> var vertices = [];
<add> var normals = [];
<ide> var uvs = [];
<ide>
<add> var EPS = 0.00001;
<add> var pu = new Vector3(), pv = new Vector3(), normal = new Vector3();
<add>
<ide> var i, j;
<ide>
<del> // generate vertices and uvs
<add> // generate vertices, normals and uvs
<ide>
<ide> var sliceCount = slices + 1;
<ide>
<ide> function ParametricBufferGeometry( func, slices, stacks ) {
<ide> var p = func( u, v );
<ide> vertices.push( p.x, p.y, p.z );
<ide>
<add> // approximate tangent plane vectors via central difference
<add>
<add> pu.subVectors( func( u + EPS, v ), func( u - EPS, v ) );
<add> pv.subVectors( func( u, v + EPS ), func( u, v - EPS ) );
<add>
<add> // cross product of tangent plane vectors returns surface normal
<add>
<add> normal.crossVectors( pu, pv );
<add> normals.push( normal.x, normal.y, normal.z );
<add>
<ide> uvs.push( u, v );
<ide>
<ide> }
<ide> function ParametricBufferGeometry( func, slices, stacks ) {
<ide>
<ide> this.setIndex( indices );
<ide> this.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
<add> this.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
<ide> this.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
<ide>
<del> // generate normals
<del>
<del> this.computeVertexNormals();
<add> this.normalizeNormals();
<ide>
<ide> }
<ide> | 1 |
Javascript | Javascript | update string#objectat documentation | a1f9a1f085ec2e6c7d16aedd992f76882791c5ce | <ide><path>packages/ember-runtime/lib/mixins/array.js
<ide> // License: Licensed under MIT license (see license.js)
<ide> // ==========================================================================
<ide>
<del>
<ide> require('ember-runtime/mixins/enumerable');
<ide>
<del>
<del>
<ide> // ..........................................................
<ide> // HELPERS
<ide> //
<ide> Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
<ide> /**
<ide> @field {Number} length
<ide>
<del> Your array must support the length property. Your replace methods should
<add> Your array must support the length property. Your replace methods should
<ide> set this property whenever it changes.
<ide> */
<ide> length: Ember.required(),
<ide>
<ide> /**
<del> This is one of the primitives you must implement to support Ember.Array.
<del> Returns the object at the named index. If your object supports retrieving
<del> the value of an array item using get() (i.e. myArray.get(0)), then you do
<del> not need to implement this method yourself.
<add> Returns the object at the given index. If the given index is negative or
<add> is greater or equal than the array length, returns `undefined`.
<add>
<add> This is one of the primitives you must implement to support `Ember.Array`.
<add> If your object supports retrieving the value of an array item using `get()`
<add> (i.e. `myArray.get(0)`), then you do not need to implement this method
<add> yourself.
<add>
<add> var arr = ['a', 'b', 'c', 'd'];
<add> arr.objectAt(0); => "a"
<add> arr.objectAt(3); => "d"
<add> arr.objectAt(-1); => undefined
<add> arr.objectAt(4); => undefined
<add> arr.objectAt(5); => undefined
<ide>
<ide> @param {Number} idx
<del> The index of the item to return. If idx exceeds the current length,
<del> return null.
<add> The index of the item to return.
<ide> */
<ide> objectAt: function(idx) {
<ide> if ((idx < 0) || (idx>=get(this, 'length'))) return undefined ;
<ide> Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
<ide>
<ide> // Add any extra methods to Ember.Array that are native to the built-in Array.
<ide> /**
<del> Returns a new array that is a slice of the receiver. This implementation
<add> Returns a new array that is a slice of the receiver. This implementation
<ide> uses the observable array methods to retrieve the objects for the new
<ide> slice.
<ide>
<ide> Ember.Array = Ember.Mixin.create(Ember.Enumerable, /** @scope Ember.Array.protot
<ide> return this.__each;
<ide> }).property().cacheable()
<ide>
<del>
<del>
<ide> }) ;
<del>
<del>
<del> | 1 |
Mixed | Ruby | improve custom configuration | de4891344ccc074f6d5693f4fac6ad610584e336 | <ide><path>guides/source/4_2_release_notes.md
<ide> Please refer to the [Changelog][railties] for detailed changes.
<ide> * Introduced an `after_bundle` callback for use in Rails templates.
<ide> ([Pull Request](https://github.com/rails/rails/pull/16359))
<ide>
<del>* Introduced the `x` namespace for defining custom configuration options:
<add>* Custom configuration options can be chained:
<ide>
<ide> ```ruby
<ide> # config/environments/production.rb
<del> config.x.payment_processing.schedule = :daily
<del> config.x.payment_processing.retries = 3
<del> config.x.super_debugger = true
<add> config.payment_processing.schedule = :daily
<add> config.payment_processing.retries = 3
<add> config.resque = { timeout: 60, inline_jobs: :always }
<add> config.super_debugger = true
<ide> ```
<ide>
<ide> These options are then available through the configuration object:
<ide>
<ide> ```ruby
<del> Rails.configuration.x.payment_processing.schedule # => :daily
<del> Rails.configuration.x.payment_processing.retries # => 3
<del> Rails.configuration.x.super_debugger # => true
<del> Rails.configuration.x.super_debugger.not_set # => nil
<add> Rails.configuration.payment_processing.schedule # => :daily
<add> Rails.configuration.payment_processing.retries # => 3
<add> Rails.configuration.resque.timeout # => 60
<add> Rails.configuration.resque.inline_jobs # => :always
<add> Rails.configuration.super_debugger # => true
<ide> ```
<ide>
<ide> ([Commit](https://github.com/rails/rails/commit/611849772dd66c2e4d005dcfe153f7ce79a8a7db))
<ide><path>guides/source/configuring.md
<ide> Custom configuration
<ide> You can configure your own code through the Rails configuration object with custom configuration. It works like this:
<ide>
<ide> ```ruby
<del> config.x.payment_processing.schedule = :daily
<del> config.x.payment_processing.retries = 3
<del> config.x.super_debugger = true
<add> config.payment_processing.schedule = :daily
<add> config.payment_processing.retries = 3
<add> config.resque = { timeout: 60, inline_jobs: :always }
<add> config.super_debugger = true
<ide> ```
<ide>
<ide> These configuration points are then available through the configuration object:
<ide>
<ide> ```ruby
<del> Rails.configuration.x.payment_processing.schedule # => :daily
<del> Rails.configuration.x.payment_processing.retries # => 3
<del> Rails.configuration.x.super_debugger # => true
<del> Rails.configuration.x.super_debugger.not_set # => nil
<add> Rails.configuration.payment_processing.schedule # => :daily
<add> Rails.configuration.payment_processing.retries # => 3
<add> Rails.configuration.resque.timeout # => 60
<add> Rails.configuration.resque.inline_jobs # => :always
<add> Rails.configuration.super_debugger # => true
<ide> ```
<ide><path>railties/CHANGELOG.md
<ide> configure your own code through the Rails configuration object with custom configuration:
<ide>
<ide> # config/environments/production.rb
<del> config.x.payment_processing.schedule = :daily
<del> config.x.payment_processing.retries = 3
<del> config.x.super_debugger = true
<add> config.payment_processing.schedule = :daily
<add> config.payment_processing.retries = 3
<add> config.resque = { timeout: 60, inline_jobs: :always }
<add> config.super_debugger = true
<ide>
<ide> These configuration points are then available through the configuration object:
<ide>
<del> Rails.configuration.x.payment_processing.schedule # => :daily
<del> Rails.configuration.x.payment_processing.retries # => 3
<del> Rails.configuration.x.super_debugger # => true
<del> Rails.configuration.x.super_debugger.not_set # => nil
<add> Rails.configuration.payment_processing.schedule # => :daily
<add> Rails.configuration.payment_processing.retries # => 3
<add> Rails.configuration.resque.timeout # => 60
<add> Rails.configuration.resque.inline_jobs # => :always
<add> Rails.configuration.super_debugger # => true
<ide>
<ide> *DHH*
<ide>
<ide><path>railties/lib/rails/application/configuration.rb
<ide> class Configuration < ::Rails::Engine::Configuration
<ide> :railties_order, :relative_url_root, :secret_key_base, :secret_token,
<ide> :serve_static_assets, :ssl_options, :static_cache_control, :session_options,
<ide> :time_zone, :reload_classes_only_on_change,
<del> :beginning_of_week, :filter_redirect, :x
<add> :beginning_of_week, :filter_redirect
<ide>
<ide> attr_writer :log_level
<ide> attr_reader :encoding
<ide> def initialize(*)
<ide> @eager_load = nil
<ide> @secret_token = nil
<ide> @secret_key_base = nil
<del> @x = Custom.new
<ide>
<ide> @assets = ActiveSupport::OrderedOptions.new
<ide> @assets.enabled = true
<ide> def session_store(*args)
<ide> def annotations
<ide> SourceAnnotationExtractor::Annotation
<ide> end
<del>
<del> private
<del> class Custom
<del> def initialize
<del> @configurations = Hash.new
<del> end
<del>
<del> def method_missing(method, *args)
<del> @configurations[method] ||= ActiveSupport::OrderedOptions.new
<del> end
<del> end
<ide> end
<ide> end
<ide> end
<ide><path>railties/lib/rails/railtie/configuration.rb
<ide> def respond_to?(name, include_private = false)
<ide>
<ide> def method_missing(name, *args, &blk)
<ide> if name.to_s =~ /=$/
<del> @@options[$`.to_sym] = args.first
<add> key = $`.to_sym
<add> value = args.first
<add>
<add> if value.is_a?(Hash)
<add> @@options[key] = ChainedConfigurationOptions.new value
<add> else
<add> @@options[key] = value
<add> end
<ide> elsif @@options.key?(name)
<ide> @@options[name]
<ide> else
<del> super
<add> @@options[name] = ActiveSupport::OrderedOptions.new
<add> end
<add> end
<add>
<add> class ChainedConfigurationOptions < ActiveSupport::OrderedOptions # :nodoc:
<add> def initialize(value = nil)
<add> if value.is_a?(Hash)
<add> value.each_pair { |k, v| set_value k, v }
<add> else
<add> super
<add> end
<add> end
<add>
<add> def method_missing(meth, *args)
<add> if meth =~ /=$/
<add> key = $`.to_sym
<add> value = args.first
<add>
<add> set_value key, value
<add> else
<add> self.fetch(meth) { super }
<add> end
<add> end
<add>
<add> private
<add>
<add> def set_value(key, value)
<add> if value.is_a?(Hash)
<add> value = self.class.new(value)
<add> end
<add>
<add> self[key] = value
<ide> end
<ide> end
<ide> end
<ide><path>railties/test/application/configuration/base_test.rb
<ide> module ApplicationTests
<ide> module ConfigurationTests
<ide> class BaseTest < ActiveSupport::TestCase
<add> include ActiveSupport::Testing::Isolation
<add>
<ide> def setup
<ide> build_app
<ide> boot_rails
<ide> def app
<ide> end
<ide>
<ide> def require_environment
<del> require "#{app_path}/config/environment"
<add> require "#{app_path}/config/environment"
<ide> end
<ide> end
<ide> end
<del>end
<ide>\ No newline at end of file
<add>end
<ide><path>railties/test/application/configuration/custom_test.rb
<ide> require 'application/configuration/base_test'
<ide>
<ide> class ApplicationTests::ConfigurationTests::CustomTest < ApplicationTests::ConfigurationTests::BaseTest
<del> test 'access custom configuration point' do
<add> test 'configuration top level can be chained' do
<ide> add_to_config <<-RUBY
<del> config.x.resque.inline_jobs = :always
<del> config.x.resque.timeout = 60
<add> config.resque.inline_jobs = :always
<add> config.resque.timeout = 60
<ide> RUBY
<ide> require_environment
<ide>
<del> assert_equal :always, Rails.configuration.x.resque.inline_jobs
<del> assert_equal 60, Rails.configuration.x.resque.timeout
<del> assert_nil Rails.configuration.x.resque.nothing
<add> assert_equal :always, Rails.configuration.resque.inline_jobs
<add> assert_equal 60, Rails.configuration.resque.timeout
<add> assert_nil Rails.configuration.resque.nothing
<add> end
<add>
<add> test 'configuration top level accept normal values' do
<add> add_to_config <<-RUBY
<add> config.timeout = 60
<add> config.something_nil = nil
<add> config.something_false = false
<add> config.something_true = true
<add> RUBY
<add> require_environment
<add>
<add> assert_equal 60, Rails.configuration.timeout
<add> assert_equal nil, Rails.configuration.something_nil
<add> assert_equal false, Rails.configuration.something_false
<add> assert_equal true, Rails.configuration.something_true
<add> end
<add>
<add> test 'configuration top level builds options from hashes' do
<add> add_to_config <<-RUBY
<add> config.resque = { timeout: 60, inline_jobs: :always }
<add> RUBY
<add> require_environment
<add>
<add> assert_equal :always, Rails.configuration.resque.inline_jobs
<add> assert_equal 60, Rails.configuration.resque.timeout
<add> assert_nil Rails.configuration.resque.nothing
<add> end
<add>
<add> test 'configuration top level builds options from hashes with string keys' do
<add> add_to_config <<-RUBY
<add> config.resque = { 'timeout' => 60, 'inline_jobs' => :always }
<add> RUBY
<add> require_environment
<add>
<add> assert_equal :always, Rails.configuration.resque.inline_jobs
<add> assert_equal 60, Rails.configuration.resque.timeout
<add> assert_nil Rails.configuration.resque.nothing
<add> end
<add>
<add> test 'configuration top level builds nested options from hashes with symbol keys' do
<add> add_to_config <<-RUBY
<add> config.resque = { timeout: 60, inline_jobs: :always, url: { host: 'localhost', port: 8080 } }
<add> config.resque.url.protocol = 'https'
<add> config.resque.queues = { production: ['low_priority'] }
<add> RUBY
<add> require_environment
<add>
<add> assert_equal(:always, Rails.configuration.resque.inline_jobs)
<add> assert_equal(60, Rails.configuration.resque.timeout)
<add> assert_equal({ host: 'localhost', port: 8080, protocol: 'https' }, Rails.configuration.resque.url)
<add> assert_equal('localhost', Rails.configuration.resque.url.host)
<add> assert_equal(8080, Rails.configuration.resque.url.port)
<add> assert_equal('https', Rails.configuration.resque.url.protocol)
<add> assert_equal(['low_priority'], Rails.configuration.resque.queues.production)
<add> assert_nil(Rails.configuration.resque.nothing)
<add> end
<add>
<add> test 'configuration top level builds nested options from hashes with string keys' do
<add> add_to_config <<-RUBY
<add> config.resque = { 'timeout' => 60, 'inline_jobs' => :always, 'url' => { 'host' => 'localhost', 'port' => 8080 } }
<add> RUBY
<add> require_environment
<add>
<add> assert_equal(:always, Rails.configuration.resque.inline_jobs)
<add> assert_equal(60, Rails.configuration.resque.timeout)
<add> assert_equal({ host: 'localhost', port: 8080 }, Rails.configuration.resque.url)
<add> assert_equal('localhost', Rails.configuration.resque.url.host)
<add> assert_equal(8080, Rails.configuration.resque.url.port)
<add> assert_nil(Rails.configuration.resque.nothing)
<ide> end
<ide> end
<ide><path>railties/test/railties/engine_test.rb
<ide> def index
<ide>
<ide> Rails.application.load_seed
<ide> assert Rails.application.config.app_seeds_loaded
<del> assert_raise(NoMethodError) { Bukkits::Engine.config.bukkits_seeds_loaded }
<add> assert_empty Bukkits::Engine.config.bukkits_seeds_loaded
<ide>
<ide> Bukkits::Engine.load_seed
<ide> assert Bukkits::Engine.config.bukkits_seeds_loaded | 8 |
Ruby | Ruby | test source.path on tab.create and .for_formula | 4f1d47bc156253ab0eabf6b7aba1fcfa46d80633 | <ide><path>Library/Homebrew/test/test_tab.rb
<ide> def test_from_file
<ide> assert_equal source_path, tab.source["path"]
<ide> end
<ide>
<add> def test_create
<add> f = formula { url "foo-1.0" }
<add> compiler = DevelopmentTools.default_compiler
<add> stdlib = :libcxx
<add> tab = Tab.create(f, compiler, stdlib)
<add>
<add> assert_equal f.path.to_s, tab.source["path"]
<add> end
<add>
<add> def test_create_from_alias
<add> alias_path = CoreTap.instance.alias_dir/"bar"
<add> f = formula(:alias_path => alias_path) { url "foo-1.0" }
<add> compiler = DevelopmentTools.default_compiler
<add> stdlib = :libcxx
<add> tab = Tab.create(f, compiler, stdlib)
<add>
<add> assert_equal f.alias_path.to_s, tab.source["path"]
<add> end
<add>
<add> def test_for_formula
<add> f = formula { url "foo-1.0" }
<add> tab = Tab.for_formula(f)
<add>
<add> assert_equal f.path.to_s, tab.source["path"]
<add> end
<add>
<add> def test_for_formula_from_alias
<add> alias_path = CoreTap.instance.alias_dir/"bar"
<add> f = formula(:alias_path => alias_path) { url "foo-1.0" }
<add> tab = Tab.for_formula(f)
<add>
<add> assert_equal alias_path.to_s, tab.source["path"]
<add> end
<add>
<ide> def test_to_json
<ide> tab = Tab.new(Utils::JSON.load(@tab.to_json))
<ide> assert_equal @tab.used_options.sort, tab.used_options.sort
<ide><path>Library/Homebrew/test/testing_env.rb
<ide> class TestCase < ::Minitest::Test
<ide> TEST_SHA1 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
<ide> TEST_SHA256 = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef".freeze
<ide>
<del> def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, &block)
<del> @_f = Class.new(Formula, &block).new(name, path, spec)
<add> def formula(name = "formula_name", path = Formulary.core_path(name), spec = :stable, alias_path: nil, &block)
<add> @_f = Class.new(Formula, &block).new(name, path, spec, :alias_path => alias_path)
<ide> end
<ide>
<ide> def mktmpdir(prefix_suffix = nil, &block) | 2 |
Python | Python | make core ut no longer dependent on mysql | 849b408c5fb3641809f031c6e58626c8ea596be6 | <ide><path>airflow/utils.py
<ide> def merge_conn(conn, session=None):
<ide>
<ide> def initdb():
<ide> session = settings.Session()
<add>
<ide> from airflow import models
<ide> upgradedb()
<ide>
<ide><path>tests/core.py
<ide> import os
<ide> from time import sleep
<ide> import unittest
<add>
<ide> from airflow import configuration
<ide> configuration.test_mode()
<ide> from airflow import jobs, models, DAG, utils, operators, hooks, macros
<add>from airflow.hooks import BaseHook
<ide> from airflow.bin import cli
<ide> from airflow.www import app as application
<ide> from airflow.settings import Session
<ide> def test_time_sensor(self):
<ide> t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, force=True)
<ide>
<ide> def test_check_operators(self):
<add>
<add> conn_id = "sqlite_default"
<add>
<add> captainHook = BaseHook.get_hook(conn_id=conn_id)
<add> captainHook.run("CREATE TABLE operator_test_table (a, b)")
<add> captainHook.run("insert into operator_test_table values (1,2)")
<add>
<ide> t = operators.CheckOperator(
<ide> task_id='check',
<del> sql="SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES",
<del> conn_id="mysql_default",
<add> sql="select count(*) from operator_test_table" ,
<add> conn_id=conn_id,
<ide> dag=self.dag)
<ide> t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, force=True)
<ide>
<ide> t = operators.ValueCheckOperator(
<ide> task_id='value_check',
<ide> pass_value=95,
<ide> tolerance=0.1,
<del> conn_id="mysql_default",
<add> conn_id=conn_id,
<ide> sql="SELECT 100",
<ide> dag=self.dag)
<ide> t.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE, force=True)
<ide>
<add> captainHook.run("drop table operator_test_table")
<add>
<add>
<ide> def test_clear_api(self):
<ide> task = self.dag_bash.tasks[0]
<ide> task.clear( | 2 |
Ruby | Ruby | fix version scheme not being set in the tab | 627381e949233ec90e4ea4ffc9d0e811f68619b9 | <ide><path>Library/Homebrew/formula_installer.rb
<ide> def pour
<ide> tab.aliases = formula.aliases
<ide> tab.arch = Hardware::CPU.arch
<ide> tab.source["versions"]["stable"] = formula.stable.version.to_s
<add> tab.source["versions"]["version_scheme"] = formula.version_scheme
<ide> tab.source["path"] = formula.specified_path.to_s
<ide> tab.source["tap_git_head"] = formula.tap&.git_head
<ide> tab.tap = formula.tap | 1 |
PHP | PHP | fix mistakes in docblock | 2a0d07c0f56495701247074df8c149b34a8118dd | <ide><path>src/Controller/Component/SecurityComponent.php
<ide> * - Requiring that SSL be used.
<ide> * - Limiting cross controller communication.
<ide> *
<del> * @link http://book.cakephp.org/3.0/en/controllers/components/security-component.html
<add> * @link http://book.cakephp.org/3.0/en/controllers/components/security.html
<ide> */
<ide> class SecurityComponent extends Component {
<ide>
<ide> public function requireAuth($actions) {
<ide> * @param string $error Error method
<ide> * @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
<ide> * @see SecurityComponent::$blackHoleCallback
<del> * @link http://book.cakephp.org/3.0/en/controllers/components/security-component.html#handling-blackhole-callbacks
<add> * @link http://book.cakephp.org/3.0/en/controllers/components/security.html#handling-blackhole-callbacks
<ide> * @throws \Cake\Network\Exception\BadRequestException
<ide> */
<ide> public function blackHole(Controller $controller, $error = '') { | 1 |
Go | Go | increase max image depth to 127 | 6d34c50e898507e461300ecf91ed661011bc15ab | <ide><path>graphdriver/aufs/aufs.go
<ide> import (
<ide> "github.com/dotcloud/docker/archive"
<ide> "github.com/dotcloud/docker/graphdriver"
<ide> "github.com/dotcloud/docker/utils"
<del> "log"
<ide> "os"
<ide> "os/exec"
<ide> "path"
<ide> "strings"
<add> "syscall"
<ide> )
<ide>
<ide> func init() {
<ide> func (a *Driver) Cleanup() error {
<ide> return nil
<ide> }
<ide>
<del>func (a *Driver) aufsMount(ro []string, rw, target string) error {
<del> rwBranch := fmt.Sprintf("%v=rw", rw)
<del> roBranches := ""
<del> for _, layer := range ro {
<del> roBranches += fmt.Sprintf("%v=ro+wh:", layer)
<del> }
<del> branches := fmt.Sprintf("br:%v:%v,xino=/dev/shm/aufs.xino", rwBranch, roBranches)
<add>func (a *Driver) aufsMount(ro []string, rw, target string) (err error) {
<add> defer func() {
<add> if err != nil {
<add> Unmount(target)
<add> }
<add> }()
<ide>
<del> //if error, try to load aufs kernel module
<del> if err := mount("none", target, "aufs", 0, branches); err != nil {
<del> log.Printf("Kernel does not support AUFS, trying to load the AUFS module with modprobe...")
<del> if err := exec.Command("modprobe", "aufs").Run(); err != nil {
<del> return fmt.Errorf("Unable to load the AUFS module")
<add> if err = a.tryMount(ro, rw, target); err != nil {
<add> if err = a.mountRw(rw, target); err != nil {
<add> return
<ide> }
<del> log.Printf("...module loaded.")
<del> if err := mount("none", target, "aufs", 0, branches); err != nil {
<del> return fmt.Errorf("Unable to mount using aufs %s", err)
<add>
<add> for _, layer := range ro {
<add> branch := fmt.Sprintf("append:%s=ro+wh", layer)
<add> if err = mount("none", target, "aufs", syscall.MS_REMOUNT, branch); err != nil {
<add> return
<add> }
<ide> }
<ide> }
<del> return nil
<add> return
<add>}
<add>
<add>// Try to mount using the aufs fast path, if this fails then
<add>// append ro layers.
<add>func (a *Driver) tryMount(ro []string, rw, target string) (err error) {
<add> var (
<add> rwBranch = fmt.Sprintf("%s=rw", rw)
<add> roBranches = fmt.Sprintf("%s=ro+wh:", strings.Join(ro, "=ro+wh:"))
<add> )
<add> return mount("none", target, "aufs", 0, fmt.Sprintf("br:%v:%v,xino=/dev/shm/aufs.xino", rwBranch, roBranches))
<add>}
<add>
<add>func (a *Driver) mountRw(rw, target string) error {
<add> return mount("none", target, "aufs", 0, fmt.Sprintf("br:%s,xino=/dev/shm/aufs.xino", rw))
<add>}
<add>
<add>func rollbackMount(target string, err error) {
<add> if err != nil {
<add> Unmount(target)
<add> }
<ide> }
<ide><path>graphdriver/aufs/aufs_test.go
<ide> package aufs
<ide>
<ide> import (
<add> "crypto/sha256"
<add> "encoding/hex"
<add> "fmt"
<ide> "github.com/dotcloud/docker/archive"
<add> "io/ioutil"
<ide> "os"
<ide> "path"
<ide> "testing"
<ide> func TestApplyDiff(t *testing.T) {
<ide> t.Fatal(err)
<ide> }
<ide> }
<add>
<add>func hash(c string) string {
<add> h := sha256.New()
<add> fmt.Fprint(h, c)
<add> return hex.EncodeToString(h.Sum(nil))
<add>}
<add>
<add>func TestMountMoreThan42Layers(t *testing.T) {
<add> d := newDriver(t)
<add> defer os.RemoveAll(tmp)
<add> defer d.Cleanup()
<add> var last string
<add> var expected int
<add>
<add> for i := 1; i < 127; i++ {
<add> expected++
<add> var (
<add> parent = fmt.Sprintf("%d", i-1)
<add> current = fmt.Sprintf("%d", i)
<add> )
<add>
<add> if parent == "0" {
<add> parent = ""
<add> } else {
<add> parent = hash(parent)
<add> }
<add> current = hash(current)
<add>
<add> if err := d.Create(current, parent); err != nil {
<add> t.Logf("Current layer %d", i)
<add> t.Fatal(err)
<add> }
<add> point, err := d.Get(current)
<add> if err != nil {
<add> t.Logf("Current layer %d", i)
<add> t.Fatal(err)
<add> }
<add> f, err := os.Create(path.Join(point, current))
<add> if err != nil {
<add> t.Logf("Current layer %d", i)
<add> t.Fatal(err)
<add> }
<add> f.Close()
<add>
<add> if i%10 == 0 {
<add> if err := os.Remove(path.Join(point, parent)); err != nil {
<add> t.Logf("Current layer %d", i)
<add> t.Fatal(err)
<add> }
<add> expected--
<add> }
<add> last = current
<add> }
<add>
<add> // Perform the actual mount for the top most image
<add> point, err := d.Get(last)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> files, err := ioutil.ReadDir(point)
<add> if err != nil {
<add> t.Fatal(err)
<add> }
<add> if len(files) != expected {
<add> t.Fatalf("Expected %d got %d", expected, len(files))
<add> }
<add>}
<ide><path>graphdriver/aufs/mount_linux.go
<ide> package aufs
<ide>
<ide> import "syscall"
<ide>
<del>func mount(source string, target string, fstype string, flags uintptr, data string) (err error) {
<add>func mount(source string, target string, fstype string, flags uintptr, data string) error {
<ide> return syscall.Mount(source, target, fstype, flags, data)
<ide> }
<ide><path>runtime.go
<ide> import (
<ide> "time"
<ide> )
<ide>
<del>// Set the max depth to the aufs restriction
<del>const MaxImageDepth = 42
<add>// Set the max depth to the aufs default that most
<add>// kernels are compiled with
<add>// For more information see: http://sourceforge.net/p/aufs/aufs3-standalone/ci/aufs3.12/tree/config.mk
<add>const MaxImageDepth = 127
<ide>
<ide> var defaultDns = []string{"8.8.8.8", "8.8.4.4"}
<ide> | 4 |
PHP | PHP | apply fixes from styleci | ff907d5f7bfc8d76811eb587158f837604750572 | <ide><path>tests/Mail/MailMailableAssertionsTest.php
<ide> namespace Illuminate\Tests\Mail;
<ide>
<ide> use Illuminate\Mail\Mailable;
<del>use PHPUnit\Framework\TestCase;
<ide> use PHPUnit\Framework\AssertionFailedError;
<add>use PHPUnit\Framework\TestCase;
<ide>
<ide> class MailMailableAssertionsTest extends TestCase
<ide> {
<ide> class MailableAssertionsStub extends Mailable
<ide> {
<ide> protected function renderForAssertions()
<ide> {
<del> $text = <<<EOD
<add> $text = <<<'EOD'
<ide> # List
<ide> - First Item
<ide> - Second Item
<ide> - Third Item
<ide> EOD;
<ide>
<del> $html = <<<EOD
<add> $html = <<<'EOD'
<ide> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ide> <html xmlns="http://www.w3.org/1999/xhtml">
<ide> <head> | 1 |
Javascript | Javascript | reuse hooks when replaying a suspended component | 33e3d2878e9ec82c65468316ffcc473e5288bb87 | <ide><path>packages/react-reconciler/src/ReactFiberBeginWork.new.js
<ide> import type {
<ide> import type {UpdateQueue} from './ReactFiberClassUpdateQueue.new';
<ide> import type {RootState} from './ReactFiberRoot.new';
<ide> import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.new';
<add>import type {ThenableState} from './ReactFiberThenable.new';
<add>
<ide> import checkPropTypes from 'shared/checkPropTypes';
<ide> import {
<ide> markComponentRenderStarted,
<ide> import {
<ide> renderWithHooks,
<ide> checkDidRenderIdHook,
<ide> bailoutHooks,
<add> replaySuspendedComponentWithHooks,
<ide> } from './ReactFiberHooks.new';
<ide> import {stopProfilerTimerIfRunning} from './ReactProfilerTimer.new';
<ide> import {
<ide> function updateFunctionComponent(
<ide> return workInProgress.child;
<ide> }
<ide>
<add>export function replayFunctionComponent(
<add> current: Fiber | null,
<add> workInProgress: Fiber,
<add> nextProps: any,
<add> Component: any,
<add> prevThenableState: ThenableState,
<add> renderLanes: Lanes,
<add>): Fiber | null {
<add> // This function is used to replay a component that previously suspended,
<add> // after its data resolves. It's a simplified version of
<add> // updateFunctionComponent that reuses the hooks from the previous attempt.
<add>
<add> let context;
<add> if (!disableLegacyContext) {
<add> const unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
<add> context = getMaskedContext(workInProgress, unmaskedContext);
<add> }
<add>
<add> prepareToReadContext(workInProgress, renderLanes);
<add> if (enableSchedulingProfiler) {
<add> markComponentRenderStarted(workInProgress);
<add> }
<add> const nextChildren = replaySuspendedComponentWithHooks(
<add> current,
<add> workInProgress,
<add> Component,
<add> nextProps,
<add> context,
<add> prevThenableState,
<add> );
<add> const hasId = checkDidRenderIdHook();
<add> if (enableSchedulingProfiler) {
<add> markComponentRenderStopped();
<add> }
<add>
<add> if (current !== null && !didReceiveUpdate) {
<add> bailoutHooks(current, workInProgress, renderLanes);
<add> return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
<add> }
<add>
<add> if (getIsHydrating() && hasId) {
<add> pushMaterializedTreeId(workInProgress);
<add> }
<add>
<add> // React DevTools reads this flag.
<add> workInProgress.flags |= PerformedWork;
<add> reconcileChildren(current, workInProgress, nextChildren, renderLanes);
<add> return workInProgress.child;
<add>}
<add>
<ide> function updateClassComponent(
<ide> current: Fiber | null,
<ide> workInProgress: Fiber,
<ide><path>packages/react-reconciler/src/ReactFiberBeginWork.old.js
<ide> import type {
<ide> import type {UpdateQueue} from './ReactFiberClassUpdateQueue.old';
<ide> import type {RootState} from './ReactFiberRoot.old';
<ide> import type {TracingMarkerInstance} from './ReactFiberTracingMarkerComponent.old';
<add>import type {ThenableState} from './ReactFiberThenable.old';
<add>
<ide> import checkPropTypes from 'shared/checkPropTypes';
<ide> import {
<ide> markComponentRenderStarted,
<ide> import {
<ide> renderWithHooks,
<ide> checkDidRenderIdHook,
<ide> bailoutHooks,
<add> replaySuspendedComponentWithHooks,
<ide> } from './ReactFiberHooks.old';
<ide> import {stopProfilerTimerIfRunning} from './ReactProfilerTimer.old';
<ide> import {
<ide> function updateFunctionComponent(
<ide> return workInProgress.child;
<ide> }
<ide>
<add>export function replayFunctionComponent(
<add> current: Fiber | null,
<add> workInProgress: Fiber,
<add> nextProps: any,
<add> Component: any,
<add> prevThenableState: ThenableState,
<add> renderLanes: Lanes,
<add>): Fiber | null {
<add> // This function is used to replay a component that previously suspended,
<add> // after its data resolves. It's a simplified version of
<add> // updateFunctionComponent that reuses the hooks from the previous attempt.
<add>
<add> let context;
<add> if (!disableLegacyContext) {
<add> const unmaskedContext = getUnmaskedContext(workInProgress, Component, true);
<add> context = getMaskedContext(workInProgress, unmaskedContext);
<add> }
<add>
<add> prepareToReadContext(workInProgress, renderLanes);
<add> if (enableSchedulingProfiler) {
<add> markComponentRenderStarted(workInProgress);
<add> }
<add> const nextChildren = replaySuspendedComponentWithHooks(
<add> current,
<add> workInProgress,
<add> Component,
<add> nextProps,
<add> context,
<add> prevThenableState,
<add> );
<add> const hasId = checkDidRenderIdHook();
<add> if (enableSchedulingProfiler) {
<add> markComponentRenderStopped();
<add> }
<add>
<add> if (current !== null && !didReceiveUpdate) {
<add> bailoutHooks(current, workInProgress, renderLanes);
<add> return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes);
<add> }
<add>
<add> if (getIsHydrating() && hasId) {
<add> pushMaterializedTreeId(workInProgress);
<add> }
<add>
<add> // React DevTools reads this flag.
<add> workInProgress.flags |= PerformedWork;
<add> reconcileChildren(current, workInProgress, nextChildren, renderLanes);
<add> return workInProgress.child;
<add>}
<add>
<ide> function updateClassComponent(
<ide> current: Fiber | null,
<ide> workInProgress: Fiber,
<ide><path>packages/react-reconciler/src/ReactFiberHooks.new.js
<ide> export function renderWithHooks<Props, SecondArg>(
<ide> }
<ide> }
<ide>
<add> finishRenderingHooks(current, workInProgress);
<add>
<add> return children;
<add>}
<add>
<add>function finishRenderingHooks(current: Fiber | null, workInProgress: Fiber) {
<ide> // We can assume the previous dispatcher is always this one, since we set it
<ide> // at the beginning of the render phase and there's no re-entrance.
<ide> ReactCurrentDispatcher.current = ContextOnlyDispatcher;
<ide> export function renderWithHooks<Props, SecondArg>(
<ide> }
<ide> }
<ide> }
<add>}
<ide>
<add>export function replaySuspendedComponentWithHooks<Props, SecondArg>(
<add> current: Fiber | null,
<add> workInProgress: Fiber,
<add> Component: (p: Props, arg: SecondArg) => any,
<add> props: Props,
<add> secondArg: SecondArg,
<add> prevThenableState: ThenableState | null,
<add>): any {
<add> // This function is used to replay a component that previously suspended,
<add> // after its data resolves.
<add> //
<add> // It's a simplified version of renderWithHooks, but it doesn't need to do
<add> // most of the set up work because they weren't reset when we suspended; they
<add> // only get reset when the component either completes (finishRenderingHooks)
<add> // or unwinds (resetHooksOnUnwind).
<add> if (__DEV__) {
<add> hookTypesDev =
<add> current !== null
<add> ? ((current._debugHookTypes: any): Array<HookType>)
<add> : null;
<add> hookTypesUpdateIndexDev = -1;
<add> // Used for hot reloading:
<add> ignorePreviousDependencies =
<add> current !== null && current.type !== workInProgress.type;
<add> }
<add> const children = renderWithHooksAgain(
<add> workInProgress,
<add> Component,
<add> props,
<add> secondArg,
<add> prevThenableState,
<add> );
<add> finishRenderingHooks(current, workInProgress);
<ide> return children;
<ide> }
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberHooks.old.js
<ide> export function renderWithHooks<Props, SecondArg>(
<ide> }
<ide> }
<ide>
<add> finishRenderingHooks(current, workInProgress);
<add>
<add> return children;
<add>}
<add>
<add>function finishRenderingHooks(current: Fiber | null, workInProgress: Fiber) {
<ide> // We can assume the previous dispatcher is always this one, since we set it
<ide> // at the beginning of the render phase and there's no re-entrance.
<ide> ReactCurrentDispatcher.current = ContextOnlyDispatcher;
<ide> export function renderWithHooks<Props, SecondArg>(
<ide> }
<ide> }
<ide> }
<add>}
<ide>
<add>export function replaySuspendedComponentWithHooks<Props, SecondArg>(
<add> current: Fiber | null,
<add> workInProgress: Fiber,
<add> Component: (p: Props, arg: SecondArg) => any,
<add> props: Props,
<add> secondArg: SecondArg,
<add> prevThenableState: ThenableState | null,
<add>): any {
<add> // This function is used to replay a component that previously suspended,
<add> // after its data resolves.
<add> //
<add> // It's a simplified version of renderWithHooks, but it doesn't need to do
<add> // most of the set up work because they weren't reset when we suspended; they
<add> // only get reset when the component either completes (finishRenderingHooks)
<add> // or unwinds (resetHooksOnUnwind).
<add> if (__DEV__) {
<add> hookTypesDev =
<add> current !== null
<add> ? ((current._debugHookTypes: any): Array<HookType>)
<add> : null;
<add> hookTypesUpdateIndexDev = -1;
<add> // Used for hot reloading:
<add> ignorePreviousDependencies =
<add> current !== null && current.type !== workInProgress.type;
<add> }
<add> const children = renderWithHooksAgain(
<add> workInProgress,
<add> Component,
<add> props,
<add> secondArg,
<add> prevThenableState,
<add> );
<add> finishRenderingHooks(current, workInProgress);
<ide> return children;
<ide> }
<ide>
<ide><path>packages/react-reconciler/src/ReactFiberWorkLoop.new.js
<ide> import {requestCurrentTransition, NoTransition} from './ReactFiberTransition';
<ide> import {
<ide> SelectiveHydrationException,
<ide> beginWork as originalBeginWork,
<add> replayFunctionComponent,
<ide> } from './ReactFiberBeginWork.new';
<ide> import {completeWork} from './ReactFiberCompleteWork.new';
<ide> import {unwindWork, unwindInterruptedWork} from './ReactFiberUnwindWork.new';
<ide> import {
<ide> getSuspenseHandler,
<ide> isBadSuspenseFallback,
<ide> } from './ReactFiberSuspenseContext.new';
<add>import {resolveDefaultProps} from './ReactFiberLazyComponent.new';
<ide>
<ide> const ceil = Math.ceil;
<ide>
<ide> function replaySuspendedUnitOfWork(
<ide> // This is a fork of performUnitOfWork specifcally for replaying a fiber that
<ide> // just suspended.
<ide> //
<del> // Instead of unwinding the stack and potentially showing a fallback, unwind
<del> // only the last stack frame, reset the fiber, and try rendering it again.
<ide> const current = unitOfWork.alternate;
<del> resetSuspendedWorkLoopOnUnwind();
<del> unwindInterruptedWork(current, unitOfWork, workInProgressRootRenderLanes);
<del> unitOfWork = workInProgress = resetWorkInProgress(unitOfWork, renderLanes);
<del>
<ide> setCurrentDebugFiberInDEV(unitOfWork);
<ide>
<ide> let next;
<del> if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
<add> setCurrentDebugFiberInDEV(unitOfWork);
<add> const isProfilingMode =
<add> enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode;
<add> if (isProfilingMode) {
<ide> startProfilerTimer(unitOfWork);
<del> next = beginWork(current, unitOfWork, renderLanes);
<add> }
<add> switch (unitOfWork.tag) {
<add> case IndeterminateComponent: {
<add> // Because it suspended with `use`, we can assume it's a
<add> // function component.
<add> unitOfWork.tag = FunctionComponent;
<add> // Fallthrough to the next branch.
<add> }
<add> // eslint-disable-next-line no-fallthrough
<add> case FunctionComponent:
<add> case ForwardRef: {
<add> // Resolve `defaultProps`. This logic is copied from `beginWork`.
<add> // TODO: Consider moving this switch statement into that module. Also,
<add> // could maybe use this as an opportunity to say `use` doesn't work with
<add> // `defaultProps` :)
<add> const Component = unitOfWork.type;
<add> const unresolvedProps = unitOfWork.pendingProps;
<add> const resolvedProps =
<add> unitOfWork.elementType === Component
<add> ? unresolvedProps
<add> : resolveDefaultProps(Component, unresolvedProps);
<add> next = replayFunctionComponent(
<add> current,
<add> unitOfWork,
<add> resolvedProps,
<add> Component,
<add> thenableState,
<add> workInProgressRootRenderLanes,
<add> );
<add> break;
<add> }
<add> case SimpleMemoComponent: {
<add> const Component = unitOfWork.type;
<add> const nextProps = unitOfWork.pendingProps;
<add> next = replayFunctionComponent(
<add> current,
<add> unitOfWork,
<add> nextProps,
<add> Component,
<add> thenableState,
<add> workInProgressRootRenderLanes,
<add> );
<add> break;
<add> }
<add> default: {
<add> if (__DEV__) {
<add> console.error(
<add> 'Unexpected type of work: %s, Currently only function ' +
<add> 'components are replayed after suspending. This is a bug in React.',
<add> unitOfWork.tag,
<add> );
<add> }
<add> resetSuspendedWorkLoopOnUnwind();
<add> unwindInterruptedWork(current, unitOfWork, workInProgressRootRenderLanes);
<add> unitOfWork = workInProgress = resetWorkInProgress(
<add> unitOfWork,
<add> renderLanes,
<add> );
<add> next = beginWork(current, unitOfWork, renderLanes);
<add> break;
<add> }
<add> }
<add> if (isProfilingMode) {
<ide> stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
<del> } else {
<del> next = beginWork(current, unitOfWork, renderLanes);
<ide> }
<ide>
<ide> // The begin phase finished successfully without suspending. Reset the state
<ide><path>packages/react-reconciler/src/ReactFiberWorkLoop.old.js
<ide> import {requestCurrentTransition, NoTransition} from './ReactFiberTransition';
<ide> import {
<ide> SelectiveHydrationException,
<ide> beginWork as originalBeginWork,
<add> replayFunctionComponent,
<ide> } from './ReactFiberBeginWork.old';
<ide> import {completeWork} from './ReactFiberCompleteWork.old';
<ide> import {unwindWork, unwindInterruptedWork} from './ReactFiberUnwindWork.old';
<ide> import {
<ide> getSuspenseHandler,
<ide> isBadSuspenseFallback,
<ide> } from './ReactFiberSuspenseContext.old';
<add>import {resolveDefaultProps} from './ReactFiberLazyComponent.old';
<ide>
<ide> const ceil = Math.ceil;
<ide>
<ide> function replaySuspendedUnitOfWork(
<ide> // This is a fork of performUnitOfWork specifcally for replaying a fiber that
<ide> // just suspended.
<ide> //
<del> // Instead of unwinding the stack and potentially showing a fallback, unwind
<del> // only the last stack frame, reset the fiber, and try rendering it again.
<ide> const current = unitOfWork.alternate;
<del> resetSuspendedWorkLoopOnUnwind();
<del> unwindInterruptedWork(current, unitOfWork, workInProgressRootRenderLanes);
<del> unitOfWork = workInProgress = resetWorkInProgress(unitOfWork, renderLanes);
<del>
<ide> setCurrentDebugFiberInDEV(unitOfWork);
<ide>
<ide> let next;
<del> if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode) {
<add> setCurrentDebugFiberInDEV(unitOfWork);
<add> const isProfilingMode =
<add> enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoMode;
<add> if (isProfilingMode) {
<ide> startProfilerTimer(unitOfWork);
<del> next = beginWork(current, unitOfWork, renderLanes);
<add> }
<add> switch (unitOfWork.tag) {
<add> case IndeterminateComponent: {
<add> // Because it suspended with `use`, we can assume it's a
<add> // function component.
<add> unitOfWork.tag = FunctionComponent;
<add> // Fallthrough to the next branch.
<add> }
<add> // eslint-disable-next-line no-fallthrough
<add> case FunctionComponent:
<add> case ForwardRef: {
<add> // Resolve `defaultProps`. This logic is copied from `beginWork`.
<add> // TODO: Consider moving this switch statement into that module. Also,
<add> // could maybe use this as an opportunity to say `use` doesn't work with
<add> // `defaultProps` :)
<add> const Component = unitOfWork.type;
<add> const unresolvedProps = unitOfWork.pendingProps;
<add> const resolvedProps =
<add> unitOfWork.elementType === Component
<add> ? unresolvedProps
<add> : resolveDefaultProps(Component, unresolvedProps);
<add> next = replayFunctionComponent(
<add> current,
<add> unitOfWork,
<add> resolvedProps,
<add> Component,
<add> thenableState,
<add> workInProgressRootRenderLanes,
<add> );
<add> break;
<add> }
<add> case SimpleMemoComponent: {
<add> const Component = unitOfWork.type;
<add> const nextProps = unitOfWork.pendingProps;
<add> next = replayFunctionComponent(
<add> current,
<add> unitOfWork,
<add> nextProps,
<add> Component,
<add> thenableState,
<add> workInProgressRootRenderLanes,
<add> );
<add> break;
<add> }
<add> default: {
<add> if (__DEV__) {
<add> console.error(
<add> 'Unexpected type of work: %s, Currently only function ' +
<add> 'components are replayed after suspending. This is a bug in React.',
<add> unitOfWork.tag,
<add> );
<add> }
<add> resetSuspendedWorkLoopOnUnwind();
<add> unwindInterruptedWork(current, unitOfWork, workInProgressRootRenderLanes);
<add> unitOfWork = workInProgress = resetWorkInProgress(
<add> unitOfWork,
<add> renderLanes,
<add> );
<add> next = beginWork(current, unitOfWork, renderLanes);
<add> break;
<add> }
<add> }
<add> if (isProfilingMode) {
<ide> stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
<del> } else {
<del> next = beginWork(current, unitOfWork, renderLanes);
<ide> }
<ide>
<ide> // The begin phase finished successfully without suspending. Reset the state
<ide><path>packages/react-reconciler/src/__tests__/ReactThenable-test.js
<ide> let Scheduler;
<ide> let act;
<ide> let use;
<ide> let useState;
<add>let useMemo;
<ide> let Suspense;
<ide> let startTransition;
<ide> let pendingTextRequests;
<ide> describe('ReactThenable', () => {
<ide> act = require('jest-react').act;
<ide> use = React.use;
<ide> useState = React.useState;
<add> useMemo = React.useMemo;
<ide> Suspense = React.Suspense;
<ide> startTransition = React.startTransition;
<ide>
<ide> describe('ReactThenable', () => {
<ide> ]);
<ide> expect(root).toMatchRenderedOutput('(empty)');
<ide> });
<add>
<add> test('when replaying a suspended component, reuses the hooks computed during the previous attempt', async () => {
<add> function ExcitingText({text}) {
<add> // This computes the uppercased version of some text. Pretend it's an
<add> // expensive operation that we want to reuse.
<add> const uppercaseText = useMemo(() => {
<add> Scheduler.unstable_yieldValue('Compute uppercase: ' + text);
<add> return text.toUpperCase();
<add> }, [text]);
<add>
<add> // This adds an exclamation point to the text. Pretend it's an async
<add> // operation that is sent to a service for processing.
<add> const exclamatoryText = use(getAsyncText(uppercaseText + '!'));
<add>
<add> // This surrounds the text with sparkle emojis. The purpose in this test
<add> // is to show that you can suspend in the middle of a sequence of hooks
<add> // without breaking anything.
<add> const sparklingText = useMemo(() => {
<add> Scheduler.unstable_yieldValue('Add sparkles: ' + exclamatoryText);
<add> return `✨ ${exclamatoryText} ✨`;
<add> }, [exclamatoryText]);
<add>
<add> return <Text text={sparklingText} />;
<add> }
<add>
<add> const root = ReactNoop.createRoot();
<add> await act(async () => {
<add> startTransition(() => {
<add> root.render(<ExcitingText text="Hello" />);
<add> });
<add> });
<add> // Suspends while we wait for the async service to respond.
<add> expect(Scheduler).toHaveYielded([
<add> 'Compute uppercase: Hello',
<add> 'Async text requested [HELLO!]',
<add> ]);
<add> expect(root).toMatchRenderedOutput(null);
<add>
<add> // The data is received.
<add> await act(async () => {
<add> resolveTextRequests('HELLO!');
<add> });
<add> expect(Scheduler).toHaveYielded([
<add> // We shouldn't run the uppercase computation again, because we can reuse
<add> // the computation from the previous attempt.
<add> // 'Compute uppercase: Hello',
<add>
<add> 'Async text requested [HELLO!]',
<add> 'Add sparkles: HELLO!',
<add> '✨ HELLO! ✨',
<add> ]);
<add> });
<add>
<add> // @gate enableUseHook
<add> test(
<add> 'wrap an async function with useMemo to skip running the function ' +
<add> 'twice when loading new data',
<add> async () => {
<add> function App({text}) {
<add> const promiseForText = useMemo(async () => getAsyncText(text), [text]);
<add> const asyncText = use(promiseForText);
<add> return <Text text={asyncText} />;
<add> }
<add>
<add> const root = ReactNoop.createRoot();
<add> await act(async () => {
<add> startTransition(() => {
<add> root.render(<App text="Hello" />);
<add> });
<add> });
<add> expect(Scheduler).toHaveYielded(['Async text requested [Hello]']);
<add> expect(root).toMatchRenderedOutput(null);
<add>
<add> await act(async () => {
<add> resolveTextRequests('Hello');
<add> });
<add> expect(Scheduler).toHaveYielded([
<add> // We shouldn't request async text again, because the async function
<add> // was memoized
<add> // 'Async text requested [Hello]'
<add>
<add> 'Hello',
<add> ]);
<add> },
<add> );
<ide> }); | 7 |
Javascript | Javascript | add missing tests for ngmin/ngmax for date inputs | 976da56d506bb70c6168f3de759aaa00a880c8c9 | <ide><path>test/ng/directive/inputSpec.js
<ide> describe('input', function() {
<ide>
<ide> expect(inputElm).toBeValid();
<ide> });
<add>
<add> it('should validate even if ng-max value changes on-the-fly', function() {
<add> scope.max = '2013-01-01T01:02:00';
<add> compileInput('<input type="datetime-local" ng-model="value" name="alias" ng-max="max" />');
<add>
<add> changeInputValueTo('2014-01-01T12:34:00');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.max = '2001-01-01T01:02:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.max = '2024-01-01T01:02:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<add>
<add> it('should validate even if ng-min value changes on-the-fly', function() {
<add> scope.min = '2013-01-01T01:02:00';
<add> compileInput('<input type="datetime-local" ng-model="value" name="alias" ng-min="min" />');
<add>
<add> changeInputValueTo('2010-01-01T12:34:00');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.min = '2014-01-01T01:02:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.min = '2009-01-01T01:02:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<ide> });
<ide>
<ide> describe('time', function () {
<ide> describe('input', function() {
<ide>
<ide> expect(inputElm).toBeValid();
<ide> });
<add>
<add> it('should validate even if ng-max value changes on-the-fly', function() {
<add> scope.max = '4:02:00';
<add> compileInput('<input type="time" ng-model="value" name="alias" ng-max="max" />');
<add>
<add> changeInputValueTo('05:34:00');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.max = '06:34:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<add>
<add> it('should validate even if ng-min value changes on-the-fly', function() {
<add> scope.min = '08:45:00';
<add> compileInput('<input type="time" ng-model="value" name="alias" ng-min="min" />');
<add>
<add> changeInputValueTo('06:15:00');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.min = '05:50:00';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<ide> });
<ide>
<ide> describe('date', function () {
<ide> describe('input', function() {
<ide>
<ide> expect(inputElm).toBeValid();
<ide> });
<add>
<add> it('should validate even if ng-max value changes on-the-fly', function() {
<add> scope.max = '2013-01-01';
<add> compileInput('<input type="date" ng-model="value" name="alias" ng-max="max" />');
<add>
<add> changeInputValueTo('2014-01-01');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.max = '2001-01-01';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.max = '2021-01-01';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<add>
<add> it('should validate even if ng-min value changes on-the-fly', function() {
<add> scope.min = '2013-01-01';
<add> compileInput('<input type="date" ng-model="value" name="alias" ng-min="min" />');
<add>
<add> changeInputValueTo('2010-01-01');
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.min = '2014-01-01';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeInvalid();
<add>
<add> scope.min = '2009-01-01';
<add> scope.$digest();
<add>
<add> expect(inputElm).toBeValid();
<add> });
<ide> });
<ide>
<ide> describe('number', function() { | 1 |
Javascript | Javascript | add concatenatedproperties documentation | 807e23fb2febf5a8857303a0dec1f5f644707264 | <ide><path>packages/ember-runtime/lib/system/core_object.js
<ide> CoreObject.PrototypeMixin = Mixin.create({
<ide>
<ide> init: function() {},
<ide>
<add> /**
<add> Defines the properties that will be concatenated from the superclass
<add> (instead of overridden).
<add>
<add> By default, when you extend an Ember class a property defined in
<add> the subclass overrides a property with the same name that is defined
<add> in the superclass. However, there are some cases where it is preferable
<add> to build up a property's value by combining the superclass' property
<add> value with the subclass' value. An example of this in use within Ember
<add> is the `classNames` property of `Ember.View`.
<add>
<add> Here is some sample code showing the difference between a concatenated
<add> property and a normal one:
<add>
<add> ```javascript
<add> App.BarView = Ember.View.extend({
<add> someNonConcatenatedProperty: ['bar'],
<add> classNames: ['bar']
<add> });
<add>
<add> App.FooBarView = App.BarView.extend({
<add> someNonConcatenatedProperty: ['foo'],
<add> classNames: ['foo'],
<add> });
<add>
<add> var fooBarView = App.FooBarView.create();
<add> fooBarView.get('someNonConcatenatedProperty'); // ['foo']
<add> fooBarView.get('classNames'); // ['ember-view', 'bar', 'foo']
<add> ```
<add>
<add> This behavior extends to object creation as well. Continuing the
<add> above example:
<add>
<add> ```javascript
<add> var view = App.FooBarView.create({
<add> someNonConcatenatedProperty: ['baz'],
<add> classNames: ['baz']
<add> })
<add> view.get('someNonConcatenatedProperty'); // ['baz']
<add> view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
<add> ```
<add>
<add> Using the `concatenatedProperties` property, we can tell to Ember that mix
<add> the content of the properties.
<add>
<add> In `Ember.View` the `classNameBindings` and `attributeBindings` properties
<add> are also concatenated, in addition to `classNames`.
<add>
<add> This feature is available for you to use throughout the Ember object model,
<add> although typical app developers are likely to use it infrequently.
<add>
<add> @property concatenatedProperties
<add> @type Array
<add> @default null
<add> */
<add> concatenatedProperties: null,
<add>
<ide> /**
<ide> @property isDestroyed
<ide> @default false | 1 |
PHP | PHP | remove obsolete class import in cookie.php | 5097e9053b57752639986d3ec018b92c7904de48 | <ide><path>laravel/cookie.php
<del><?php namespace Laravel; use Closure;
<add><?php namespace Laravel;
<ide>
<ide> class Cookie {
<ide> | 1 |
Javascript | Javascript | use correct class name in deprecation message | d11f7d54f35af093efbee208b7920c158cfc2c72 | <ide><path>lib/_tls_legacy.js
<ide> module.exports = {
<ide> createSecurePair:
<ide> internalUtil.deprecate(createSecurePair,
<ide> 'tls.createSecurePair() is deprecated. Please use ' +
<del> 'tls.Socket instead.', 'DEP0064'),
<add> 'tls.TLSSocket instead.', 'DEP0064'),
<ide> pipe
<ide> };
<ide><path>test/parallel/test-tls-legacy-deprecated.js
<ide> const tls = require('tls');
<ide>
<ide> common.expectWarning(
<ide> 'DeprecationWarning',
<del> 'tls.createSecurePair() is deprecated. Please use tls.Socket instead.'
<add> 'tls.createSecurePair() is deprecated. Please use tls.TLSSocket instead.'
<ide> );
<ide>
<ide> assert.doesNotThrow(() => tls.createSecurePair()); | 2 |
Ruby | Ruby | fix typo in rdoc [ci skip] | d1629346b9506a013315525afac113d9b2bfb47c | <ide><path>actionmailer/lib/action_mailer/base.rb
<ide> module ActionMailer
<ide> # Once a mailer action and template are defined, you can deliver your message or create it and save it
<ide> # for delivery later:
<ide> #
<del> # Notifier.welcome(david).deliver_now # sends the email
<del> # mail = Notifier.welcome(david) # => an ActionMailer::MessageDeliver object
<add> # Notifier.welcome('david').deliver_now # sends the email
<add> # mail = Notifier.welcome('david') # => an ActionMailer::MessageDeliver object
<ide> # mail.deliver_now # sends the email
<ide> #
<ide> # The <tt>ActionMailer::MessageDeliver</tt> class is a wrapper around a <tt>Mail::Message</tt> object. If
<ide> # you want direct access to the <tt>Mail::Message</tt> object you can call the <tt>message</tt> method on
<ide> # the <tt>ActionMailer::MessageDeliver</tt> object.
<ide> #
<del> # Notifier.welcome(david).message # => a Mail::Message object
<add> # Notifier.welcome('david').message # => a Mail::Message object
<ide> #
<ide> # ActionMailer is nicely integrated with ActiveJob so you can send emails in the background (example: outside
<ide> # of the request-response cycle, so the user doesn't have to wait on it):
<ide> #
<del> # Notifier.welcome(david).deliver_later # enqueue the email sending to ActiveJob
<add> # Notifier.welcome('david').deliver_later # enqueue the email sending to ActiveJob
<ide> #
<ide> # You never instantiate your mailer class. Rather, you just call the method you defined on the class itself.
<ide> #
<ide><path>actionmailer/lib/action_mailer/message_delivery.rb
<ide> module ActionMailer
<ide> # around a lazy created Mail::Message. You can get direct access to the
<ide> # Mail::Message, deliver the email or schedule the email to be sent through ActiveJob.
<ide> #
<del> # Notifier.welcome(david) # an ActionMailer::MessageDeliver object
<del> # Notifier.welcome(david).deliver_now # sends the email
<del> # Notifier.welcome(david).deliver_later # enqueue the deliver email job to ActiveJob
<del> # Notifier.welcome(david).message # a Mail::Message object
<add> # Notifier.welcome('david') # an ActionMailer::MessageDeliver object
<add> # Notifier.welcome('david').deliver_now # sends the email
<add> # Notifier.welcome('david').deliver_later # enqueue the deliver email job to ActiveJob
<add> # Notifier.welcome('david').message # a Mail::Message object
<ide> class MessageDelivery < Delegator
<ide> def initialize(mailer, mail_method, *args) #:nodoc:
<ide> @mailer = mailer
<ide> def message
<ide> #
<ide> # ==== Examples
<ide> #
<del> # Notifier.welcome(david).deliver_later
<del> # Notifier.welcome(david).deliver_later(in: 1.hour)
<del> # Notifier.welcome(david).deliver_later(at: 10.hours.from_now)
<add> # Notifier.welcome('david').deliver_later
<add> # Notifier.welcome('david').deliver_later(in: 1.hour)
<add> # Notifier.welcome('david').deliver_later(at: 10.hours.from_now)
<ide> #
<ide> # ==== Options
<ide> # * <tt>in</tt> - Enqueue the message to be delivered with a delay
<ide> def deliver_later!(options={})
<ide> #
<ide> # ==== Examples
<ide> #
<del> # Notifier.welcome(david).deliver_later
<del> # Notifier.welcome(david).deliver_later(in: 1.hour)
<del> # Notifier.welcome(david).deliver_later(at: 10.hours.from_now)
<add> # Notifier.welcome('david').deliver_later
<add> # Notifier.welcome('david').deliver_later(in: 1.hour)
<add> # Notifier.welcome('david').deliver_later(at: 10.hours.from_now)
<ide> #
<ide> # ==== Options
<ide> # * <tt>in</tt> - Enqueue the message to be delivered with a delay
<ide> def deliver_later(options={})
<ide> # Delivers a message. The message will be sent bypassing checking perform_deliveries
<ide> # and raise_delivery_errors, so use with caution.
<ide> #
<del> # Notifier.welcome(david).deliver_now!
<add> # Notifier.welcome('david').deliver_now!
<ide> #
<ide> def deliver_now!
<ide> message.deliver!
<ide> end
<ide>
<ide> # Delivers a message:
<ide> #
<del> # Notifier.welcome(david).deliver_now
<add> # Notifier.welcome('david').deliver_now
<ide> #
<ide> def deliver_now
<ide> message.deliver | 2 |
Javascript | Javascript | fix memswap plugin displaying mem values in web ui | f3c855c77562d7cbf9177009e9b3bfb067320e2c | <ide><path>glances/outputs/static/js/services/plugins/glances_memswap.js
<ide> glancesApp.service('GlancesPluginMemSwap', function() {
<del> var _pluginName = "mem";
<add> var _pluginName = "memswap";
<ide> var _view = {};
<ide>
<ide> this.percent = null; | 1 |
Go | Go | implement docker build with standalone client lib | 535c4c9a59b1e58c897677d6948a595cb3d28639 | <ide><path>api/client/build.go
<ide> package client
<ide> import (
<ide> "archive/tar"
<ide> "bufio"
<del> "encoding/base64"
<del> "encoding/json"
<ide> "fmt"
<ide> "io"
<ide> "io/ioutil"
<del> "net/http"
<del> "net/url"
<ide> "os"
<ide> "os/exec"
<ide> "path/filepath"
<ide> "regexp"
<ide> "runtime"
<del> "strconv"
<ide> "strings"
<ide>
<ide> "github.com/docker/distribution/reference"
<ide> "github.com/docker/docker/api"
<add> "github.com/docker/docker/api/client/lib"
<ide> Cli "github.com/docker/docker/cli"
<ide> "github.com/docker/docker/opts"
<ide> "github.com/docker/docker/pkg/archive"
<ide> import (
<ide> "github.com/docker/docker/pkg/units"
<ide> "github.com/docker/docker/pkg/urlutil"
<ide> "github.com/docker/docker/registry"
<del> "github.com/docker/docker/runconfig"
<ide> tagpkg "github.com/docker/docker/tag"
<ide> "github.com/docker/docker/utils"
<ide> )
<ide> func (cli *DockerCli) CmdBuild(args ...string) error {
<ide> }
<ide> }
<ide>
<del> // Send the build context
<del> v := url.Values{
<del> "t": flTags.GetAll(),
<del> }
<del> if *suppressOutput {
<del> v.Set("q", "1")
<del> }
<add> var remoteContext string
<ide> if isRemote {
<del> v.Set("remote", cmd.Arg(0))
<del> }
<del> if *noCache {
<del> v.Set("nocache", "1")
<del> }
<del> if *rm {
<del> v.Set("rm", "1")
<del> } else {
<del> v.Set("rm", "0")
<del> }
<del>
<del> if *forceRm {
<del> v.Set("forcerm", "1")
<del> }
<del>
<del> if *pull {
<del> v.Set("pull", "1")
<del> }
<del>
<del> if !runconfig.IsolationLevel.IsDefault(runconfig.IsolationLevel(*isolation)) {
<del> v.Set("isolation", *isolation)
<del> }
<del>
<del> v.Set("cpusetcpus", *flCPUSetCpus)
<del> v.Set("cpusetmems", *flCPUSetMems)
<del> v.Set("cpushares", strconv.FormatInt(*flCPUShares, 10))
<del> v.Set("cpuquota", strconv.FormatInt(*flCPUQuota, 10))
<del> v.Set("cpuperiod", strconv.FormatInt(*flCPUPeriod, 10))
<del> v.Set("memory", strconv.FormatInt(memory, 10))
<del> v.Set("memswap", strconv.FormatInt(memorySwap, 10))
<del> v.Set("cgroupparent", *flCgroupParent)
<del>
<del> if *flShmSize != "" {
<del> parsedShmSize, err := units.RAMInBytes(*flShmSize)
<del> if err != nil {
<del> return err
<del> }
<del> v.Set("shmsize", strconv.FormatInt(parsedShmSize, 10))
<del> }
<del>
<del> v.Set("dockerfile", relDockerfile)
<del>
<del> ulimitsVar := flUlimits.GetList()
<del> ulimitsJSON, err := json.Marshal(ulimitsVar)
<del> if err != nil {
<del> return err
<del> }
<del> v.Set("ulimits", string(ulimitsJSON))
<del>
<del> // collect all the build-time environment variables for the container
<del> buildArgs := runconfig.ConvertKVStringsToMap(flBuildArg.GetAll())
<del> buildArgsJSON, err := json.Marshal(buildArgs)
<add> remoteContext = cmd.Arg(0)
<add> }
<add>
<add> options := lib.ImageBuildOptions{
<add> Context: body,
<add> Memory: memory,
<add> MemorySwap: memorySwap,
<add> Tags: flTags.GetAll(),
<add> SuppressOutput: *suppressOutput,
<add> RemoteContext: remoteContext,
<add> NoCache: *noCache,
<add> Remove: *rm,
<add> ForceRemove: *forceRm,
<add> PullParent: *pull,
<add> Isolation: *isolation,
<add> CPUSetCPUs: *flCPUSetCpus,
<add> CPUSetMems: *flCPUSetMems,
<add> CPUShares: *flCPUShares,
<add> CPUQuota: *flCPUQuota,
<add> CPUPeriod: *flCPUPeriod,
<add> CgroupParent: *flCgroupParent,
<add> ShmSize: *flShmSize,
<add> Dockerfile: relDockerfile,
<add> Ulimits: flUlimits.GetList(),
<add> BuildArgs: flBuildArg.GetAll(),
<add> AuthConfigs: cli.configFile.AuthConfigs,
<add> }
<add>
<add> response, err := cli.client.ImageBuild(options)
<ide> if err != nil {
<ide> return err
<ide> }
<del> v.Set("buildargs", string(buildArgsJSON))
<ide>
<del> headers := http.Header(make(map[string][]string))
<del> buf, err := json.Marshal(cli.configFile.AuthConfigs)
<add> err = jsonmessage.DisplayJSONMessagesStream(response.Body, cli.out, cli.outFd, cli.isTerminalOut)
<ide> if err != nil {
<del> return err
<del> }
<del> headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
<del> headers.Set("Content-Type", "application/tar")
<del>
<del> sopts := &streamOpts{
<del> rawTerminal: true,
<del> in: body,
<del> out: cli.out,
<del> headers: headers,
<del> }
<del>
<del> serverResp, err := cli.stream("POST", fmt.Sprintf("/build?%s", v.Encode()), sopts)
<del>
<del> // Windows: show error message about modified file permissions.
<del> if runtime.GOOS == "windows" {
<del> h, err := httputils.ParseServerHeader(serverResp.header.Get("Server"))
<del> if err == nil {
<del> if h.OS != "windows" {
<del> fmt.Fprintln(cli.err, `SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`)
<add> if jerr, ok := err.(*jsonmessage.JSONError); ok {
<add> // If no error code is set, default to 1
<add> if jerr.Code == 0 {
<add> jerr.Code = 1
<ide> }
<add> return Cli.StatusError{Status: jerr.Message, StatusCode: jerr.Code}
<ide> }
<ide> }
<ide>
<del> if jerr, ok := err.(*jsonmessage.JSONError); ok {
<del> // If no error code is set, default to 1
<del> if jerr.Code == 0 {
<del> jerr.Code = 1
<del> }
<del> return Cli.StatusError{Status: jerr.Message, StatusCode: jerr.Code}
<del> }
<del>
<del> if err != nil {
<del> return err
<add> // Windows: show error message about modified file permissions.
<add> if response.OSType == "windows" {
<add> fmt.Fprintln(cli.err, `SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.`)
<ide> }
<ide>
<ide> // Since the build was successful, now we must tag any of the resolved
<ide><path>api/client/lib/image_build.go
<add>package lib
<add>
<add>import (
<add> "encoding/base64"
<add> "encoding/json"
<add> "io"
<add> "net/http"
<add> "net/url"
<add> "strconv"
<add>
<add> "github.com/docker/docker/cliconfig"
<add> "github.com/docker/docker/pkg/httputils"
<add> "github.com/docker/docker/pkg/ulimit"
<add> "github.com/docker/docker/pkg/units"
<add> "github.com/docker/docker/runconfig"
<add>)
<add>
<add>// ImageBuildOptions holds the information
<add>// necessary to build images.
<add>type ImageBuildOptions struct {
<add> Tags []string
<add> SuppressOutput bool
<add> RemoteContext string
<add> NoCache bool
<add> Remove bool
<add> ForceRemove bool
<add> PullParent bool
<add> Isolation string
<add> CPUSetCPUs string
<add> CPUSetMems string
<add> CPUShares int64
<add> CPUQuota int64
<add> CPUPeriod int64
<add> Memory int64
<add> MemorySwap int64
<add> CgroupParent string
<add> ShmSize string
<add> Dockerfile string
<add> Ulimits []*ulimit.Ulimit
<add> BuildArgs []string
<add> AuthConfigs map[string]cliconfig.AuthConfig
<add> Context io.Reader
<add>}
<add>
<add>// ImageBuildResponse holds information
<add>// returned by a server after building
<add>// an image.
<add>type ImageBuildResponse struct {
<add> Body io.ReadCloser
<add> OSType string
<add>}
<add>
<add>// ImageBuild sends request to the daemon to build images.
<add>// The Body in the response implement an io.ReadCloser and it's up to the caller to
<add>// close it.
<add>func (cli *Client) ImageBuild(options ImageBuildOptions) (ImageBuildResponse, error) {
<add> query, err := imageBuildOptionsToQuery(options)
<add> if err != nil {
<add> return ImageBuildResponse{}, err
<add> }
<add>
<add> headers := http.Header(make(map[string][]string))
<add> buf, err := json.Marshal(options.AuthConfigs)
<add> if err != nil {
<add> return ImageBuildResponse{}, err
<add> }
<add> headers.Add("X-Registry-Config", base64.URLEncoding.EncodeToString(buf))
<add> headers.Set("Content-Type", "application/tar")
<add>
<add> serverResp, err := cli.POSTRaw("/build", query, options.Context, headers)
<add> if err != nil {
<add> return ImageBuildResponse{}, err
<add> }
<add>
<add> var osType string
<add> if h, err := httputils.ParseServerHeader(serverResp.header.Get("Server")); err == nil {
<add> osType = h.OS
<add> }
<add>
<add> return ImageBuildResponse{
<add> Body: serverResp.body,
<add> OSType: osType,
<add> }, nil
<add>}
<add>
<add>func imageBuildOptionsToQuery(options ImageBuildOptions) (url.Values, error) {
<add> query := url.Values{
<add> "t": options.Tags,
<add> }
<add> if options.SuppressOutput {
<add> query.Set("q", "1")
<add> }
<add> if options.RemoteContext != "" {
<add> query.Set("remote", options.RemoteContext)
<add> }
<add> if options.NoCache {
<add> query.Set("nocache", "1")
<add> }
<add> if options.Remove {
<add> query.Set("rm", "1")
<add> } else {
<add> query.Set("rm", "0")
<add> }
<add>
<add> if options.ForceRemove {
<add> query.Set("forcerm", "1")
<add> }
<add>
<add> if options.PullParent {
<add> query.Set("pull", "1")
<add> }
<add>
<add> if !runconfig.IsolationLevel.IsDefault(runconfig.IsolationLevel(options.Isolation)) {
<add> query.Set("isolation", options.Isolation)
<add> }
<add>
<add> query.Set("cpusetcpus", options.CPUSetCPUs)
<add> query.Set("cpusetmems", options.CPUSetMems)
<add> query.Set("cpushares", strconv.FormatInt(options.CPUShares, 10))
<add> query.Set("cpuquota", strconv.FormatInt(options.CPUQuota, 10))
<add> query.Set("cpuperiod", strconv.FormatInt(options.CPUPeriod, 10))
<add> query.Set("memory", strconv.FormatInt(options.Memory, 10))
<add> query.Set("memswap", strconv.FormatInt(options.MemorySwap, 10))
<add> query.Set("cgroupparent", options.CgroupParent)
<add>
<add> if options.ShmSize != "" {
<add> parsedShmSize, err := units.RAMInBytes(options.ShmSize)
<add> if err != nil {
<add> return query, err
<add> }
<add> query.Set("shmsize", strconv.FormatInt(parsedShmSize, 10))
<add> }
<add>
<add> query.Set("dockerfile", options.Dockerfile)
<add>
<add> ulimitsJSON, err := json.Marshal(options.Ulimits)
<add> if err != nil {
<add> return query, err
<add> }
<add> query.Set("ulimits", string(ulimitsJSON))
<add>
<add> buildArgs := runconfig.ConvertKVStringsToMap(options.BuildArgs)
<add> buildArgsJSON, err := json.Marshal(buildArgs)
<add> if err != nil {
<add> return query, err
<add> }
<add> query.Set("buildargs", string(buildArgsJSON))
<add>
<add> return query, nil
<add>} | 2 |
Python | Python | add failing test for issue | 9857cd9889583981b834628e054cb91f90c5ca65 | <ide><path>tests/test_bound_fields.py
<ide> class ExampleSerializer(serializers.Serializer):
<ide> assert serializer['bool_field'].as_form_field().value == ''
<ide> assert serializer['null_field'].as_form_field().value == ''
<ide>
<add> def test_rendering_boolean_field(self):
<add> from rest_framework.renderers import HTMLFormRenderer
<add>
<add> class ExampleSerializer(serializers.Serializer):
<add> bool_field = serializers.BooleanField(
<add> style={'base_template': 'checkbox.html', 'template_pack': 'rest_framework/vertical'})
<add>
<add> serializer = ExampleSerializer(data={'bool_field': True})
<add> assert serializer.is_valid()
<add> renderer = HTMLFormRenderer()
<add> rendered = renderer.render_field(serializer['bool_field'], {})
<add> expected_packed = (
<add> '<divclass="form-group">'
<add> '<divclass="checkbox">'
<add> '<label>'
<add> '<inputtype="checkbox"name="bool_field"value="true"checked>'
<add> 'Boolfield'
<add> '</label>'
<add> '</div>'
<add> '</div>'
<add> )
<add> rendered_packed = ''.join(rendered.split())
<add> assert rendered_packed == expected_packed
<add>
<ide>
<ide> class TestNestedBoundField:
<ide> def test_nested_empty_bound_field(self): | 1 |
Text | Text | add note about tweet button restrictions | 1ef49d2c577e9145561896807123b733a901008c | <ide><path>curriculum/challenges/english/03-front-end-libraries/front-end-libraries-projects/build-a-random-quote-machine.md
<ide> You can use any mix of HTML, JavaScript, CSS, Bootstrap, SASS, React, Redux, and
<ide> <strong>User Story #11:</strong> The <code>#quote-box</code> wrapper element should be horizontally centered. Please run tests with browser's zoom level at 100% and page maximized.
<ide> You can build your project by forking <a href='https://codepen.io/freeCodeCamp/pen/MJjpwO' target='_blank'>this CodePen pen</a>. Or you can use this CDN link to run the tests in any environment you like: <code>https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js</code>
<ide> Once you're done, submit the URL to your working project with all its tests passing.
<add><strong>Note:</strong> Twitter does not allow links to be loaded in an iframe. Try using the <code>target="_blank"</code> or <code>target="_top"</code> attribute on the <code>#tweet-quote</code> element if your tweet won't load. <code>target="_top"</code> will replace the current tab so make sure your work is saved.
<ide> </section>
<ide>
<ide> ## Instructions | 1 |
Text | Text | reorganize collaborator guide | 0a1fba02a65b0b6bb53ca2d6966eaca67265e7d6 | <ide><path>COLLABORATOR_GUIDE.md
<ide> **Contents**
<ide>
<ide> * [Issues and Pull Requests](#issues-and-pull-requests)
<add> - [Managing Issues and Pull Requests](#managing-issues-and-pull-requests)
<add> - [Welcoming First-Time Contributiors](#welcoming-first-time-contributiors)
<add> - [Closing Issues and Pull Requests](#closing-issues-and-pull-requests)
<ide> * [Accepting Modifications](#accepting-modifications)
<del> - [Useful CI Jobs](#useful-ci-jobs)
<del> - [Internal vs. Public API](#internal-vs-public-api)
<del> - [Breaking Changes](#breaking-changes)
<del> - [Deprecations](#deprecations)
<del> - [Involving the TSC](#involving-the-tsc)
<add> - [Code Reviews and Consensus Seeking](#code-reviews-and-consensus-seeking)
<add> - [Waiting for Approvals](#waiting-for-approvals)
<add> - [Testing and CI](#testing-and-ci)
<add> - [Useful CI Jobs](#useful-ci-jobs)
<add> - [Internal vs. Public API](#internal-vs-public-api)
<add> - [Breaking Changes](#breaking-changes)
<add> - [Breaking Changes and Deprecations](#breaking-changes-and-deprecations)
<add> - [Breaking Changes to Internal Elements](#breaking-changes-to-internal-elements)
<add> - [When Breaking Changes Actually Break Things](#when-breaking-changes-actually-break-things)
<add> - [Reverting commits](#reverting-commits)
<add> - [Introducing New Modules](#introducing-new-modules)
<add> - [Deprecations](#deprecations)
<add> - [Involving the TSC](#involving-the-tsc)
<ide> * [Landing Pull Requests](#landing-pull-requests)
<del> - [Technical HOWTO](#technical-howto)
<del> - [I Just Made a Mistake](#i-just-made-a-mistake)
<del> - [Long Term Support](#long-term-support)
<add> - [Technical HOWTO](#technical-howto)
<add> - [Troubleshooting](#troubleshooting)
<add> - [I Just Made a Mistake](#i-just-made-a-mistake)
<add> - [Long Term Support](#long-term-support)
<add> - [What is LTS?](#what-is-lts)
<add> - [How does LTS work?](#how-does-lts-work)
<add> - [Landing semver-minor commits in LTS](#landing-semver-minor-commits-in-lts)
<add> - [How are LTS Branches Managed?](#how-are-lts-branches-managed)
<add> - [How can I help?](#how-can-i-help)
<add> - [How is an LTS release cut?](#how-is-an-lts-release-cut)
<ide>
<ide> This document contains information for Collaborators of the Node.js
<ide> project regarding maintaining the code, documentation and issues.
<ide> understand the project governance model as outlined in
<ide>
<ide> ## Issues and Pull Requests
<ide>
<del>Courtesy should **always** be shown to individuals submitting issues and pull
<del>requests to the Node.js project. Be welcoming to first time contributors,
<del>identified by the GitHub  badge.
<add>### Managing Issues and Pull Requests
<ide>
<ide> Collaborators should feel free to take full responsibility for
<ide> managing issues and pull requests they feel qualified to handle, as
<ide> long as this is done while being mindful of these guidelines, the
<del>opinions of other Collaborators and guidance of the TSC.
<add>opinions of other Collaborators and guidance of the [TSC][]. They
<add>may also notify other qualified parties for more input on an issue
<add>or a pull request.
<add>[See "Who to CC in issues"](./doc/onboarding-extras.md#who-to-cc-in-issues)
<add>
<add>### Welcoming First-Time Contributiors
<ide>
<del>Collaborators may **close** any issue or pull request they believe is
<add>Courtesy should always be shown to individuals submitting issues and pull
<add>requests to the Node.js project. Be welcoming to first-time contributors,
<add>identified by the GitHub  badge.
<add>
<add>For first-time contributors, check if the commit author is the same as the
<add>pull request author, and ask if they have configured their git
<add>username and email to their liking as per [this guide][git-username].
<add>This is to make sure they would be promoted to "contributor" once
<add>their pull request gets landed.
<add>
<add>### Closing Issues and Pull Requests
<add>
<add>Collaborators may close any issue or pull request they believe is
<ide> not relevant for the future of the Node.js project. Where this is
<ide> unclear, the issue should be left open for several days to allow for
<ide> additional discussion. Where this does not yield input from Node.js
<ide> Collaborators or additional evidence that the issue has relevance, the
<ide> issue may be closed. Remember that issues can always be re-opened if
<ide> necessary.
<ide>
<del>[**See "Who to CC in issues"**](./doc/onboarding-extras.md#who-to-cc-in-issues)
<del>
<ide> ## Accepting Modifications
<ide>
<ide> All modifications to the Node.js code and documentation should be
<ide> performed via GitHub pull requests, including modifications by
<del>Collaborators and TSC members.
<add>Collaborators and TSC members. A pull request must be reviewed, and usually
<add>must also be tested with CI, before being landed into the codebase.
<add>
<add>### Code Reviews and Consensus Seeking
<ide>
<ide> All pull requests must be reviewed and accepted by a Collaborator with
<ide> sufficient expertise who is able to take full responsibility for the
<ide> change. In the case of pull requests proposed by an existing
<ide> Collaborator, an additional Collaborator is required for sign-off.
<ide>
<ide> In some cases, it may be necessary to summon a qualified Collaborator
<del>to a pull request for review by @-mention.
<add>or a Github team to a pull request for review by @-mention.
<add>[See "Who to CC in issues"](./doc/onboarding-extras.md#who-to-cc-in-issues)
<ide>
<ide> If you are unsure about the modification and are not prepared to take
<ide> full responsibility for the change, defer to another Collaborator.
<ide>
<del>Before landing pull requests, sufficient time should be left for input
<del>from other Collaborators. Leave at least 48 hours during the week and
<del>72 hours over weekends to account for international time differences
<del>and work schedules. Trivial changes (e.g. those which fix minor bugs
<del>or improve performance without affecting API or causing other
<del>wide-reaching impact), and focused changes that affect only documentation
<del>and/or the test suite, may be landed after a shorter delay if they have
<del>multiple approvals.
<del>
<del>For first time contributors, ask the author if they have configured their git
<del>username and email to their liking as per [this guide][git-username].
<add>If any Collaborator objects to a change *without giving any additional
<add>explanation or context*, and the objecting Collaborator fails to respond to
<add>explicit requests for explanation or context within a reasonable period of
<add>time, the objection may be dismissed. Note that this does not apply to
<add>objections that are explained.
<ide>
<ide> For non-breaking changes, if there is no disagreement amongst
<ide> Collaborators, a pull request may be landed given appropriate review.
<ide> elevate discussion to the TSC for resolution (see below).
<ide>
<ide> Breaking changes (that is, pull requests that require an increase in
<ide> the major version number, known as `semver-major` changes) must be
<del>elevated for review by the TSC. This does not necessarily mean that the
<del>PR must be put onto the TSC meeting agenda. If multiple TSC members
<del>approve (`LGTM`) the PR and no Collaborators oppose the PR, it can be
<del>landed. Where there is disagreement among TSC members or objections
<del>from one or more Collaborators, `semver-major` pull requests should be
<del>put on the TSC meeting agenda.
<add>[elevated for review by the TSC](#involving-the-tsc).
<add>This does not necessarily mean that the PR must be put onto the TSC meeting
<add>agenda. If multiple TSC members approve (`LGTM`) the PR and no Collaborators
<add>oppose the PR, it can be landed. Where there is disagreement among TSC members
<add>or objections from one or more Collaborators, `semver-major` pull requests
<add>should be put on the TSC meeting agenda.
<add>
<add>### Waiting for Approvals
<add>
<add>Before landing pull requests, sufficient time should be left for input
<add>from other Collaborators. In general, leave at least 48 hours during the
<add>week and 72 hours over weekends to account for international time
<add>differences and work schedules. However, certain types of pull requests
<add>can be fast-tracked and may be landed after a shorter delay:
<add>
<add>* Focused changes that affect only documentation and/or the test suite.
<add> `code-and-learn` and `good-first-issue` pull requests typically fall
<add> into this category.
<add>* Changes that revert commit(s) and/or fix regressions.
<add>
<add>When a pull request is deemed suitable to be fast-tracked, label it with
<add>`fast-track`. The pull request can be landed once 2 or more collaborators
<add>approve both the pull request and the fast-tracking request, and the necessary
<add>CI testing is done.
<add>
<add>### Testing and CI
<ide>
<ide> All bugfixes require a test case which demonstrates the defect. The
<ide> test should *fail* before the change, and *pass* after the change.
<ide> All pull requests that modify executable code should be subjected to
<ide> continuous integration tests on the
<ide> [project CI server](https://ci.nodejs.org/).
<ide>
<del>If any Collaborator objects to a change *without giving any additional
<del>explanation or context*, and the objecting Collaborator fails to respond to
<del>explicit requests for explanation or context within a reasonable period of
<del>time, the objection may be dismissed. Note that this does not apply to
<del>objections that are explained.
<del>
<ide> #### Useful CI Jobs
<ide>
<ide> * [`node-test-pull-request`](https://ci.nodejs.org/job/node-test-pull-request/)
<ide> using an API in a manner currently undocumented achieves a particular useful
<ide> result, a decision will need to be made whether or not that falls within the
<ide> supported scope of that API; and if it does, it should be documented.
<ide>
<del>Breaking changes to internal elements are permitted in semver-patch or
<del>semver-minor commits but Collaborators should take significant care when
<del>making and reviewing such changes. Before landing such commits, an effort
<del>must be made to determine the potential impact of the change in the ecosystem
<del>by analyzing current use and by validating such changes through ecosystem
<del>testing using the [Canary in the Goldmine](https://github.com/nodejs/citgm)
<del>tool. If a change cannot be made without ecosystem breakage, then TSC review is
<del>required before landing the change as anything less than semver-major.
<del>
<del>If a determination is made that a particular internal API (for instance, an
<del>underscore `_` prefixed property) is sufficiently relied upon by the ecosystem
<del>such that any changes may break user code, then serious consideration should be
<del>given to providing an alternative Public API for that functionality before any
<del>breaking changes are made.
<add>See [Breaking Changes to Internal Elements](#breaking-changes-to-internal-elements)
<add>on how to handle those types of changes.
<ide>
<ide> ### Breaking Changes
<ide>
<ide> changing error messages in any way, altering expected timing of an event (e.g.
<ide> moving from sync to async responses or vice versa), and changing the
<ide> non-internal side effects of using a particular API.
<ide>
<add>Purely additive changes (e.g. adding new events to `EventEmitter`
<add>implementations, adding new arguments to a method in a way that allows
<add>existing code to continue working without modification, or adding new
<add>properties to an options argument) are semver-minor changes.
<add>
<add>#### Breaking Changes and Deprecations
<add>
<ide> With a few notable exceptions outlined below, when backwards incompatible
<ide> changes to a *Public* API are necessary, the existing API *must* be deprecated
<ide> *first* and the new API either introduced in parallel or added after the next
<ide> Exception to this rule is given in the following cases:
<ide> Such changes *must* be handled as semver-major changes but MAY be landed
<ide> without a [Deprecation cycle](#deprecation-cycle).
<ide>
<del>From time-to-time, in particularly exceptional cases, the TSC may be asked to
<del>consider and approve additional exceptions to this rule.
<del>
<del>Purely additive changes (e.g. adding new events to EventEmitter
<del>implementations, adding new arguments to a method in a way that allows
<del>existing code to continue working without modification, or adding new
<del>properties to an options argument) are handled as semver-minor changes.
<del>
<ide> Note that errors thrown, along with behaviors and APIs implemented by
<ide> dependencies of Node.js (e.g. those originating from V8) are generally not
<ide> under the control of Node.js and therefore *are not directly subject to this
<ide> policy*. However, care should still be taken when landing updates to
<ide> dependencies when it is known or expected that breaking changes to error
<ide> handling may have been made. Additional CI testing may be required.
<ide>
<del>#### When breaking changes actually break things
<add>From time-to-time, in particularly exceptional cases, the TSC may be asked to
<add>consider and approve additional exceptions to this rule.
<add>
<add>For more information, see [Deprecations](#deprecations).
<add>
<add>#### Breaking Changes to Internal Elements
<add>
<add>Breaking changes to internal elements are permitted in semver-patch or
<add>semver-minor commits but Collaborators should take significant care when
<add>making and reviewing such changes. Before landing such commits, an effort
<add>must be made to determine the potential impact of the change in the ecosystem
<add>by analyzing current use and by validating such changes through ecosystem
<add>testing using the [Canary in the Goldmine](https://github.com/nodejs/citgm)
<add>tool. If a change cannot be made without ecosystem breakage, then TSC review is
<add>required before landing the change as anything less than semver-major.
<add>
<add>If a determination is made that a particular internal API (for instance, an
<add>underscore `_` prefixed property) is sufficiently relied upon by the ecosystem
<add>such that any changes may break user code, then serious consideration should be
<add>given to providing an alternative Public API for that functionality before any
<add>breaking changes are made.
<add>
<add>#### When Breaking Changes Actually Break Things
<ide>
<ide> Because breaking (semver-major) changes are permitted to land on the master
<ide> branch at any time, at least some subset of the user ecosystem may be adversely
<ide> Changes" section of the release notes.
<ide>
<ide> ### Involving the TSC
<ide>
<del>Collaborators may opt to elevate pull requests or issues to the TSC for
<del>discussion by assigning the `tsc-review` label. This should be done
<del>where a pull request:
<add>Collaborators may opt to elevate pull requests or issues to the [TSC][] for
<add>discussion by assigning the `tsc-review` label or @-mentioning the
<add>`@nodejs/tsc` Github team. This should be done where a pull request:
<ide>
<del>- has a significant impact on the codebase,
<del>- is inherently controversial; or
<add>- is labeled `semver-major`, or
<add>- has a significant impact on the codebase, or
<add>- is inherently controversial, or
<ide> - has failed to reach consensus amongst the Collaborators who are
<ide> actively participating in the discussion.
<ide>
<ide> LTS working group and the Release team.
<ide> [Enhancement Proposal]: https://github.com/nodejs/node-eps
<ide> [git-username]: https://help.github.com/articles/setting-your-username-in-git/
<ide> [`node-core-utils`]: https://github.com/nodejs/node-core-utils
<add>[TSC]: https://github.com/nodejs/TSC | 1 |
Go | Go | add networkmanager and clusterstatus interfaces | 8f4f85dd5b5b6b7268428b8f95f56c1ba8608ac3 | <ide><path>daemon/cluster.go
<ide> import (
<ide>
<ide> // Cluster is the interface for github.com/docker/docker/daemon/cluster.(*Cluster).
<ide> type Cluster interface {
<add> ClusterStatus
<add> NetworkManager
<add>}
<add>
<add>// ClusterStatus interface provides information about the Swarm status of the Cluster
<add>type ClusterStatus interface {
<add> IsAgent() bool
<add> IsManager() bool
<add>}
<add>
<add>// NetworkManager provides methods to manage networks
<add>type NetworkManager interface {
<ide> GetNetwork(input string) (apitypes.NetworkResource, error)
<ide> GetNetworks() ([]apitypes.NetworkResource, error)
<ide> RemoveNetwork(input string) error | 1 |
Ruby | Ruby | fix example action dispatch in mime type | c007d871e6d46d58c53aa18cdb6e0ca484eecdf7 | <ide><path>actionpack/lib/action_dispatch/http/mime_type.rb
<ide> def self.[](type)
<ide> # respond_to do |format|
<ide> # format.html
<ide> # format.ics { render :text => post.to_ics, :mime_type => Mime::Type["text/calendar"] }
<del> # format.xml { render :xml => @people.to_xml }
<add> # format.xml { render :xml => @people }
<ide> # end
<ide> # end
<ide> # end | 1 |
Javascript | Javascript | fix postcss.config.js warnings | 600b78c098bb9c1d4b6135df146e5948c1baf07f | <ide><path>examples/blog-starter/postcss.config.js
<ide> module.exports = {
<ide> plugins: [
<ide> 'tailwindcss',
<del> process.env.NODE_ENV === 'production'
<add> ...(process.env.NODE_ENV === 'production'
<ide> ? [
<del> '@fullhuman/postcss-purgecss',
<del> {
<del> content: [
<del> './pages/**/*.{js,jsx,ts,tsx}',
<del> './components/**/*.{js,jsx,ts,tsx}',
<del> ],
<del> defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || [],
<del> },
<add> [
<add> '@fullhuman/postcss-purgecss',
<add> {
<add> content: [
<add> './pages/**/*.{js,jsx,ts,tsx}',
<add> './components/**/*.{js,jsx,ts,tsx}',
<add> ],
<add> defaultExtractor: content =>
<add> content.match(/[\w-/:]+(?<!:)/g) || [],
<add> },
<add> ],
<ide> ]
<del> : undefined,
<add> : []),
<ide> 'postcss-preset-env',
<ide> ],
<ide> } | 1 |
Java | Java | fix event handlers for dpad arrows on android tv | 4d71b1525d357a61a1740d6de5c1b97b6527f986 | <ide><path>ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.java
<ide> public class ReactAndroidHWInputDeviceHelper {
<ide> * Contains a mapping between handled KeyEvents and the corresponding navigation event
<ide> * that should be fired when the KeyEvent is received.
<ide> */
<del> private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.of(
<del> KeyEvent.KEYCODE_DPAD_CENTER,
<del> "select",
<del> KeyEvent.KEYCODE_ENTER,
<del> "select",
<del> KeyEvent.KEYCODE_SPACE,
<del> "select",
<del> KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE,
<del> "playPause",
<del> KeyEvent.KEYCODE_MEDIA_REWIND,
<del> "rewind",
<del> KeyEvent.KEYCODE_MEDIA_FAST_FORWARD,
<del> "fastForward"
<del> );
<add> private static final Map<Integer, String> KEY_EVENTS_ACTIONS = MapBuilder.<Integer, String>builder()
<add> .put(KeyEvent.KEYCODE_DPAD_CENTER, "select")
<add> .put(KeyEvent.KEYCODE_ENTER, "select")
<add> .put(KeyEvent.KEYCODE_SPACE, "select")
<add> .put(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, "playPause")
<add> .put(KeyEvent.KEYCODE_MEDIA_REWIND, "rewind")
<add> .put(KeyEvent.KEYCODE_MEDIA_FAST_FORWARD, "fastForward")
<add> .put(KeyEvent.KEYCODE_DPAD_UP, "up")
<add> .put(KeyEvent.KEYCODE_DPAD_RIGHT, "right")
<add> .put(KeyEvent.KEYCODE_DPAD_DOWN, "down")
<add> .put(KeyEvent.KEYCODE_DPAD_LEFT, "left")
<add> .build();
<ide>
<ide> /**
<ide> * We keep a reference to the last focused view id | 1 |
Javascript | Javascript | implement endinlineimage ir | a2bf701bfeef9ebc977eb62ca2663150885f5007 | <ide><path>pdf.js
<ide> var PartialEvaluator = (function() {
<ide>
<ide> constructor.prototype = {
<ide> getIRQueue: function(stream, xref, resources, queue, fonts, images, uniquePrefix) {
<add> function buildPaintImageXObject(image, inline) {
<add> var dict = image.dict;
<add> var w = dict.get('Width', 'W');
<add> var h = dict.get('Height', 'H');
<add>
<add> if (image instanceof JpegStream) {
<add> var objId = ++objIdCounter;
<add> images.push({
<add> id: objId,
<add> IR: image.getIR()
<add> });
<add>
<add> // Add the dependency on the image object.
<add> fnArray.push("dependency");
<add> argsArray.push([ objId ]);
<add>
<add> // The normal fn.
<add> fn = 'paintJpegXObject';
<add> args = [ objId, w, h ];
<add> } else {
<add> // Needs to be rendered ourself.
<add>
<add> // Figure out if the image has an imageMask.
<add> var imageMask = dict.get('ImageMask', 'IM') || false;
<add>
<add> // If there is no imageMask, create the PDFImage and a lot
<add> // of image processing can be done here.
<add> if (!imageMask) {
<add> var imageObj = new PDFImage(xref, resources, image, inline);
<add>
<add> if (imageObj.imageMask) {
<add> throw "Can't handle this in the web worker :/";
<add> }
<add>
<add> var imgData = {
<add> width: w,
<add> height: h,
<add> data: new Uint8Array(w * h * 4)
<add> };
<add> var pixels = imgData.data;
<add> imageObj.fillRgbaBuffer(pixels, imageObj.decode);
<add>
<add> fn = "paintImageXObject";
<add> args = [ imgData ];
<add> } else /* imageMask == true */ {
<add> // This depends on a tmpCanvas beeing filled with the
<add> // current fillStyle, such that processing the pixel
<add> // data can't be done here. Instead of creating a
<add> // complete PDFImage, only read the information needed
<add> // for later.
<add> fn = "paintImageMaskXObject";
<add>
<add> var width = dict.get('Width', 'W');
<add> var height = dict.get('Height', 'H');
<add> var bitStrideLength = (width + 7) >> 3;
<add> var imgArray = image.getBytes(bitStrideLength * height);
<add> var decode = dict.get('Decode', 'D');
<add> var inverseDecode = !!decode && decode[0] > 0;
<add>
<add> args = [ imgArray, inverseDecode, width, height ];
<add> }
<add> }
<add> }
<add>
<ide> uniquePrefix = uniquePrefix || "";
<ide> if (!queue.argsArray) {
<ide> queue.argsArray = []
<ide> var PartialEvaluator = (function() {
<ide> fn = "paintFormXObjectEnd";
<ide> args = [];
<ide> } else if ('Image' == type.name) {
<del> var image = xobj;
<del> var dict = image.dict;
<del> var w = dict.get('Width', 'W');
<del> var h = dict.get('Height', 'H');
<del>
<del> if (image instanceof JpegStream) {
<del> var objId = ++objIdCounter;
<del> images.push({
<del> id: objId,
<del> IR: image.getIR()
<del> });
<del>
<del> // Add the dependency on the image object.
<del> fnArray.push("dependency");
<del> argsArray.push([ objId ]);
<del>
<del> // The normal fn.
<del> fn = 'paintJpegXObject';
<del> args = [ objId, w, h ];
<del> } else {
<del> // Needs to be rendered ourself.
<del>
<del> // Figure out if the image has an imageMask.
<del> var imageMask = dict.get('ImageMask', 'IM') || false;
<del>
<del> // If there is no imageMask, create the PDFImage and a lot
<del> // of image processing can be done here.
<del> if (!imageMask) {
<del> var inline = false;
<del> var imageObj = new PDFImage(xref, resources, image, inline);
<del>
<del> if (imageObj.imageMask) {
<del> throw "Can't handle this in the web worker :/";
<del> }
<del>
<del> var imgData = {
<del> width: w,
<del> height: h,
<del> data: new Uint8Array(w * h * 4)
<del> };
<del> var pixels = imgData.data;
<del> imageObj.fillRgbaBuffer(pixels, imageObj.decode);
<del>
<del> fn = "paintImageXObject";
<del> args = [ imgData ];
<del> } else /* imageMask == true */ {
<del> // This depends on a tmpCanvas beeing filled with the
<del> // current fillStyle, such that processing the pixel
<del> // data can't be done here. Instead of creating a
<del> // complete PDFImage, only read the information needed
<del> // for later.
<del> fn = "paintImageMaskXObject";
<del>
<del> var width = dict.get('Width', 'W');
<del> var height = dict.get('Height', 'H');
<del> var bitStrideLength = (width + 7) >> 3;
<del> var imgArray = image.getBytes(bitStrideLength * height);
<del> var decode = dict.get('Decode', 'D');
<del> var inverseDecode = !!imageObj.decode && imageObj.decode[0] > 0;
<del>
<del> args = [ imgArray, inverseDecode, width, height ];
<del> }
<del> }
<add> buildPaintImageXObject(xobj, false)
<ide> } else {
<ide> error('Unhandled XObject subtype ' + type.name);
<ide> }
<ide> var PartialEvaluator = (function() {
<ide> // TODO: TOASK: Is it possible to get here? If so, what does
<ide> // args[0].name should be like???
<ide> }
<add> } else if (cmd == 'EI') {
<add> buildPaintImageXObject(args[0], true);
<ide> }
<ide>
<ide> // Transform some cmds.
<ide> var CanvasGraphics = (function() {
<ide> beginImageData: function() {
<ide> error('Should not call beginImageData');
<ide> },
<del> endInlineImage: function(image) {
<del> this.paintImageXObject(null, image, true);
<del> },
<ide>
<ide> paintFormXObjectBegin: function(matrix, bbox) {
<ide> this.save();
<ide><path>worker/message_handler.js
<ide> MessageHandler.prototype = {
<ide> },
<ide>
<ide> send: function(actionName, data) {
<del> try {
<del> this.comObj.postMessage({
<del> action: actionName,
<del> data: data
<del> });
<del> } catch (e) {
<del> console.error("FAILED to send data from", this.name);
<del> throw e;
<del> }
<add> this.comObj.postMessage({
<add> action: actionName,
<add> data: data
<add> });
<ide> }
<del>
<ide> }
<ide> | 2 |
Mixed | Javascript | expose pagemargin prop on viewpagerandroid | 6038040f8e8238fc7fae943aa623d6f32693d4f1 | <ide><path>Examples/UIExplorer/ViewPagerAndroidExample.android.js
<ide> /**
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<add> *
<ide> * The examples provided by Facebook are for non-commercial testing and
<ide> * evaluation purposes only.
<ide> *
<ide> var ViewPagerAndroidExample = React.createClass({
<ide> onPageScroll={this.onPageScroll}
<ide> onPageSelected={this.onPageSelected}
<ide> onPageScrollStateChanged={this.onPageScrollStateChanged}
<add> pageMargin={10}
<ide> ref={viewPager => { this.viewPager = viewPager; }}>
<ide> {pages}
<ide> </ViewPagerAndroid>
<ide><path>Libraries/Components/ViewPager/ViewPagerAndroid.android.js
<ide> /**
<del> * Copyright 2004-present Facebook. All Rights Reserved.
<add> * Copyright (c) 2013-present, Facebook, Inc.
<add> * All rights reserved.
<add> *
<add> * This source code is licensed under the BSD-style license found in the
<add> * LICENSE file in the root directory of this source tree. An additional grant
<add> * of patent rights can be found in the PATENTS file in the same directory.
<ide> *
<ide> * @providesModule ViewPagerAndroid
<ide> * @flow
<ide> */
<ide> 'use strict';
<ide>
<del>var NativeMethodsMixin = require('NativeMethodsMixin');
<ide> var React = require('React');
<ide> var ReactElement = require('ReactElement');
<del>var ReactNativeViewAttributes = require('ReactNativeViewAttributes');
<ide> var ReactPropTypes = require('ReactPropTypes');
<ide> var UIManager = require('UIManager');
<ide> var View = require('View');
<ide> var ViewPagerAndroid = React.createClass({
<ide> */
<ide> onPageSelected: ReactPropTypes.func,
<ide>
<add> /**
<add> * Blank space to show between pages. This is only visible while scrolling, pages are still
<add> * edge-to-edge.
<add> */
<add> pageMargin: ReactPropTypes.number,
<add>
<ide> /**
<ide> * Determines whether the keyboard gets dismissed in response to a drag.
<ide> * - 'none' (the default), drags do not dismiss the keyboard.
<ide> var ViewPagerAndroid = React.createClass({
<ide> render: function() {
<ide> return (
<ide> <NativeAndroidViewPager
<add> {...this.props}
<ide> ref={VIEWPAGER_REF}
<ide> style={this.props.style}
<ide> onPageScroll={this._onPageScroll}
<ide><path>ReactAndroid/src/main/java/com/facebook/react/views/viewpager/ReactViewPagerManager.java
<ide> import com.facebook.infer.annotation.Assertions;
<ide> import com.facebook.react.bridge.ReadableArray;
<ide> import com.facebook.react.common.MapBuilder;
<add>import com.facebook.react.uimanager.PixelUtil;
<ide> import com.facebook.react.uimanager.ThemedReactContext;
<ide> import com.facebook.react.uimanager.ViewGroupManager;
<add>import com.facebook.react.uimanager.annotations.ReactProp;
<ide>
<ide> import javax.annotation.Nullable;
<ide>
<ide> public View getChildAt(ReactViewPager parent, int index) {
<ide> public void removeViewAt(ReactViewPager parent, int index) {
<ide> parent.removeViewFromAdapter(index);
<ide> }
<add>
<add> @ReactProp(name = "pageMargin", defaultFloat = 0)
<add> public void setPageMargin(ReactViewPager pager, float margin) {
<add> pager.setPageMargin((int) PixelUtil.toPixelFromDIP(margin));
<add> }
<ide> } | 3 |
Go | Go | remove redundant comments in test build.go | 32b81dae29fbb6f831cda5e9db1c120f78cd4a91 | <ide><path>integration-cli/cli/build/build.go
<ide> func WithoutCache(cmd *icmd.Cmd) func() {
<ide> return nil
<ide> }
<ide>
<del>// WithContextPath set the build context path
<add>// WithContextPath sets the build context path
<ide> func WithContextPath(path string) func(*icmd.Cmd) func() {
<del> // WithContextPath sets the build context path
<ide> return func(cmd *icmd.Cmd) func() {
<ide> cmd.Command = append(cmd.Command, path)
<ide> return nil | 1 |
PHP | PHP | fix cs error | 6d696806335770b83e293cb2333431518b8c66b6 | <ide><path>src/Controller/Component/FlashComponent.php
<ide> namespace Cake\Controller\Component;
<ide>
<ide> use Cake\Controller\Component;
<del>use Cake\Controller\ComponentRegistry;
<ide> use Cake\Http\Exception\InternalErrorException;
<ide> use Cake\Utility\Inflector;
<ide> use Exception; | 1 |
Python | Python | fix legend placement in `percentile` docs | 8d2af2eb69fceb7663f39af3307fff45ee636a45 | <ide><path>numpy/lib/function_base.py
<ide> def percentile(a,
<ide> xlabel='Percentile',
<ide> ylabel='Estimated percentile value',
<ide> yticks=a)
<del> ax.legend()
<add> ax.legend(bbox_to_anchor=(1.03, 1))
<add> plt.tight_layout()
<ide> plt.show()
<ide>
<ide> References | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.