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 var colorbrewer =
4cc7599b5f19ae8630e0085a226f00e6bba39049
<ide><path>lib/colorbrewer/colorbrewer.js <ide> // This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/). <del>{YlGn: { <add>var colorbrewer = {YlGn: { <ide> 3: ["#f7fcb9","#addd8e","#31a354"], <ide> 4: ["#ffffcc","#c2e699","#78c679","#238443"], <ide> 5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
1
PHP
PHP
fix missed type declaration from base class
4aeb89235e594f3b942fc6c136b76de4de7d65cc
<ide><path>src/Illuminate/Http/Request.php <ide> public function secure() <ide> /** <ide> * Get the client IP address. <ide> * <del> * @return string <add> * @return string|null <ide> */ <ide> public function ip() <ide> {
1
PHP
PHP
fix cookies on subdomains
bc9940a87bbc2d338107972d213c6d81dad644aa
<ide><path>lib/Cake/Network/Http/Client.php <ide> protected function _storeCookies(Response $response, $host) { <ide> * Adds cookies stored in the client to the request. <ide> * <ide> * Uses the request's host to find matching cookies. <add> * Walks backwards through subdomains to find cookies <add> * defined on parent domains. <ide> * <ide> * @param Request $request <ide> * @return void <ide> */ <ide> protected function _addCookies(Request $request) { <del> $host = parse_url($request->url(), PHP_URL_HOST); <del> if (isset($this->_cookies[$host])) { <del> $request->cookie($this->_cookies[$host]); <add> $parts = explode('.', parse_url($request->url(), PHP_URL_HOST)); <add> for ($i = 0, $len = count($parts); $i < $len - 1; $i++) { <add> $host = implode('.', array_slice($parts, $i)); <add> if (isset($this->_cookies[$host])) { <add> $request->cookie($this->_cookies[$host]); <add> } <ide> } <ide> } <ide> <ide><path>lib/Cake/Test/TestCase/Network/Http/ClientTest.php <ide> public function testCookiesWithDomain() { <ide> 'Set-Cookie: third=3', <ide> ]; <ide> $secondResponse = new Response($secondHeaders, ''); <add> $thirdResponse = new Response([], ''); <ide> <ide> $mock = $this->getMock( <ide> 'Cake\Network\Http\Adapter\Stream', <ide> public function testCookiesWithDomain() { <ide> )) <ide> ->will($this->returnValue([$secondResponse])); <ide> <add> $mock->expects($this->at(2)) <add> ->method('send') <add> ->with($this->attributeEqualTo( <add> '_cookies', <add> ['first' => '1', 'second' => '2', 'third' => '3'] <add> )) <add> ->will($this->returnValue([$thirdResponse])); <add> <ide> $http = new Client([ <ide> 'host' => 'test.cakephp.org', <ide> 'adapter' => $mock <ide> ]); <ide> <ide> $http->get('/projects'); <ide> $http->get('http://cakephp.org/versions'); <add> $http->get('/projects'); <ide> <ide> $result = $http->cookies(); <ide> $expected = [
2
Python
Python
remove fpe `fill` special case after rebase
a546ee19523f9b97db985afa8d161af0dee1fafa
<ide><path>numpy/core/tests/test_casting_floatingpoint_errors.py <ide> def assignment(): <ide> <ide> yield assignment <ide> <del> # TODO: This constraint is a bug in arr.fill() and should be removed <del> # e.g. by gh-20924. The type check works around the fact that <del> # PyPy seems to create an "invalid" error itself, and we see it <del> # due to gh-21416. <del> if type(value) is int and value != 10**100: <del> def fill(): <del> arr = np.empty(3, dtype=dtype) <del> arr.fill(value) <del> <del> yield fill <add> def fill(): <add> arr = np.empty(3, dtype=dtype) <add> arr.fill(value) <add> <add> yield fill <ide> <ide> def copyto_scalar(): <ide> arr = np.empty(3, dtype=dtype)
1
Javascript
Javascript
check logic simplification
d69a26b9650df7dc1f210c3c59df74ec4245dff3
<ide><path>lib/buffer.js <ide> SlowBuffer.prototype.__proto__ = Buffer.prototype; <ide> <ide> <ide> function clamp(index, len, defaultValue) { <del> if (typeof index === 'undefined') return defaultValue; <add> if (typeof index !== 'number') return defaultValue; <ide> index = ~~index; // Coerce to integer. <ide> if (index >= len) return len; <ide> if (index >= 0) return index; <ide> function toHex(n) { <ide> SlowBuffer.prototype.toString = function(encoding, start, end) { <ide> encoding = String(encoding || 'utf8').toLowerCase(); <ide> start = +start || 0; <del> if (typeof end == 'undefined') end = this.length; <add> if (typeof end !== 'number') end = this.length; <ide> <ide> // Fastpath empty strings <ide> if (+end == start) { <ide> SlowBuffer.prototype.slice = function(start, end) { <ide> }; <ide> <ide> <del>function coerce(length) { <del> // Coerce length to a number (possibly NaN), round up <del> // in case it's fractional (e.g. 123.456). Since NaN <del> // comparisons are always false, use to return zero. <del> length = Math.ceil(+length); <del> return length > 0 ? length : 0; <del>} <del> <del> <ide> var zeroBuffer = new SlowBuffer(0); <ide> <ide> // Buffer <ide> function Buffer(subject, encoding, offset) { <ide> throw new TypeError('First argument must be a Buffer when slicing'); <ide> } <ide> <del> this.length = coerce(encoding); <add> this.length = +encoding > 0 ? Math.ceil(encoding) : 0; <ide> this.parent = subject.parent ? subject.parent : subject; <ide> this.offset = offset; <ide> } else { <ide> // Find the length <ide> switch (type = typeof subject) { <ide> case 'number': <del> this.length = coerce(subject); <add> this.length = +subject > 0 ? Math.ceil(subject) : 0; <ide> break; <ide> <ide> case 'string': <ide> this.length = Buffer.byteLength(subject, encoding); <ide> break; <ide> <del> case 'object': // Assume object is an array <del> this.length = coerce(subject.length); <add> case 'object': // Assume object is array-ish <add> this.length = +subject.length > 0 ? Math.ceil(subject.length) : 0; <ide> break; <ide> <ide> default: <ide> function Buffer(subject, encoding, offset) { <ide> this.offset = 0; <ide> } <ide> <del> // Treat array-ish objects as a byte array. <del> if (isArrayIsh(subject)) { <del> for (var i = 0; i < this.length; i++) { <del> this.parent[i + this.offset] = subject[i]; <add> // optimize by branching logic for new allocations <add> if (typeof subject !== 'number') { <add> if (type === 'string') { <add> // We are a string <add> this.length = this.write(subject, 0, encoding); <add> // if subject is buffer then use built-in copy method <add> } else if (Buffer.isBuffer(subject)) { <add> if (subject.parent) <add> subject.parent.copy(this.parent, <add> this.offset, <add> subject.offset, <add> this.length + subject.offset); <add> else <add> subject.copy(this.parent, this.offset, 0, this.length); <add> } else if (isArrayIsh(subject)) { <add> for (var i = 0; i < this.length; i++) <add> this.parent[i + this.offset] = subject[i]; <ide> } <del> } else if (type == 'string') { <del> // We are a string <del> this.length = this.write(subject, 0, encoding); <ide> } <ide> } <ide> <ide> SlowBuffer.makeFastBuffer(this.parent, this, this.offset, this.length); <ide> } <ide> <ide> function isArrayIsh(subject) { <del> return Array.isArray(subject) || Buffer.isBuffer(subject) || <add> return Array.isArray(subject) || <ide> subject && typeof subject === 'object' && <ide> typeof subject.length === 'number'; <ide> } <ide> Buffer.prototype.toJSON = function() { <ide> Buffer.prototype.toString = function(encoding, start, end) { <ide> encoding = String(encoding || 'utf8').toLowerCase(); <ide> <del> if (typeof start == 'undefined' || start < 0) { <add> if (typeof start !== 'number' || start < 0) { <ide> start = 0; <ide> } else if (start > this.length) { <ide> start = this.length; <ide> } <ide> <del> if (typeof end == 'undefined' || end > this.length) { <add> if (typeof end !== 'number' || end > this.length) { <ide> end = this.length; <ide> } else if (end < 0) { <ide> end = 0; <ide> Buffer.prototype.fill = function fill(value, start, end) { <ide> if (typeof value === 'string') { <ide> value = value.charCodeAt(0); <ide> } <del> if (!(typeof value === 'number') || isNaN(value)) { <add> if (typeof value !== 'number' || isNaN(value)) { <ide> throw new TypeError('value is not a number'); <ide> } <ide>
1
Text
Text
fix typo in 3.1 announcement
b18d773b517a93528fbdba043b9da8d7bc2cf5b4
<ide><path>docs/topics/3.1-announcement.md <ide> Some highlights include: <ide> * An improved pagination API, supporting header or in-body pagination styles. <ide> * Pagination controls rendering in the browsable API. <ide> * Better support for API versioning. <del>* Built-in internalization support. <add>* Built-in internationalization support. <ide> * Support for Django 1.8's `HStoreField` and `ArrayField`. <ide> <ide> ---
1
Text
Text
reset regex.lastindex when tests use test method
78e28e2bd36c92fb1515776a0f6a14a6fd1cf3ba
<ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/find-one-or-more-criminals-in-a-hunt.md <ide> assert( <ide> Your regex should not match any criminals in the empty string `""` <ide> <ide> ```js <add>reCriminals.lastIndex = 0; <ide> assert(!reCriminals.test('')); <ide> ``` <ide> <ide> Your regex should not match any criminals in the string `P1P2P3` <ide> <ide> ```js <add>reCriminals.lastIndex = 0; <ide> assert(!reCriminals.test('P1P2P3')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/ignore-case-while-matching.md <ide> Write a regex `fccRegex` to match `freeCodeCamp`, no matter its case. Your regex <ide> Your regex should match the string `freeCodeCamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('freeCodeCamp')); <ide> ``` <ide> <ide> Your regex should match the string `FreeCodeCamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FreeCodeCamp')); <ide> ``` <ide> <ide> Your regex should match the string `FreecodeCamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FreecodeCamp')); <ide> ``` <ide> <ide> Your regex should match the string `FreeCodecamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FreeCodecamp')); <ide> ``` <ide> <ide> Your regex should not match the string `Free Code Camp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(!fccRegex.test('Free Code Camp')); <ide> ``` <ide> <ide> Your regex should match the string `FreeCOdeCamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FreeCOdeCamp')); <ide> ``` <ide> <ide> Your regex should not match the string `FCC` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(!fccRegex.test('FCC')); <ide> ``` <ide> <ide> Your regex should match the string `FrEeCoDeCamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FrEeCoDeCamp')); <ide> ``` <ide> <ide> Your regex should match the string `FrEeCodECamp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FrEeCodECamp')); <ide> ``` <ide> <ide> Your regex should match the string `FReeCodeCAmp` <ide> <ide> ```js <add>fccRegex.lastIndex = 0; <ide> assert(fccRegex.test('FReeCodeCAmp')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-a-literal-string-with-different-possibilities.md <ide> Complete the regex `petRegex` to match the pets `dog`, `cat`, `bird`, or `fish`. <ide> Your regex `petRegex` should return `true` for the string `John has a pet dog.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(petRegex.test('John has a pet dog.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `false` for the string `Emma has a pet rock.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(!petRegex.test('Emma has a pet rock.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `true` for the string `Emma has a pet bird.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(petRegex.test('Emma has a pet bird.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `true` for the string `Liz has a pet cat.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(petRegex.test('Liz has a pet cat.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `false` for the string `Kara has a pet dolphin.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(!petRegex.test('Kara has a pet dolphin.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `true` for the string `Alice has a pet fish.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(petRegex.test('Alice has a pet fish.')); <ide> ``` <ide> <ide> Your regex `petRegex` should return `false` for the string `Jimmy has a pet computer.` <ide> <ide> ```js <add>petRegex.lastIndex = 0; <ide> assert(!petRegex.test('Jimmy has a pet computer.')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-beginning-string-patterns.md <ide> assert(calRegex.flags == ''); <ide> Your regex should match the string `Cal` at the beginning of the string. <ide> <ide> ```js <add>calRegex.lastIndex = 0; <ide> assert(calRegex.test('Cal and Ricky both like racing.')); <ide> ``` <ide> <ide> Your regex should not match the string `Cal` in the middle of a string. <ide> <ide> ```js <add>calRegex.lastIndex = 0; <ide> assert(!calRegex.test('Ricky and Cal both like racing.')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-ending-string-patterns.md <ide> assert(lastRegex.flags == ''); <ide> You should match `caboose` at the end of the string `The last car on a train is the caboose` <ide> <ide> ```js <add>lastRegex.lastIndex = 0; <ide> assert(lastRegex.test('The last car on a train is the caboose')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-literal-strings.md <ide> Complete the regex `waldoRegex` to find `"Waldo"` in the string `waldoIsHiding` <ide> Your regex `waldoRegex` should find the string `Waldo` <ide> <ide> ```js <add>waldoRegex.lastIndex = 0; <ide> assert(waldoRegex.test(waldoIsHiding)); <ide> ``` <ide> <ide> Your regex `waldoRegex` should not search for anything else. <ide> <ide> ```js <add>waldoRegex.lastIndex = 0; <ide> assert(!waldoRegex.test('Somewhere is hiding in this text.')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.md <ide> assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null); <ide> Your regex should not match the string `astronaut` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(!pwRegex.test('astronaut')); <ide> ``` <ide> <ide> Your regex should not match the string `banan1` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(!pwRegex.test('banan1')); <ide> ``` <ide> <ide> Your regex should match the string `bana12` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(pwRegex.test('bana12')); <ide> ``` <ide> <ide> Your regex should match the string `abc123` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(pwRegex.test('abc123')); <ide> ``` <ide> <ide> Your regex should not match the string `12345` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(!pwRegex.test('12345')); <ide> ``` <ide> <ide> Your regex should match the string `8pass99` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(pwRegex.test('8pass99')); <ide> ``` <ide> <ide> Your regex should not match the string `1a2bcde` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(!pwRegex.test('1a2bcde')); <ide> ``` <ide> <ide> Your regex should match the string `astr1on11aut` <ide> <ide> ```js <add>pwRegex.lastIndex = 0; <ide> assert(pwRegex.test('astr1on11aut')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/restrict-possible-usernames.md <ide> Change the regex `userCheck` to fit the constraints listed above. <ide> Your regex should match the string `JACK` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('JACK')); <ide> ``` <ide> <ide> Your regex should not match the string `J` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('J')); <ide> ``` <ide> <ide> Your regex should match the string `Jo` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('Jo')); <ide> ``` <ide> <ide> Your regex should match the string `Oceans11` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('Oceans11')); <ide> ``` <ide> <ide> Your regex should match the string `RegexGuru` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('RegexGuru')); <ide> ``` <ide> <ide> Your regex should not match the string `007` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('007')); <ide> ``` <ide> <ide> Your regex should not match the string `9` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('9')); <ide> ``` <ide> <ide> Your regex should not match the string `A1` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('A1')); <ide> ``` <ide> <ide> Your regex should not match the string `BadUs3rnam3` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('BadUs3rnam3')); <ide> ``` <ide> <ide> Your regex should match the string `Z97` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('Z97')); <ide> ``` <ide> <ide> Your regex should not match the string `c57bT3` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('c57bT3')); <ide> ``` <ide> <ide> Your regex should match the string `AB1` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(userCheck.test('AB1')); <ide> ``` <ide> <ide> Your regex should not match the string `J%4` <ide> <ide> ```js <add>userCheck.lastIndex = 0; <ide> assert(!userCheck.test('J%4')) <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/reuse-patterns-using-capture-groups.md <ide> assert(reRegex.source.match(/\\1|\\2/g).length >= 2); <ide> Your regex should match the string `42 42 42`. <ide> <ide> ```js <add>reRegex.lastIndex = 0; <ide> assert(reRegex.test('42 42 42')); <ide> ``` <ide> <ide> Your regex should match the string `100 100 100`. <ide> <ide> ```js <add>reRegex.lastIndex = 0; <ide> assert(reRegex.test('100 100 100')); <ide> ``` <ide> <ide> assert.equal('42 42'.match(reRegex.source), null); <ide> Your regex should not match the string `101 102 103`. <ide> <ide> ```js <add>reRegex.lastIndex = 0; <ide> assert(!reRegex.test('101 102 103')); <ide> ``` <ide> <ide> Your regex should not match the string `1 2 3`. <ide> <ide> ```js <add>reRegex.lastIndex = 0; <ide> assert(!reRegex.test('1 2 3')); <ide> ``` <ide> <ide> Your regex should match the string `10 10 10`. <ide> <ide> ```js <add>reRegex.lastIndex = 0; <ide> assert(reRegex.test('10 10 10')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.md <ide> assert(haRegex.source.match(/{.*?}/).length > 0); <ide> Your regex should not match the string `Hazzah` <ide> <ide> ```js <add>haRegex.lastIndex = 0; <ide> assert(!haRegex.test('Hazzah')); <ide> ``` <ide> <ide> Your regex should not match the string `Hazzzah` <ide> <ide> ```js <add>haRegex.lastIndex = 0; <ide> assert(!haRegex.test('Hazzzah')); <ide> ``` <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-upper-and-lower-number-of-matches.md <ide> assert(ohRegex.source.match(/{.*?}/).length > 0); <ide> Your regex should not match the string `Ohh no` <ide> <ide> ```js <add>ohRegex.lastIndex = 0; <ide> assert(!ohRegex.test('Ohh no')); <ide> ``` <ide> <ide> assert('Ohhhhhh no'.match(ohRegex)[0].length === 10); <ide> Your regex should not match the string `Ohhhhhhh no` <ide> <ide> ```js <add>ohRegex.lastIndex = 0; <ide> assert(!ohRegex.test('Ohhhhhhh no')); <ide> ``` <ide>
11
PHP
PHP
serialize values in array cache store
7b7861d0df900520182764db7943049327ee554d
<ide><path>src/Illuminate/Cache/ArrayStore.php <ide> public function get($key) <ide> return; <ide> } <ide> <del> return $item['value']; <add> return unserialize($item['value']); <ide> } <ide> <ide> /** <ide> public function get($key) <ide> public function put($key, $value, $seconds) <ide> { <ide> $this->storage[$key] = [ <del> 'value' => $value, <add> 'value' => serialize($value), <ide> 'expiresAt' => $this->calculateExpiration($seconds), <ide> ]; <ide> <ide> public function increment($key, $value = 1) <ide> { <ide> if ($existing = $this->get($key)) { <ide> return tap(((int) $existing) + $value, function ($incremented) use ($key) { <del> $this->storage[$key]['value'] = $incremented; <add> $this->storage[$key]['value'] = serialize($incremented); <ide> }); <ide> } <ide> <ide><path>tests/Cache/CacheArrayStoreTest.php <ide> public function testAnotherOwnerCanForceReleaseALock() <ide> <ide> $this->assertTrue($wannabeOwner->acquire()); <ide> } <add> <add> public function testValuesAreNotStoredByReference() <add> { <add> $store = new ArrayStore; <add> $object = new \stdClass; <add> $object->foo = true; <add> <add> $store->put('object', $object, 10); <add> $object->bar = true; <add> <add> $this->assertObjectNotHasAttribute('bar', $store->get('object')); <add> } <ide> }
2
Python
Python
use `usegmt` flag in formatdate
8a160d5de1763614ab1a86107e779b0afd151ade
<ide><path>django/utils/http.py <ide> def http_date(epoch_seconds=None): <ide> <ide> Outputs a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'. <ide> """ <del> rfcdate = formatdate(epoch_seconds) <del> return '%s GMT' % rfcdate[:25] <add> return formatdate(epoch_seconds, usegmt=True) <ide> <ide> def parse_http_date(date): <ide> """
1
Javascript
Javascript
move plugins before environment
b46da215894747641abde7d0668ea663508dc527
<ide><path>lib/WebpackOptionsApply.js <ide> WebpackOptionsApply.prototype.constructor = WebpackOptionsApply; <ide> <ide> WebpackOptionsApply.prototype.process = function(options, compiler) { <ide> var ExternalsPlugin; <del> compiler.context = options.context; <del> if(options.plugins && Array.isArray(options.plugins)) { <del> compiler.apply.apply(compiler, options.plugins); <del> } <ide> compiler.outputPath = options.output.path; <ide> compiler.recordsInputPath = options.recordsInputPath || options.recordsPath; <ide> compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath; <ide><path>lib/webpack.js <ide> function webpack(options, callback) { <ide> new WebpackOptionsDefaulter().process(options); <ide> <ide> compiler = new Compiler(); <add> compiler.context = options.context; <add> compiler.options = options; <ide> new NodeEnvironmentPlugin().apply(compiler); <add> if(options.plugins && Array.isArray(options.plugins)) { <add> compiler.apply.apply(compiler, options.plugins); <add> } <ide> compiler.applyPlugins("environment"); <ide> compiler.applyPlugins("after-environment"); <del> compiler.options = options; <ide> compiler.options = new WebpackOptionsApply().process(options, compiler); <ide> } else { <ide> throw new Error("Invalid argument: options");
2
Ruby
Ruby
require object/blank not used
27238ad1b8f25c424ba9d45f4de6d40473c602d0
<ide><path>railties/lib/rails/generators/rails/resource/resource_generator.rb <ide> require 'rails/generators/resource_helpers' <ide> require 'rails/generators/rails/model/model_generator' <del>require 'active_support/core_ext/object/blank' <ide> <ide> module Rails <ide> module Generators
1
Mixed
Ruby
add type caster to `runtimereflection#alias_name`
8d64cd86db1bc5e1ad119d13eb14f94726a0765f
<ide><path>activerecord/CHANGELOG.md <add>* Add type caster to `RuntimeReflection#alias_name` <add> <add> Fixes #28959. <add> <add> *Jon Moss* <add> <ide> * Deprecate `supports_statement_cache?`. <ide> <ide> *Ryuta Kamizono* <ide><path>activerecord/lib/active_record/reflection.rb <ide> def alias_candidate(name) <ide> end <ide> <ide> def alias_name <del> Arel::Table.new(table_name) <add> Arel::Table.new(table_name, type_caster: klass.type_caster) <ide> end <ide> <ide> def all_includes; yield; end <ide><path>activerecord/test/cases/enum_test.rb <ide> require "cases/helper" <add>require "models/author" <ide> require "models/book" <ide> <ide> class EnumTest < ActiveRecord::TestCase <del> fixtures :books <add> fixtures :books, :authors <ide> <ide> setup do <add> @author = authors(:david) <ide> @book = books(:awdr) <ide> end <ide> <ide> class EnumTest < ActiveRecord::TestCase <ide> assert_not_equal @book, Book.where(status: :written).first <ide> assert_equal @book, Book.where(status: [:published]).first <ide> assert_not_equal @book, Book.where(status: [:written]).first <add> assert_not @author.unpublished_books.include?(@book) <ide> assert_not_equal @book, Book.where.not(status: :published).first <ide> assert_equal @book, Book.where.not(status: :written).first <ide> end <ide><path>activerecord/test/models/author.rb <ide> def ratings <ide> has_many :tags_with_primary_key, through: :posts <ide> <ide> has_many :books <add> has_many :unpublished_books, -> { where(status: [:proposed, :written]) }, class_name: "Book" <ide> has_many :subscriptions, through: :books <ide> has_many :subscribers, -> { order("subscribers.nick") }, through: :subscriptions <ide> has_many :distinct_subscribers, -> { select("DISTINCT subscribers.*").order("subscribers.nick") }, through: :subscriptions, source: :subscriber <ide><path>activerecord/test/models/book.rb <ide> class Book < ActiveRecord::Base <del> has_many :authors <add> belongs_to :author <ide> <ide> has_many :citations, foreign_key: "book1_id" <ide> has_many :references, -> { distinct }, through: :citations, source: :reference_of
5
Ruby
Ruby
use the enumerable implementation of include?
4c4193e905ed87faf58d9f41f1724f5353943e93
<ide><path>Library/Homebrew/dependencies.rb <ide> def each(*args, &block) <ide> end <ide> <ide> def <<(o) <del> @deps << o unless @deps.include? o <add> @deps << o unless include?(o) <ide> self <ide> end <ide>
1
PHP
PHP
fix sqlserverschema tests
a9f0bd729f39fa7a09fd569a7265cc08d98017bf
<ide><path>tests/TestCase/Database/Schema/SqlserverSchemaTest.php <ide> public function testAddConstraintSql() <ide> ]); <ide> <ide> $expected = <<<SQL <del>ALTER TABLE [posts] ADD CONSTRAINT [category_fk] FOREIGN KEY (]category_id], [category_name]) REFERENCES [categories] ([id], [name]) ON UPDATE CASCADE ON DELETE CASCADE; <add>ALTER TABLE [posts] ADD CONSTRAINT [category_fk] FOREIGN KEY ([category_id], [category_name]) REFERENCES [categories] ([id], [name]) ON UPDATE CASCADE ON DELETE CASCADE; <ide> SQL; <ide> $result = $table->addConstraintSql($connection); <ide> $this->assertCount(2, $result); <ide> public function testDropConstraintSql() <ide> ]); <ide> <ide> $expected = <<<SQL <del>ALTER TABLE [posts] DROP FOREIGN KEY [author_fk]; <add>ALTER TABLE [posts] DROP CONSTRAINT [author_fk]; <ide> SQL; <ide> $result = $table->dropConstraintSql($connection); <ide> $this->assertCount(1, $result);
1
Mixed
Ruby
reset instance variables after each request
054fa96bacad418a776983916f857ffd708100ae
<ide><path>actionpack/CHANGELOG.md <add>* Instance variables set in requests in a `ActionController::TestCase` are now cleared before the next request <ide> <add> This means if you make multiple requests in the same test, instance variables set in the first request will <add> not persist into the second one. (It's not recommended to make multiple requests in the same test.) <add> <add> *Alex Ghiculescu* <ide> <ide> Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionpack/CHANGELOG.md) for previous changes. <ide><path>actionpack/lib/action_controller/metal/testing.rb <ide> module ActionController <ide> module Testing <ide> # Behavior specific to functional tests <ide> module Functional # :nodoc: <add> def clear_instance_variables_between_requests <add> if @_ivars <add> new_ivars = instance_variables - @_ivars <add> new_ivars.each { |ivar| remove_instance_variable(ivar) } <add> end <add> <add> @_ivars = instance_variables <add> end <add> <ide> def recycle! <ide> @_url_options = nil <ide> self.formats = nil <ide><path>actionpack/lib/action_controller/test_case.rb <ide> def head(action, **args) <ide> # prefer using #get, #post, #patch, #put, #delete and #head methods <ide> # respectively which will make tests more expressive. <ide> # <add> # It's not recommended to make more than one request in the same test. Instance <add> # variables that are set in one request will not persist to the next request, <add> # but it's not guaranteed that all Rails internal state will be reset. Prefer <add> # ActionDispatch::IntegrationTest for making multiple requests in the same test. <add> # <ide> # Note that the request method is not verified. <ide> def process(action, method: "GET", params: nil, session: nil, body: nil, flash: {}, format: nil, xhr: false, as: nil) <ide> check_required_ivars <add> @controller.clear_instance_variables_between_requests <ide> <ide> action = +action.to_s <ide> http_method = method.to_s.upcase <ide><path>actionpack/test/controller/test_case_test.rb <ide> def boom <ide> raise "boom!" <ide> end <ide> <add> def increment_count <add> @counter ||= 0 <add> @counter += 1 <add> render plain: @counter <add> end <add> <ide> private <ide> def generate_url(opts) <ide> url_for(opts.merge(action: "test_uri")) <ide> def test_parsed_body_with_as_option <ide> post :render_json, body: { foo: "heyo" }.to_json, as: :json <ide> assert_equal({ "foo" => "heyo" }, response.parsed_body) <ide> end <add> <add> def test_reset_instance_variables_after_each_request <add> get :increment_count <add> assert_equal "1", response.body <add> <add> get :increment_count <add> assert_equal "1", response.body <add> end <add> <add> def test_can_read_instance_variables_before_or_after_request <add> assert_nil @controller.instance_variable_get(:@counter) <add> <add> get :increment_count <add> assert_equal "1", response.body <add> assert_equal 1, @controller.instance_variable_get(:@counter) <add> <add> get :increment_count <add> assert_equal "1", response.body <add> assert_equal 1, @controller.instance_variable_get(:@counter) <add> end <add> <add> def test_ivars_are_not_reset_if_they_are_given_a_value_before_any_requests <add> @controller.instance_variable_set(:@counter, 3) <add> <add> get :increment_count <add> assert_equal "4", response.body <add> assert_equal 4, @controller.instance_variable_get(:@counter) <add> <add> get :increment_count <add> assert_equal "5", response.body <add> assert_equal 5, @controller.instance_variable_get(:@counter) <add> <add> get :increment_count <add> assert_equal "6", response.body <add> assert_equal 6, @controller.instance_variable_get(:@counter) <add> end <add> <add> def test_ivars_are_reset_if_they_are_given_a_value_after_some_requests <add> get :increment_count <add> assert_equal "1", response.body <add> assert_equal 1, @controller.instance_variable_get(:@counter) <add> <add> @controller.instance_variable_set(:@counter, 3) <add> <add> get :increment_count <add> assert_equal "1", response.body <add> assert_equal 1, @controller.instance_variable_get(:@counter) <add> end <ide> end <ide> <ide> class ResponseDefaultHeadersTest < ActionController::TestCase
4
Ruby
Ruby
modify test to correctly pass attributes hash
c91a44d5407a406ddd310f06a54327b1e3799e59
<ide><path>activerecord/test/cases/persistence_test.rb <ide> def test_create_many <ide> <ide> def test_create_columns_not_equal_attributes <ide> topic = Topic.instantiate( <del> "attributes" => { <del> "title" => "Another New Topic", <del> "does_not_exist" => "test" <del> } <add> "title" => "Another New Topic", <add> "does_not_exist" => "test" <ide> ) <add> topic = topic.dup # reset @new_record <ide> assert_nothing_raised { topic.save } <add> assert topic.persisted? <add> assert_equal "Another New Topic", topic.reload.title <ide> end <ide> <ide> def test_create_through_factory_with_block <ide> def test_update_columns_not_equal_attributes <ide> topic_reloaded = Topic.instantiate(topic.attributes.merge("does_not_exist" => "test")) <ide> topic_reloaded.title = "A New Topic" <ide> assert_nothing_raised { topic_reloaded.save } <add> assert topic_reloaded.persisted? <add> assert_equal "A New Topic", topic_reloaded.reload.title <ide> end <ide> <ide> def test_update_for_record_with_only_primary_key
1
Mixed
Ruby
add rename_index to change_table
1a782b2b634cadbea2ae194848e97ca0ecdbce30
<ide><path>activerecord/CHANGELOG.md <ide> ## Rails 4.0.0 (unreleased) ## <ide> <add>* `rename_index` can be used inside a `change_table` block. <add> <add> change_table :accounts do |t| <add> t.rename_index :user_id, :account_id <add> end <add> <add> *Jarek Radosz* <add> <ide> * `#pluck` can be used on a relation with `select` clause. Fix #7551 <ide> <ide> Example: <ide><path>activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb <ide> def native <ide> # change_table :table do |t| <ide> # t.column <ide> # t.index <add> # t.rename_index <ide> # t.timestamps <ide> # t.change <ide> # t.change_default <ide> def index_exists?(column_name, options = {}) <ide> @base.index_exists?(@table_name, column_name, options) <ide> end <ide> <add> # Renames the given index on the table. <add> # <add> # t.rename_index(:user_id, :account_id) <add> def rename_index(index_name, new_index_name) <add> @base.rename_index(@table_name, index_name, new_index_name) <add> end <add> <ide> # Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps <ide> # <ide> # t.timestamps <ide><path>activerecord/test/cases/migration/change_table_test.rb <ide> def test_index_exists_with_options <ide> end <ide> end <ide> <add> def test_rename_index_renames_index <add> with_change_table do |t| <add> @connection.expect :rename_index, nil, [:delete_me, :bar, :baz] <add> t.rename_index :bar, :baz <add> end <add> end <add> <ide> def test_change_changes_column <ide> with_change_table do |t| <ide> @connection.expect :change_column, nil, [:delete_me, :bar, :string, {}]
3
Text
Text
fix typo in globals.md
3b3632054001639bcaf12a9bd579e45fc485bbf9
<ide><path>doc/api/globals.md <ide> added: v15.0.0 <ide> <ide> The `'abort'` event is emitted when the `abortController.abort()` method <ide> is called. The callback is invoked with a single object argument with a <del>single `type` propety set to `'abort'`: <add>single `type` property set to `'abort'`: <ide> <ide> ```js <ide> const ac = new AbortController();
1
Go
Go
fix default shm size in test
4354b348ad6f9a585c57d37147c2a893a2d873da
<ide><path>integration-cli/docker_api_containers_test.go <ide> func (s *DockerSuite) TestPostContainersCreateShmSizeZero(c *check.C) { <ide> } <ide> <ide> func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check.C) { <add> var defaultSHMSize int64 = 67108864 <ide> config := map[string]interface{}{ <ide> "Image": "busybox", <ide> "Cmd": "mount", <ide> func (s *DockerSuite) TestPostContainersCreateShmSizeHostConfigOmitted(c *check. <ide> var containerJSON types.ContainerJSON <ide> c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil) <ide> <del> c.Assert(*containerJSON.HostConfig.ShmSize, check.Equals, runconfig.DefaultSHMSize) <add> c.Assert(*containerJSON.HostConfig.ShmSize, check.Equals, defaultSHMSize) <ide> <ide> out, _ := dockerCmd(c, "start", "-i", containerJSON.ID) <ide> shmRegexp := regexp.MustCompile(`shm on /dev/shm type tmpfs(.*)size=65536k`)
1
Text
Text
update changelog for 2.10.3
5c0348ef1b45834399890b99e67eb7b522c2c558
<ide><path>CHANGELOG.md <ide> Changelog <ide> ========= <ide> <add>### 2.10.3 [See full changelog](https://gist.github.com/ichernev/f264b9bed5b00f8b1b7f) <add> <add>* add `moment.fn.to` and `moment.fn.toNow` (similar to `from` and `fromNow`) <add>* new locales (Sinhalese (si), Montenegrin (me), Javanese (ja)) <add>* performance improvements <add> <ide> ### 2.10.2 <ide> <ide> * fixed moment-with-locales in browser env caused by esperanto change
1
Go
Go
add typo in remove all. ensure tmpdir is removed
9de45904980dba224e8ab133f12cfc53835e2dd4
<ide><path>server.go <ide> func (srv *Server) ImageExport(name string, out io.Writer) error { <ide> if err != nil { <ide> return err <ide> } <add> defer os.RemoveAll(tempdir) <add> <ide> utils.Debugf("Serializing %s", name) <ide> <ide> rootRepo := srv.runtime.repositories.Repositories[name] <ide> func (srv *Server) ImageExport(name string, out io.Writer) error { <ide> if err := os.Mkdir(tmpImageDir, os.ModeDir); err != nil { <ide> return err <ide> } <del> defer os.RemoveAll(tempdir) <add> defer os.RemoveAll(tmpImageDir) <ide> <ide> var version = "1.0" <ide> var versionBuf = []byte(version) <ide> func (srv *Server) ImageExport(name string, out io.Writer) error { <ide> if err != nil { <ide> return err <ide> } <del> defer os.RemoveAll(tempdir) <ide> <ide> if _, err := io.Copy(out, fs); err != nil { <ide> return err
1
Javascript
Javascript
fix naming opaqueobjects
736f30b3f50b783df06c6d96ee8fd9b4354d98df
<ide><path>src/renderers/WebGLRenderer.js <ide> THREE.WebGLRenderer = function ( parameters ) { <ide> _clearColor = new THREE.Color( 0x000000 ), <ide> _clearAlpha = 0; <ide> <del> var OpaqueObjects = []; <add> var opaqueObjects = []; <ide> var transparentObjects = []; <ide> var _sortObjects = true; <ide> <ide> THREE.WebGLRenderer = function ( parameters ) { <ide> // set matrices for regular objects (frustum culled) <ide> <ide> <del> OpaqueObjects.length = 0; <add> opaqueObjects.length = 0; <ide> transparentObjects.length = 0; <ide> _sortObjects = this.sortObjects; <ide> <ide> projectObject(scene,scene,camera); <ide> <ide> if ( this.sortObjects ) { <ide> <del> OpaqueObjects.sort( painterSortStable ); <add> opaqueObjects.sort( painterSortStable ); <ide> transparentObjects.sort( reversePainterSortStable ); <ide> <ide> } <ide> THREE.WebGLRenderer = function ( parameters ) { <ide> this.setDepthWrite( material.depthWrite ); <ide> setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits ); <ide> <del> renderObjects( OpaqueObjects, camera, lights, fog, true, material ); <add> renderObjects( opaqueObjects, camera, lights, fog, true, material ); <ide> renderObjects( transparentObjects, camera, lights, fog, true, material ); <ide> renderObjectsImmediate( scene.__webglObjectsImmediate, '', camera, lights, fog, false, material ); <ide> <ide> THREE.WebGLRenderer = function ( parameters ) { <ide> <ide> this.setBlending( THREE.NoBlending ); <ide> <del> renderObjects( OpaqueObjects, camera, lights, fog, false, material ); <add> renderObjects( opaqueObjects, camera, lights, fog, false, material ); <ide> renderObjectsImmediate( scene.__webglObjectsImmediate, 'opaque', camera, lights, fog, false, material ); <ide> <ide> // transparent pass (back-to-front order) <ide> THREE.WebGLRenderer = function ( parameters ) { <ide> <ide> } else { <ide> <del> OpaqueObjects.push(webglObject); <add> opaqueObjects.push(webglObject); <ide> <ide> } <ide>
1
PHP
PHP
fix docblock and typo
b5e991d15f857ee86a4532a4249813f7c3dd779b
<ide><path>src/Illuminate/Database/Eloquent/Model.php <ide> public function getKey() <ide> /** <ide> * Get the queueable identity for the entity. <ide> * <del> * @var mixed <add> * @return mixed <ide> */ <ide> public function getQueueableId() <ide> { <ide><path>src/Illuminate/Pipeline/Hub.php <ide> public function pipeline($name, Closure $callback) <ide> * @param string|null $pipeline <ide> * @return mixed <ide> */ <del> public function pipe($object, $pipieline = null) <add> public function pipe($object, $pipeline = null) <ide> { <del> $pipieline = $pipieline ?: 'default'; <add> $pipeline = $pipeline ?: 'default'; <ide> <ide> return call_user_func( <del> $this->pipelines[$pipieline], new Pipeline($this->container), $object <add> $this->pipelines[$pipeline], new Pipeline($this->container), $object <ide> ); <ide> } <ide> <ide><path>src/Illuminate/Pipeline/Pipeline.php <ide> class Pipeline implements PipelineContract { <ide> /** <ide> * Create a new class instance. <ide> * <del> * @param \Closure $app <add> * @param \Illuminate\Contracts\Container\Container $container <ide> * @return void <ide> */ <ide> public function __construct(Container $container)
3
Text
Text
add readme arabic
4bd3b3c41239b7070a65581dda25019d658384d1
<ide><path>docs/i18n-languages/arabic/README.md <add>![freeCodeCamp.org Social Banner](https://s3.amazonaws.com/freecodecamp/wide-social-banner.png) <add>[![Build Status](https://travis-ci.org/freeCodeCamp/freeCodeCamp.svg?branch=staging)](https://travis-ci.org/freeCodeCamp/freeCodeCamp) <add>[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com) <add>[![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](http://www.firsttimersonly.com/) <add>[![Known Vulnerabilities](https://snyk.io/test/github/freecodecamp/freecodecamp/badge.svg)](https://snyk.io/test/github/freecodecamp/freecodecamp) <add> <add><div dir="rtl" style="direction: rtl" markdown="1"> <add> <add>## مرحبًا بك في شفرة مصدر freeCodeCamp.org ومنهج مفتوح المصدر! <add> <add>[freeCodeCamp.org](https://www.freecodecamp.org) هو مجتمع ودود حيث يمكنك تعلم البرمجة مجانًا. تدار من قبل [منظمة غير ربحية 501 (c) (3)](https://donate.freecodecamp.org) وبدعم من الجهات المانحة لمساعدة ملايين البالغين على التحول إلى تكنولوجيا المعلومات. لقد ساعد مجتمعنا بالفعل أكثر من 10000 شخص في الحصول على وظيفتهم الأولى كمطورين. <add> <add>برنامج تطوير الويب الكامل الخاص بنا مجاني تمامًا ويتيح لك الدراسة بالسرعة التي تناسبك. لدينا الآلاف من تحديات التشفير التفاعلية لمساعدتك على تطوير مهاراتك. <add> <add>## محتويات <add> <add>- [الشهادات](#certifications) <add>- [منصة التعلم](#the-learning-platform) <add>- [الإبلاغ عن خطأ](#found-a-bug) <add>- [الإبلاغ عن مشكلة أمنية](#found-a-security-issue) <add>- [للمساهمة](#contributing) <add>- [رخصة](#license) <add> <add>### الشهادات <add> <add>يقدم freeCodeCamp.org العديد من شهادات المطورين المجانية. تتضمن كل من هذه الشهادات إنشاءًا إلزاميًا لـ 5 مشاريع تطبيقات ويب ، بالإضافة إلى المئات من تحديات التشفير الاختيارية لمساعدتك في الاستعداد لهذه المشاريع. نحن نقدر أن كل شهادة ستستغرق حوالي 300 ساعة للمبرمج المبتدئ. <add> <add>يحتوي كل مشروع من هذه المشاريع الـ 30 في برنامج freeCodeCamp.org على سيناريوهات استخدام رشيقة واختبارات آلية. تساعدك هذه الخطوات في بناء مشروعك تدريجيًا وتضمن التحقق من صحة جميع سيناريوهات المستخدم قبل إرساله. <add> <add>يمكنك استخراج مجموعات الاختبار هذه عبر [freeCodeCamp CDN](https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js). بمعنى آخر ، يمكنك بناء هذه المشاريع على مواقع ويب مثل CodePen و Glitch - أو حتى على بيئة التطوير المحلية على جهاز الكمبيوتر الخاص بك. <add> <add>بمجرد الحصول على الشهادة ، يمكنك الاحتفاظ بها مدى الحياة. يمكنك الوصول إليها من ملفك الشخصي على LinkedIn أو السيرة الذاتية. عندما ينقر أرباب العمل المحتملين أو العملاء المستقلون على الرابط ، فإنهم يرون شهادتك التي تم التحقق منها. <add> <add>الاستثناء الوحيد لهذه القاعدة سيكون في حال اكتشفنا انتهاكات [سياسة الصدق الأكاديمي](https://www.freecodecamp.org/academic-honesty). عندما نقبض على الأشخاص الذين يسرقون بشكل لا لبس فيه (إرسال التعليمات البرمجية أو مشروعات الأشخاص الآخرين دون الاستشهاد بهم) ، نقوم بما يجب على جميع المؤسسات التعليمية الصارمة القيام به ، فإننا نلغي شهاداتهم ونحظر هؤلاء الأشخاص. <add> <add>فيما يلي شهاداتنا الست الرئيسية: <add> <add>#### 1. شهادة تصميم الويب سريع الاستجابة <add> <add>- [مقدمة عن HTML و HTML5](https://learn.freecodecamp.org/responsive-web-design/basic-html-and-html5) <add>- [مقدمة في CSS](https://learn.freecodecamp.org/responsive-web-design/basic-css) <add>- [التصميم المرئي التطبيقي](https://learn.freecodecamp.org/responsive-web-design/applied-visual-design) <add>- [إمكانية الوصول التطبيقية](https://learn.freecodecamp.org/responsive-web-design/applied-accessibility) <add>- [مبادئ تصميم الويب سريع الاستجابة](https://learn.freecodecamp.org/responsive-web-design/responsive-web-design-principles) <add>- [CSS Flexbox](https://learn.freecodecamp.org/responsive-web-design/css-flexbox) <add>- [CSS Grid](https://learn.freecodecamp.org/responsive-web-design/css-grid) <add> <br /> <add> <br /> <add> **المشاريع**: صفحة الإشادة ، نموذج المسح ، صفحة الترويج ، صفحة التوثيق الفني ، الملف الشخصي. <add> <add>#### 2. اعتماد خوارزميات جافا سكريبت وهياكل البيانات <add> <add>- [مقدمة لجافا سكريبت](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript) <add>- [ES6](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6) <add>- [التعبيرات العادية](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions) <add>- [تصحيح الأخطاء](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging) <add>- [مقدمة في هياكل البيانات](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures) <add>- [مقدمة في الخوارزميات](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting) <add>- [البرمجة الشيئية](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/object-oriented-programming) <add>- [البرمجة الوظيفية](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming) <add>- [الخوارزميات - المستوى المتوسط](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting) <add> <br /> <add> <br /> <add> **المشاريع**: مدقق Palindrome ، محول الأرقام الرومانية ، تشفير قيصر ، التحقق من رقم الهاتف ، تسجيل النقدية <add> <add>#### 3. شهادة مكتبة الواجهة الأمامية <add> <add>- [Bootstrap](https://learn.freecodecamp.org/front-end-libraries/bootstrap) <add>- [jQuery](https://learn.freecodecamp.org/front-end-libraries/jquery) <add>- [Sass](https://learn.freecodecamp.org/front-end-libraries/sass) <add>- [React](https://learn.freecodecamp.org/front-end-libraries/react) <add>- [Redux](https://learn.freecodecamp.org/front-end-libraries/redux) <add>- [React و Redux](https://learn.freecodecamp.org/front-end-libraries/react-and-redux) <add> <br /> <add> <br /> <add> **المشاريع**: مولد الاقتباسات العشوائية ، معاينة مستندات Markdown ، آلة الطبل ، آلة حاسبة JavaScript ، ساعة Pomodoro. <add> <add>#### 4. شهادة تصور البيانات <add> <add>- [تصور البيانات مع D3](https://learn.freecodecamp.org/data-visualization/data-visualization-with-d3) <add>- [API JSON و Ajax](https://learn.freecodecamp.org/data-visualization/json-apis-and-ajax) <add> <br /> <add> <br /> <add> **المشاريع**: مخطط شريطي ، مخطط مبعثر ، خريطة حرارية ، خريطة محيطية ، مخطط شوكي <add> <add>#### 5. شهادات الواجهة والخدمات الصغيرة <add> <add>- [إدارة التبعية مع Npm](https://learn.freecodecamp.org/apis-and-microservices/managing-packages-with-npm) <add>- [مقدمة عن Node و Express](https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express) <add>- [MongoDB و Mongoose](https://learn.freecodecamp.org/apis-and-microservices/mongodb-and-mongoose) <add> <br /> <add> <br /> <add> **المشاريع**: الخدمات الصغيرة على مدار الساعة ، محلل رأس الطلب ، اختصار عنوان URL ، تتبع التمرين ، محلل البيانات الوصفية. <add> <add>#### 6. شهادة أمن المعلومات وضمان الجودة <add> <add>- [أمن المعلومات مع HelmetJS](https://learn.freecodecamp.org/information-security-and-quality-assurance/information-security-with-helmetjs) <add>- [Chai الجودة والاختبار مع تشاي](https://learn.freecodecamp.org/information-security-and-quality-assurance/quality-assurance-and-testing-with-chai) <add>- [Node و Express المتقدم](https://learn.freecodecamp.org/information-security-and-quality-assurance/advanced-node-and-express) <add> <br /> <add> <br /> <add> **المشاريع**: محول إمبريالي متري ، تتبع المشكلات ، مكتبة شخصية ، مدقق أسعار الأسهم ، منتدى مناقشة مجهول. <add> <add>#### شهادة تطوير كاملة. <add> <add>بمجرد حصولك على هذه الشهادات الست ، يمكنك المطالبة بشهادة مطور المكدس الكامل freeCodeCamp.org. هذا التمييز النهائي يعني أنك قد أكملت حوالي 1800 ساعة من البرمجة مع مجموعة واسعة من أدوات تطوير الويب. <add> <add>#### الشهادات القديمة <add> <add>لدينا أيضًا 3 شهادات قديمة من برنامج 2015 ، والتي لا تزال متاحة. ستظل جميع المشاريع المطلوبة لهذه الشهادات القديمة متاحة على freeCodeCamp.org. <add> <add>- شهادة مطور الواجهة الأمامية السابق <add>- شهادة تصور البيانات القديمة <add>- شهادة المطور الخلفي السابق <add> <add>### منصة التعلم <add> <add>يتم تنفيذ هذا الرمز مباشرة في [freeCodeCamp.org](https://www.freecodecamp.org). <add> <add>يمتلك مجتمعنا أيضًا: <add> <add>- [المنتدى](https://www.freecodecamp.org/forum) حيث يمكنك عادةً الحصول على مساعدة في البرمجة أو ملاحظات حول مشاريعك. <add>- قناة [YouTube](https://youtube.com/freecodecamp) مع دروس مجانية في Python و SQL و Android ومجموعة متنوعة من الموضوعات الأخرى. <add>- [تدوين صوتي](https://podcast.freecodecamp.org/) مع المناقشات التقنية حول التقنيات الجديدة والقصص الملهمة من المطورين. <add>- [مجموعات الدراسة المحلية](https://study-group-directory.freecodecamp.org/), تقع في جميع أنحاء العالم حيث يمكنك البرمجة معًا وجهًا لوجه. <add>- [دليل شامل يغطي آلاف الموضوعات المختلفة](https://guide.freecodecamp.org/) <add>- [أخبار](https://www.freecodecamp.org/news), مجانًا ومفتوحة المصدر وخالية من الإعلانات ، حيث يمكنك نشر مقالات مدونتك. <add>- [مجموعة الفيسبوك](https://www.facebook.com/groups/freeCodeCampEarth/permalink/428140994253892/) مع أكثر من 100000 عضو حول العالم. <add> <add>### [انضم إلى مجتمعنا هنا](https://www.freecodecamp.org/signin). <add> <add>### هل وجدت خطأ؟ <add> <add>إذا كنت تعتقد أنك عثرت على خطأ ، فاقرأ مقالة المساعدة أولاً [Help I've Found a Bug](https://www.freecodecamp.org/forum/t/how-to-report-a-bug/19543) واتبع تعليماته. إذا كنت متأكدًا من أن هذا خطأ جديد وأنك قد تحققت من أن المستخدمين الآخرين يواجهون المشكلة ، فقم بإنشاء "issue" جديدة على GitHub. تأكد من تضمين أكبر قدر ممكن من المعلومات حتى نتمكن من إعادة إنتاج الخطأ. <add> <add>### وجدت مشكلة أمنية؟ <add> <add>الرجاء عدم إنشاء "issue" على Github لأسباب أمنية. بدلاً من ذلك ، أرسل بريدًا إلكترونيًا إلى `security@freecodecamp.org` وسننظر في الأمر على الفور. <add> <add>### للمساهمة <add> <add>#### [يرجى اتباع هذه الخطوات للمساهمة](CONTRIBUTING.md). <add> <add>### رخصة <add> <add>Copyright © 2020 freeCodeCamp.org <add> <add>محتوى هذا المستودع محمي بواسطة التراخيص التالية: <add> <add>- البرنامج مرخص [BSD-3-Clause](LICENSE.md). <add>- مصادر التعلم لل [curriculum](/curriculum) و [guide](/guide) وكذلك الدلائل الفرعية مرخصة [CC-BY-SA-4.0](/curriculum/LICENSE.md). <add></div>
1
Mixed
Ruby
return sized enumerator from batches#find_each
13d2696c10726afecd393753fcac88c5a9907d8c
<ide><path>activerecord/CHANGELOG.md <del>* `find_in_batches` now returns an `Enumerator` that can calculate its size. <add><<<<<<< HEAD <add>* `find_in_batches`, `find_each` now <add> return an `Enumerator` that can calculate its size. <add>======= <add>* `find_in_batches`, `find_each`, `Result#each` now returns an `Enumerator` <add> that can calculate its size. <add>>>>>>>> 5863938... Return sized enumerator from Result#each <ide> <ide> See also #13938. <ide> <ide><path>activerecord/lib/active_record/relation/batches.rb <ide> def find_each(options = {}) <ide> records.each { |record| yield record } <ide> end <ide> else <del> enum_for :find_each, options <add> enum_for :find_each, options do <add> options[:start] ? where(table[primary_key].gteq(options[:start])).size : size <add> end <ide> end <ide> end <ide> <ide><path>activerecord/lib/active_record/result.rb <ide> def each <ide> if block_given? <ide> hash_rows.each { |row| yield row } <ide> else <del> hash_rows.to_enum <add> hash_rows.to_enum { @rows.size } <ide> end <ide> end <ide> <ide><path>activerecord/test/cases/batches_test.rb <ide> def test_each_should_return_an_enumerator_if_no_block_is_present <ide> end <ide> end <ide> <add> if Enumerator.method_defined? :size <add> def test_each_should_return_a_sized_enumerator <add> assert_equal 11, Post.find_each(:batch_size => 1).size <add> assert_equal 5, Post.find_each(:batch_size => 2, :start => 7).size <add> assert_equal 11, Post.find_each(:batch_size => 10_000).size <add> end <add> end <add> <ide> def test_each_enumerator_should_execute_one_query_per_batch <ide> assert_queries(@total + 1) do <ide> Post.find_each(:batch_size => 1).with_index do |post, index| <ide><path>activerecord/test/cases/result_test.rb <ide> def test_each_without_block_returns_an_enumerator <ide> assert_kind_of Integer, index <ide> end <ide> end <add> <add> if Enumerator.method_defined? :size <add> def test_each_without_block_returns_a_sized_enumerator <add> assert_equal 3, result.each.size <add> end <add> end <ide> end <ide> end <ide><path>activesupport/lib/active_support/core_ext/enumerable.rb <ide> def index_by <ide> if block_given? <ide> Hash[map { |elem| [yield(elem), elem] }] <ide> else <del> to_enum :index_by <add> to_enum(:index_by) { size } <ide> end <ide> end <ide>
6
Java
Java
introduce requestentity and builder
f6fbdafb6a5b364bc2538b4f05a85fcc9be9fc51
<ide><path>spring-web/src/main/java/org/springframework/http/RequestEntity.java <add>/* <add> * Copyright 2002-2014 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> * 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.http; <add> <add>import java.net.URI; <add>import java.nio.charset.Charset; <add>import java.util.Arrays; <add>import java.util.Map; <add> <add>import org.springframework.util.MultiValueMap; <add>import org.springframework.util.ObjectUtils; <add>import org.springframework.web.util.UriTemplate; <add> <add>/** <add> * Extension of {@link HttpEntity} that adds a {@linkplain HttpMethod method} and <add> * {@linkplain URI uri}. <add> * Used in {@code RestTemplate} as well {@code @Controller} methods. <add> * <add> * <p>In {@code RestTemplate}, this class is used as parameter in <add> * {@link org.springframework.web.client.RestTemplate#exchange(RequestEntity, Class) exchange()}: <add> * <pre class="code"> <add> * MyRequest body = ... <add> * RequestEntity&lt;MyRequest&gt; request = RequestEntity.post(&quot;http://example.com/{foo}&quot;, &quot;bar&quot;).accept(MediaType.APPLICATION_JSON).body(body); <add> * ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class); <add> * </pre> <add> * <add> * <p>Can also be used in Spring MVC, as a parameter in a @Controller method: <add> * <pre class="code"> <add> * &#64;RequestMapping("/handle") <add> * public void handle(RequestEntity&lt;String&gt; request) { <add> * HttpMethod method = request.getMethod(); <add> * URI url = request.getUrl(); <add> * String body = request.getBody(); <add> * } <add> * </pre> <add> * <add> * @author Arjen Poutsma <add> * @since 4.1 <add> * @see #getMethod() <add> * @see #getUrl() <add> */ <add>public class RequestEntity<T> extends HttpEntity<T> { <add> <add> private final HttpMethod method; <add> <add> private final URI url; <add> <add> /** <add> * Create a new {@code RequestEntity} with the given method and URL, and no body nor headers. <add> * @param method the method <add> * @param url the URL <add> */ <add> public RequestEntity(HttpMethod method, URI url) { <add> super(); <add> this.method = method; <add> this.url = url; <add> } <add> <add> /** <add> * Create a new {@code RequestEntity} with the given method, URL, body, and no headers. <add> * @param body the body <add> * @param method the method <add> * @param url the URL <add> */ <add> public RequestEntity(T body, HttpMethod method, URI url) { <add> super(body); <add> this.method = method; <add> this.url = url; <add> } <add> <add> /** <add> * Create a new {@code RequestEntity} with the given method, URL, body, headers and no <add> * body <add> * @param headers the headers <add> * @param method the method <add> * @param url the URL <add> */ <add> public RequestEntity(MultiValueMap<String, String> headers, HttpMethod method, URI url) { <add> super(headers); <add> this.method = method; <add> this.url = url; <add> } <add> <add> /** <add> * Create a new {@code RequestEntity} with the given method, URL, body, headers and <add> * body <add> * @param body the body <add> * @param headers the headers <add> * @param method the method <add> * @param url the URL <add> */ <add> public RequestEntity(T body, MultiValueMap<String, String> headers, <add> HttpMethod method, URI url) { <add> super(body, headers); <add> this.method = method; <add> this.url = url; <add> } <add> <add> /** <add> * Return the HTTP method of the request. <add> * @return the HTTP method as an {@code HttpMethod} enum value <add> */ <add> public HttpMethod getMethod() { <add> return method; <add> } <add> <add> /** <add> * Return the URL of the request. <add> * @return the URL as a {@code URI} <add> */ <add> public URI getUrl() { <add> return url; <add> } <add> <add> @Override <add> public boolean equals(Object other) { <add> if (this == other) { <add> return true; <add> } <add> if (!(other instanceof RequestEntity)) { <add> return false; <add> } <add> RequestEntity<?> otherEntity = (RequestEntity<?>) other; <add> return (ObjectUtils.nullSafeEquals(this.method, otherEntity.method) && <add> ObjectUtils.nullSafeEquals(this.url, otherEntity.url) && <add> super.equals(other)); <add> } <add> <add> @Override <add> public int hashCode() { <add> return 29 * super.hashCode() + <add> 29 * ObjectUtils.nullSafeHashCode(this.method) + <add> ObjectUtils.nullSafeHashCode(this.url); <add> } <add> <add> @Override <add> public String toString() { <add> StringBuilder builder = new StringBuilder("<"); <add> builder.append(this.method.toString()); <add> builder.append(' '); <add> builder.append(this.url); <add> builder.append(','); <add> T body = getBody(); <add> HttpHeaders headers = getHeaders(); <add> if (body != null) { <add> builder.append(body); <add> if (headers != null) { <add> builder.append(','); <add> } <add> } <add> if (headers != null) { <add> builder.append(headers); <add> } <add> builder.append('>'); <add> return builder.toString(); <add> } <add> <add> // Static builder methods <add> <add> /** <add> * Creates a builder with the given method, url, and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param method the HTTP method (GET, POST, etc) <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder method(HttpMethod method, String url, <add> Object... uriVariables) { <add> URI expanded = new UriTemplate(url).expand(uriVariables); <add> return new DefaultBodyBuilder(method, expanded); <add> } <add> <add> /** <add> * Creates a builder with the given method, url, and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param method the HTTP method (GET, POST, etc) <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder method(HttpMethod method, String url, <add> Map<String, ?> uriVariables) { <add> URI expanded = new UriTemplate(url).expand(uriVariables); <add> return new DefaultBodyBuilder(method, expanded); <add> } <add> <add> /** <add> * Creates a builder with the given method, url, and uri variables. <add> * @param method the HTTP method (GET, POST, etc) <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static BodyBuilder method(HttpMethod method, URI url) { <add> return new DefaultBodyBuilder(method, url); <add> } <add> <add> /** <add> * Creates a GET builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> get(String url, Object... uriVariables) { <add> return method(HttpMethod.GET, url, uriVariables); <add> } <add> <add> /** <add> * Creates a GET builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> get(String url, Map<String, ?> uriVariables) { <add> return method(HttpMethod.GET, url, uriVariables); <add> } <add> <add> /** <add> * Creates a GET builder with the given url. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> get(URI url) { <add> return method(HttpMethod.GET, url); <add> } <add> <add> /** <add> * Creates a HEAD builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> head(String url, Object... uriVariables) { <add> return method(HttpMethod.HEAD, url, uriVariables); <add> } <add> <add> /** <add> * Creates a HEAD builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> head(String url, Map<String, ?> uriVariables) { <add> return method(HttpMethod.HEAD, url, uriVariables); <add> } <add> <add> /** <add> * Creates a HEAD builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> head(URI url) { <add> return method(HttpMethod.HEAD, url); <add> } <add> <add> /** <add> * Creates a POST builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder post(String url, Object... uriVariables) { <add> return method(HttpMethod.POST, url, uriVariables); <add> } <add> <add> /** <add> * Creates a POST builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder post(String url, Map<String, ?> uriVariables) { <add> return method(HttpMethod.POST, url, uriVariables); <add> } <add> <add> /** <add> * Creates a POST builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static BodyBuilder post(URI url) { <add> return method(HttpMethod.POST, url); <add> } <add> <add> /** <add> * Creates a PUT builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder put(String url, <add> Object... uriVariables) { <add> return method(HttpMethod.PUT, url, uriVariables); <add> } <add> <add> /** <add> * Creates a PUT builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder put(String url, <add> Map<String, ?> uriVariables) { <add> return method(HttpMethod.PUT, url, uriVariables); <add> } <add> <add> /** <add> * Creates a PUT builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static BodyBuilder put(URI url) { <add> return method(HttpMethod.PUT, url); <add> } <add> <add> /** <add> * Creates a PATCH builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder patch(String url, <add> Object... uriVariables) { <add> return method(HttpMethod.PATCH, url, uriVariables); <add> } <add> <add> /** <add> * Creates a PATCH builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static BodyBuilder patch(String url, <add> Map<String, ?> uriVariables) { <add> return method(HttpMethod.PATCH, url, uriVariables); <add> } <add> <add> /** <add> * Creates a PATCH builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static BodyBuilder patch(URI url) { <add> return method(HttpMethod.PATCH, url); <add> } <add> <add> /** <add> * Creates a DELETE builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> delete(String url, <add> Object... uriVariables) { <add> return method(HttpMethod.DELETE, url, uriVariables); <add> } <add> <add> /** <add> * Creates a DELETE builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> delete(String url, <add> Map<String, ?> uriVariables) { <add> return method(HttpMethod.DELETE, url, uriVariables); <add> } <add> <add> /** <add> * Creates a DELETE builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> delete(URI url) { <add> return method(HttpMethod.DELETE, url); <add> } <add> <add> /** <add> * Creates an OPTIONS builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> options(String url, <add> Object... uriVariables) { <add> return method(HttpMethod.OPTIONS, url, uriVariables); <add> } <add> <add> /** <add> * Creates an OPTIONS builder with the given url and uri variables. <add> * <p>URI Template variables are expanded using the given URI variables, if any. <add> * @param url the URL <add> * @param uriVariables the variables to expand in the template <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> options(String url, <add> Map<String, ?> uriVariables) { <add> return method(HttpMethod.OPTIONS, url, uriVariables); <add> } <add> <add> /** <add> * Creates an OPTIONS builder with the given url. <add> * @param url the URL <add> * @return the created builder <add> */ <add> public static HeadersBuilder<?> options(URI url) { <add> return method(HttpMethod.OPTIONS, url); <add> } <add> <add> /** <add> * Defines a builder that adds headers to the request entity. <add> * @param <B> the builder subclass <add> */ <add> public interface HeadersBuilder<B extends HeadersBuilder<B>> { <add> <add> /** <add> * Add the given, single header value under the given name. <add> * @param headerName the header name <add> * @param headerValues the header value(s) <add> * @return this builder <add> * @see HttpHeaders#add(String, String) <add> */ <add> B header(String headerName, String... headerValues); <add> <add> /** <add> * Set the list of acceptable {@linkplain MediaType media types}, as specified <add> * by the {@code Accept} header. <add> * @param acceptableMediaTypes the acceptable media types <add> */ <add> B accept(MediaType... acceptableMediaTypes); <add> <add> /** <add> * Set the list of acceptable {@linkplain Charset charsets}, as specified by <add> * the {@code Accept-Charset} header. <add> * @param acceptableCharsets the acceptable charsets <add> */ <add> B acceptCharset(Charset... acceptableCharsets); <add> <add> /** <add> * Sets the value of the {@code If-Modified-Since} header. <add> * <p>The date should be specified as the number of milliseconds since January 1, <add> * 1970 GMT. <add> * @param ifModifiedSince the new value of the header <add> */ <add> B ifModifiedSince(long ifModifiedSince); <add> <add> /** <add> * Sets the values of the {@code If-None-Match} header. <add> * @param ifNoneMatches the new value of the header <add> */ <add> B ifNoneMatch(String... ifNoneMatches); <add> <add> /** <add> * Builds the request entity with no body. <add> * @return the request entity <add> * @see BodyBuilder#body(Object) <add> */ <add> RequestEntity<Void> build(); <add> <add> } <add> <add> /** <add> * Defines a builder that adds a body to the response entity. <add> */ <add> public interface BodyBuilder extends HeadersBuilder<BodyBuilder> { <add> <add> /** <add> * Set the length of the body in bytes, as specified by the {@code Content-Length} <add> * header. <add> * @param contentLength the content length <add> * @return this builder <add> * @see HttpHeaders#setContentLength(long) <add> */ <add> BodyBuilder contentLength(long contentLength); <add> <add> /** <add> * Set the {@linkplain MediaType media type} of the body, as specified by the <add> * {@code Content-Type} header. <add> * @param contentType the content type <add> * @return this builder <add> * @see HttpHeaders#setContentType(MediaType) <add> */ <add> BodyBuilder contentType(MediaType contentType); <add> <add> /** <add> * Sets the body of the request entity and returns it. <add> * @param body the body of the request entity <add> * @param <T> the type of the body <add> * @return the built request entity <add> */ <add> <T> RequestEntity<T> body(T body); <add> <add> } <add> <add> private static class DefaultBodyBuilder implements BodyBuilder { <add> <add> private final HttpMethod method; <add> <add> private final URI url; <add> <add> private final HttpHeaders headers = new HttpHeaders(); <add> <add> <add> public DefaultBodyBuilder(HttpMethod method, URI url) { <add> this.method = method; <add> this.url = url; <add> } <add> <add> @Override <add> public BodyBuilder header(String headerName, String... headerValues) { <add> for (String headerValue : headerValues) { <add> this.headers.add(headerName, headerValue); <add> } <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder accept(MediaType... acceptableMediaTypes) { <add> this.headers.setAccept(Arrays.asList(acceptableMediaTypes)); <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder acceptCharset(Charset... acceptableCharsets) { <add> this.headers.setAcceptCharset(Arrays.asList(acceptableCharsets)); <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder contentLength(long contentLength) { <add> this.headers.setContentLength(contentLength); <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder contentType(MediaType contentType) { <add> this.headers.setContentType(contentType); <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder ifModifiedSince(long ifModifiedSince) { <add> this.headers.setIfModifiedSince(ifModifiedSince); <add> return this; <add> } <add> <add> @Override <add> public BodyBuilder ifNoneMatch(String... ifNoneMatches) { <add> this.headers.setIfNoneMatch(Arrays.asList(ifNoneMatches)); <add> return this; <add> } <add> <add> @Override <add> public RequestEntity<Void> build() { <add> return new RequestEntity<Void>(null, this.headers, this.method, this.url); <add> } <add> <add> @Override <add> public <T> RequestEntity<T> body(T body) { <add> return new RequestEntity<T>(body, this.headers, this.method, this.url); <add> } <add> } <add> <add> <add> <add> <add> <add> <add>} <ide><path>spring-web/src/main/java/org/springframework/web/client/RestOperations.java <ide> import org.springframework.http.HttpEntity; <ide> import org.springframework.http.HttpHeaders; <ide> import org.springframework.http.HttpMethod; <add>import org.springframework.http.RequestEntity; <ide> import org.springframework.http.ResponseEntity; <ide> <ide> /** <ide> <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requ <ide> <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, <ide> ParameterizedTypeReference<T> responseType) throws RestClientException; <ide> <add> /** <add> * Execute the HTTP method and URL of the {@link RequestEntity}, writing it to the <add> * request, and returns the response as {@link ResponseEntity}. Typically used in <add> * combination with the static builder methods on {@code RequestEntity}, for instance: <add> * <add> * <pre class="code"> <add> * MyRequest body = ... <add> * RequestEntity request = RequestEntity.post(&quot;http://example.com/{foo}&quot;, &quot;bar&quot;).accept(MediaType.APPLICATION_JSON).body(body); <add> * ResponseEntity&lt;MyResponse&gt; response = template.exchange(request, MyResponse.class); <add> * </pre> <add> * <add> * @param requestEntity the entity to write to the request <add> * @param responseType the type of the return value <add> * @return the response as entity <add> * @since 4.1 <add> */ <add> <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, <add> Class<T> responseType) throws RestClientException; <add> <add> /** <add> * Execute the HTTP method and URL of the {@link RequestEntity}, writing it to the <add> * request, and returns the response as {@link ResponseEntity}. <add> * The given {@link ParameterizedTypeReference} is used to pass generic type information: <add> * <add> * <pre class="code"> <add> * MyRequest body = ... <add> * RequestEntity request = RequestEntity.post(&quot;http://example.com/{foo}&quot;, &quot;bar&quot;).accept(MediaType.APPLICATION_JSON).body(body); <add> * ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt; myBean = new ParameterizedTypeReference&lt;List&lt;MyResponse&gt;&gt;() {}; <add> * ResponseEntity&lt;List&lt;MyResponse&gt;&gt; response = template.exchange(request, myBean); <add> * </pre> <add> * <add> * @param requestEntity the entity to write to the request <add> * @param responseType the type of the return value <add> * @return the response as entity <add> * @since 4.1 <add> */ <add> <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, <add> ParameterizedTypeReference<T> responseType) throws RestClientException; <add> <add> <ide> // general execution <ide> <ide> /** <ide><path>spring-web/src/main/java/org/springframework/web/client/RestTemplate.java <ide> import org.springframework.http.HttpHeaders; <ide> import org.springframework.http.HttpMethod; <ide> import org.springframework.http.MediaType; <add>import org.springframework.http.RequestEntity; <ide> import org.springframework.http.ResponseEntity; <ide> import org.springframework.http.client.ClientHttpRequest; <ide> import org.springframework.http.client.ClientHttpRequestFactory; <ide> public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> <ide> return execute(url, method, requestCallback, responseExtractor); <ide> } <ide> <add> @Override <add> public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, <add> Class<T> responseType) throws RestClientException { <add> Assert.notNull(requestEntity, "'requestEntity' must not be null"); <add> <add> RequestCallback requestCallback = httpEntityCallback(requestEntity, responseType); <add> ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(responseType); <add> return execute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor); <add> } <add> <add> @Override <add> public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, <add> ParameterizedTypeReference<T> responseType) throws RestClientException { <add> Assert.notNull(requestEntity, "'requestEntity' must not be null"); <add> <add> Type type = responseType.getType(); <add> RequestCallback requestCallback = httpEntityCallback(requestEntity, type); <add> ResponseExtractor<ResponseEntity<T>> responseExtractor = responseEntityExtractor(type); <add> return execute(requestEntity.getUrl(), requestEntity.getMethod(), requestCallback, responseExtractor); <add> } <add> <add> <ide> // general execution <ide> <ide> @Override <ide><path>spring-web/src/test/java/org/springframework/http/RequestEntityTests.java <add>/* <add> * Copyright 2002-2014 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> * 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.http; <add> <add>import java.net.URI; <add>import java.net.URISyntaxException; <add>import java.nio.charset.Charset; <add>import java.util.HashMap; <add>import java.util.List; <add>import java.util.Map; <add> <add>import static org.junit.Assert.*; <add>import static org.junit.Assert.assertEquals; <add>import org.junit.Test; <add> <add>public class RequestEntityTests { <add> <add> @Test <add> public void normal() throws URISyntaxException { <add> String headerName = "My-Custom-Header"; <add> String headerValue = "HeaderValue"; <add> URI url = new URI("http://example.com"); <add> Integer entity = 42; <add> <add> RequestEntity<Object> requestEntity = <add> RequestEntity.method(HttpMethod.GET, url) <add> .header(headerName, headerValue).body(entity); <add> <add> assertNotNull(requestEntity); <add> assertEquals(HttpMethod.GET, requestEntity.getMethod()); <add> assertTrue(requestEntity.getHeaders().containsKey(headerName)); <add> assertEquals(headerValue, requestEntity.getHeaders().getFirst(headerName)); <add> assertEquals(entity, requestEntity.getBody()); <add> } <add> <add> @Test <add> public void uriVariablesExpansion() throws URISyntaxException { <add> RequestEntity.get("http://example.com/{foo}", "bar").accept(MediaType.TEXT_PLAIN).build(); <add> <add> String url = "http://www.{host}.com/{path}"; <add> String host = "example"; <add> String path = "foo/bar"; <add> <add> URI expected = new URI("http://www.example.com/foo/bar"); <add> <add> RequestEntity<?> entity = RequestEntity.method(HttpMethod.GET, url, host, path).build(); <add> assertEquals(expected, entity.getUrl()); <add> <add> Map<String, String> uriVariables = new HashMap<String, String>(2); <add> uriVariables.put("host", host); <add> uriVariables.put("path", path); <add> <add> entity = RequestEntity.method(HttpMethod.GET, url, uriVariables).build(); <add> assertEquals(expected, entity.getUrl()); <add> } <add> <add> @Test <add> public void get() { <add> RequestEntity<Void> requestEntity = RequestEntity.get(URI.create("http://example.com")).accept( <add> MediaType.IMAGE_GIF, MediaType.IMAGE_JPEG, MediaType.IMAGE_PNG).build(); <add> <add> assertNotNull(requestEntity); <add> assertEquals(HttpMethod.GET, requestEntity.getMethod()); <add> assertTrue(requestEntity.getHeaders().containsKey("Accept")); <add> assertEquals("image/gif, image/jpeg, image/png", requestEntity.getHeaders().getFirst("Accept")); <add> assertNull(requestEntity.getBody()); <add> } <add> <add> @Test <add> public void headers() throws URISyntaxException { <add> MediaType accept = MediaType.TEXT_PLAIN; <add> Charset charset = Charset.forName("UTF-8"); <add> long ifModifiedSince = 12345L; <add> String ifNoneMatch = "\"foo\""; <add> long contentLength = 67890; <add> MediaType contentType = MediaType.TEXT_PLAIN; <add> <add> RequestEntity<Void> responseEntity = RequestEntity.post("http://example.com"). <add> accept(accept). <add> acceptCharset(charset). <add> ifModifiedSince(ifModifiedSince). <add> ifNoneMatch(ifNoneMatch). <add> contentLength(contentLength). <add> contentType(contentType). <add> build(); <add> <add> assertNotNull(responseEntity); <add> assertEquals(HttpMethod.POST, responseEntity.getMethod()); <add> assertEquals(new URI("http://example.com"), responseEntity.getUrl()); <add> HttpHeaders responseHeaders = responseEntity.getHeaders(); <add> <add> assertEquals("text/plain", responseHeaders.getFirst("Accept")); <add> assertEquals("utf-8", responseHeaders.getFirst("Accept-Charset")); <add> assertEquals("Thu, 01 Jan 1970 00:00:12 GMT", <add> responseHeaders.getFirst("If-Modified-Since")); <add> assertEquals(ifNoneMatch, responseHeaders.getFirst("If-None-Match")); <add> assertEquals(String.valueOf(contentLength), responseHeaders.getFirst("Content-Length")); <add> assertEquals(contentType.toString(), responseHeaders.getFirst("Content-Type")); <add> <add> assertNull(responseEntity.getBody()); <add> } <add> <add> @Test <add> public void methods() throws URISyntaxException { <add> URI url = new URI("http://example.com"); <add> <add> RequestEntity<?> entity = RequestEntity.get(url).build(); <add> assertEquals(HttpMethod.GET, entity.getMethod()); <add> <add> entity = RequestEntity.post(url).build(); <add> assertEquals(HttpMethod.POST, entity.getMethod()); <add> <add> entity = RequestEntity.head(url).build(); <add> assertEquals(HttpMethod.HEAD, entity.getMethod()); <add> <add> entity = RequestEntity.options(url).build(); <add> assertEquals(HttpMethod.OPTIONS, entity.getMethod()); <add> <add> entity = RequestEntity.put(url).build(); <add> assertEquals(HttpMethod.PUT, entity.getMethod()); <add> <add> entity = RequestEntity.patch(url).build(); <add> assertEquals(HttpMethod.PATCH, entity.getMethod()); <add> <add> entity = RequestEntity.delete(url).build(); <add> assertEquals(HttpMethod.DELETE, entity.getMethod()); <add> <add> } <add> <add> <add> <add> <add>} <ide>\ No newline at end of file <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java <ide> import org.springframework.http.HttpEntity; <ide> import org.springframework.http.HttpHeaders; <ide> import org.springframework.http.HttpInputMessage; <add>import org.springframework.http.RequestEntity; <ide> import org.springframework.http.ResponseEntity; <ide> import org.springframework.http.converter.HttpMessageConverter; <ide> import org.springframework.http.server.ServletServerHttpRequest; <ide> public HttpEntityMethodProcessor(List<HttpMessageConverter<?>> messageConverters <ide> <ide> @Override <ide> public boolean supportsParameter(MethodParameter parameter) { <del> return HttpEntity.class.equals(parameter.getParameterType()); <add> return HttpEntity.class.equals(parameter.getParameterType()) || <add> RequestEntity.class.equals(parameter.getParameterType()); <ide> } <ide> <ide> @Override <ide> public boolean supportsReturnType(MethodParameter returnType) { <del> return HttpEntity.class.isAssignableFrom(returnType.getParameterType()); <add> return HttpEntity.class.equals(returnType.getParameterType()) || <add> ResponseEntity.class.equals(returnType.getParameterType()); <ide> } <ide> <ide> @Override <ide> public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, <ide> NativeWebRequest webRequest, WebDataBinderFactory binderFactory) <ide> throws IOException, HttpMediaTypeNotSupportedException { <ide> <del> HttpInputMessage inputMessage = createInputMessage(webRequest); <add> ServletServerHttpRequest inputMessage = createInputMessage(webRequest); <ide> Type paramType = getHttpEntityType(parameter); <ide> <ide> Object body = readWithMessageConverters(webRequest, parameter, paramType); <del> return new HttpEntity<Object>(body, inputMessage.getHeaders()); <add> if (RequestEntity.class.equals(parameter.getParameterType())) { <add> return new RequestEntity<Object>(body, inputMessage.getHeaders(), <add> inputMessage.getMethod(), inputMessage.getURI()); <add> } <add> else { <add> return new HttpEntity<Object>(body, inputMessage.getHeaders()); <add> <add> } <ide> } <ide> <ide> private Type getHttpEntityType(MethodParameter parameter) { <ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java <ide> package org.springframework.web.servlet.mvc.method.annotation; <ide> <ide> import java.lang.reflect.Method; <add>import java.net.URI; <ide> import java.util.Arrays; <ide> import java.util.Collections; <ide> <ide> import org.springframework.http.HttpEntity; <ide> import org.springframework.http.HttpHeaders; <ide> import org.springframework.http.HttpInputMessage; <add>import org.springframework.http.HttpMethod; <ide> import org.springframework.http.HttpOutputMessage; <ide> import org.springframework.http.HttpStatus; <ide> import org.springframework.http.MediaType; <add>import org.springframework.http.RequestEntity; <ide> import org.springframework.http.ResponseEntity; <ide> import org.springframework.http.converter.HttpMessageConverter; <ide> import org.springframework.mock.web.test.MockHttpServletRequest; <ide> public class HttpEntityMethodProcessorMockTests { <ide> private MethodParameter returnTypeResponseEntity; <ide> private MethodParameter returnTypeHttpEntity; <ide> private MethodParameter returnTypeInt; <add> private MethodParameter paramRequestEntity; <ide> private MethodParameter returnTypeResponseEntityProduces; <ide> <ide> private ModelAndViewContainer mavContainer; <ide> public class HttpEntityMethodProcessorMockTests { <ide> <ide> private MockHttpServletRequest servletRequest; <ide> <add> <ide> @SuppressWarnings("unchecked") <ide> @Before <ide> public void setUp() throws Exception { <ide> public void setUp() throws Exception { <ide> reset(messageConverter); <ide> <ide> <del> Method handle1 = getClass().getMethod("handle1", HttpEntity.class, ResponseEntity.class, Integer.TYPE); <add> Method handle1 = getClass().getMethod("handle1", HttpEntity.class, ResponseEntity.class, Integer.TYPE, RequestEntity.class); <ide> paramHttpEntity = new MethodParameter(handle1, 0); <ide> paramResponseEntity = new MethodParameter(handle1, 1); <ide> paramInt = new MethodParameter(handle1, 2); <add> paramRequestEntity = new MethodParameter(handle1, 3); <ide> returnTypeResponseEntity = new MethodParameter(handle1, -1); <ide> <ide> returnTypeHttpEntity = new MethodParameter(getClass().getMethod("handle2", HttpEntity.class), -1); <ide> public void setUp() throws Exception { <ide> @Test <ide> public void supportsParameter() { <ide> assertTrue("HttpEntity parameter not supported", processor.supportsParameter(paramHttpEntity)); <add> assertTrue("RequestEntity parameter not supported", processor.supportsParameter(paramRequestEntity)); <ide> assertFalse("ResponseEntity parameter supported", processor.supportsParameter(paramResponseEntity)); <ide> assertFalse("non-entity parameter supported", processor.supportsParameter(paramInt)); <ide> } <ide> public void supportsParameter() { <ide> public void supportsReturnType() { <ide> assertTrue("ResponseEntity return type not supported", processor.supportsReturnType(returnTypeResponseEntity)); <ide> assertTrue("HttpEntity return type not supported", processor.supportsReturnType(returnTypeHttpEntity)); <add> assertFalse("RequestEntity parameter supported", <add> processor.supportsReturnType(paramRequestEntity)); <ide> assertFalse("non-ResponseBody return type supported", processor.supportsReturnType(returnTypeInt)); <ide> } <ide> <ide> public void resolveArgument() throws Exception { <ide> assertEquals("Invalid argument", body, ((HttpEntity<?>) result).getBody()); <ide> } <ide> <add> @Test <add> public void resolveArgumentRequestEntity() throws Exception { <add> MediaType contentType = MediaType.TEXT_PLAIN; <add> servletRequest.addHeader("Content-Type", contentType.toString()); <add> servletRequest.setMethod("GET"); <add> servletRequest.setServerName("www.example.com"); <add> servletRequest.setServerPort(80); <add> servletRequest.setRequestURI("/path"); <add> <add> String body = "Foo"; <add> given(messageConverter.canRead(String.class, contentType)).willReturn(true); <add> given(messageConverter.read(eq(String.class), isA(HttpInputMessage.class))).willReturn(body); <add> <add> Object result = processor.resolveArgument(paramRequestEntity, mavContainer, webRequest, null); <add> <add> assertTrue(result instanceof RequestEntity); <add> assertFalse("The requestHandled flag shouldn't change", mavContainer.isRequestHandled()); <add> RequestEntity<?> requestEntity = (RequestEntity<?>) result; <add> assertEquals("Invalid method", HttpMethod.GET, requestEntity.getMethod()); <add> assertEquals("Invalid url", new URI("http", null, "www.example.com", 80, "/path", null, null), requestEntity.getUrl()); <add> assertEquals("Invalid argument", body, requestEntity.getBody()); <add> } <add> <ide> @Test(expected = HttpMediaTypeNotSupportedException.class) <ide> public void resolveArgumentNotReadable() throws Exception { <ide> MediaType contentType = MediaType.TEXT_PLAIN; <ide> public void responseHeaderAndBody() throws Exception { <ide> assertEquals("headerValue", outputMessage.getValue().getHeaders().get("header").get(0)); <ide> } <ide> <del> public ResponseEntity<String> handle1(HttpEntity<String> httpEntity, ResponseEntity<String> responseEntity, int i) { <add> public ResponseEntity<String> handle1(HttpEntity<String> httpEntity, ResponseEntity<String> responseEntity, int i, RequestEntity<String> requestEntity) { <ide> return responseEntity; <ide> } <ide>
6
PHP
PHP
fix existing tests
d15cfe3c57e53467445f6ca599091ac13ccd2356
<ide><path>src/Illuminate/Database/Eloquent/FactoryBuilder.php <ide> public function make(array $attributes = []) <ide> { <ide> if ($this->amount === null) { <ide> $instance = $this->makeInstance($attributes); <add> $this->applyAfter(collect([$instance]), 'make'); <ide> <del> return $this->applyAfter(collect([$instance]), 'make'); <add> return $instance; <ide> } <ide> <ide> if ($this->amount < 1) { <ide> public function make(array $attributes = []) <ide> $instances = (new $this->class)->newCollection(array_map(function () use ($attributes) { <ide> return $this->makeInstance($attributes); <ide> }, range(1, $this->amount))); <add> $this->applyAfter($instances, 'make'); <ide> <del> return $this->applyAfter($instances, 'make'); <add> return $instances; <ide> } <ide> <ide> /** <ide> protected function expandAttributes(array $attributes) <ide> /** <ide> * Run after callback on a collection of models. <ide> * <del> * @param \Illuminate\Support\Collection $results <add> * @param \Illuminate\Support\Collection $models <ide> * @param string $action <ide> * @return void <ide> */ <ide> public function applyAfter($models, $action) <ide> <ide> call_user_func_array($this->after[$this->class][$action], [$model, $this->faker]); <ide> }); <del> <del> return $models; <ide> } <ide> }
1
Javascript
Javascript
update fromjson return values
8794a173f9c175df2343245e71ee9a137f5bc66a
<ide><path>src/Angular.js <ide> function toJson(obj, pretty) { <ide> * Deserializes a JSON string. <ide> * <ide> * @param {string} json JSON string to deserialize. <del> * @returns {Object|Array|Date|string|number} Deserialized thingy. <add> * @returns {Object|Array|string|number} Deserialized thingy. <ide> */ <ide> function fromJson(json) { <ide> return isString(json)
1
PHP
PHP
update urlhelper tests
d31bc5b7b9908f4d9661e314319de1d4445c42ac
<ide><path>tests/TestCase/View/Helper/UrlHelperTest.php <ide> public function testBuildUrlConversion() <ide> $result = $this->Helper->build('/controller/action/1?one=1&two=2'); <ide> $this->assertEquals('/controller/action/1?one=1&amp;two=2', $result); <ide> <del> $result = $this->Helper->build(['controller' => 'posts', 'action' => 'index', 'page' => '1" onclick="alert(\'XSS\');"']); <add> $result = $this->Helper->build(['controller' => 'posts', 'action' => 'index', '?' => ['page' => '1" onclick="alert(\'XSS\');"']]); <ide> $this->assertEquals('/posts?page=1%22+onclick%3D%22alert%28%27XSS%27%29%3B%22', $result); <ide> <ide> $result = $this->Helper->build('/controller/action/1/param:this+one+more'); <ide> public function testBuildUrlConversion() <ide> $this->assertEquals('/controller/action/1/param:%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24', $result); <ide> <ide> $result = $this->Helper->build([ <del> 'controller' => 'posts', 'action' => 'index', 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24', <add> 'controller' => 'posts', 'action' => 'index', <add> '?' => ['param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24'], <ide> ]); <ide> $this->assertEquals('/posts?param=%257Baround%2520here%257D%255Bthings%255D%255Bare%255D%2524%2524', $result); <ide> <ide> $result = $this->Helper->build([ <del> 'controller' => 'posts', 'action' => 'index', 'page' => '1', <del> '?' => ['one' => 'value', 'two' => 'value', 'three' => 'purple'], <add> 'controller' => 'posts', 'action' => 'index', <add> '?' => ['one' => 'value', 'two' => 'value', 'three' => 'purple', 'page' => '1'], <ide> ]); <ide> $this->assertEquals('/posts?one=value&amp;two=value&amp;three=purple&amp;page=1', $result); <ide> } <ide> public function testBuildUrlConversionUnescaped() <ide> $result = $this->Helper->build([ <ide> 'controller' => 'posts', <ide> 'action' => 'view', <del> 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24', <ide> '?' => [ <ide> 'k' => 'v', <ide> '1' => '2', <add> 'param' => '%7Baround%20here%7D%5Bthings%5D%5Bare%5D%24%24', <ide> ], <ide> ], ['escape' => false]); <ide> $this->assertEquals('/posts/view?k=v&1=2&param=%257Baround%2520here%257D%255Bthings%255D%255Bare%255D%2524%2524', $result);
1
Javascript
Javascript
fix typeerror with eventemitter#on() abuse
ee9cd004d8a211871439fc77c0696b79c5d0e52d
<ide><path>lib/events.js <ide> EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { <ide> return this; <ide> }; <ide> <del>EventEmitter.prototype.getMaxListeners = function getMaxListeners() { <del> if (!util.isUndefined(this._maxListeners)) <del> return this._maxListeners; <del> else <add>function $getMaxListeners(that) { <add> if (util.isUndefined(that._maxListeners)) <ide> return EventEmitter.defaultMaxListeners; <add> return that._maxListeners; <add>} <add> <add>EventEmitter.prototype.getMaxListeners = function getMaxListeners() { <add> return $getMaxListeners(this); <ide> }; <ide> <ide> EventEmitter.prototype.emit = function emit(type) { <ide> EventEmitter.prototype.addListener = function addListener(type, listener) { <ide> <ide> // Check for listener leak <ide> if (util.isObject(this._events[type]) && !this._events[type].warned) { <del> var m = this.getMaxListeners(); <add> var m = $getMaxListeners(this); <ide> if (m && m > 0 && this._events[type].length > m) { <ide> this._events[type].warned = true; <ide> console.error('(node) warning: possible EventEmitter memory ' + <ide><path>test/parallel/test-event-emitter-get-max-listeners.js <ide> assert.strictEqual(emitter.getMaxListeners(), 0); <ide> <ide> emitter.setMaxListeners(3); <ide> assert.strictEqual(emitter.getMaxListeners(), 3); <add> <add>// https://github.com/iojs/io.js/issues/523 - second call should not throw. <add>var recv = {}; <add>EventEmitter.prototype.on.call(recv, 'event', function() {}); <add>EventEmitter.prototype.on.call(recv, 'event', function() {});
2
Python
Python
add tunnel test
9ac990c8c83c63f47251e4afd4dc74d65a5c1481
<ide><path>tests/core.py <del>import copy <add>from __future__ import print_function <add> <ide> from datetime import datetime, time, timedelta <ide> import doctest <ide> import json <ide> def test_parse_s3_url(self): <ide> ("test", "this/is/not/a-real-key.txt"), <ide> "Incorrect parsing of the s3 url") <ide> <add>HELLO_SERVER_CMD = """ <add>import socket, sys <add>listener = socket.socket() <add>listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) <add>listener.bind(('localhost', 2134)) <add>listener.listen(1) <add>sys.stdout.write('ready') <add>sys.stdout.flush() <add>conn = listener.accept()[0] <add>conn.sendall(b'hello') <add>""" <add> <ide> <ide> class SSHHookTest(unittest.TestCase): <ide> def setUp(self): <ide> def test_remote_cmd(self): <ide> output = self.hook.check_output(["echo", "-n", "airflow"]) <ide> self.assertEqual(output, b"airflow") <ide> <add> def test_tunnel(self): <add> print("Setting up remote listener") <add> import subprocess <add> import socket <add> <add> self.handle = self.hook._Popen([ <add> "python", "-c", '"{0}"'.format(HELLO_SERVER_CMD) <add> ], stdout=subprocess.PIPE) <add> <add> print("Setting up tunnel") <add> with self.hook.tunnel(2135, 2134): <add> print("Tunnel up") <add> server_output = self.handle.stdout.read(5) <add> self.assertEqual(server_output, b"ready") <add> print("Connecting to server via tunnel") <add> s = socket.socket() <add> s.connect(("localhost", 2135)) <add> print("Receiving...",) <add> response = s.recv(5) <add> self.assertEqual(response, b"hello") <add> print("Closing connection") <add> s.close() <add> print("Waiting for listener...") <add> output, _ = self.handle.communicate() <add> self.assertEqual(self.handle.returncode, 0) <add> print("Closing tunnel") <add> <ide> <ide> if 'AIRFLOW_RUNALL_TESTS' in os.environ: <ide>
1
PHP
PHP
fix indentation and double slashes
4cb904f44d24f856ec9c1040d2198ed8f009723b
<ide><path>application/config/application.php <ide> 'Blade' => 'Laravel\\Blade', <ide> 'Bundle' => 'Laravel\\Bundle', <ide> 'Cache' => 'Laravel\\Cache', <del> 'Command' => 'Laravel\\CLI\\Command', <add> 'Command' => 'Laravel\\CLI\\Command', <ide> 'Config' => 'Laravel\\Config', <ide> 'Controller' => 'Laravel\\Routing\\Controller', <ide> 'Cookie' => 'Laravel\\Cookie',
1
Javascript
Javascript
fix isfibermounted exports
545a193ef9c2c419fb362c78fc6233ecd27866b6
<ide><path>src/renderers/shared/fiber/ReactFiberTreeReflection.js <ide> var MOUNTING = 1; <ide> var MOUNTED = 2; <ide> var UNMOUNTED = 3; <ide> <del>function isFiberMounted(fiber : Fiber) : number { <add>function isFiberMountedImpl(fiber : Fiber) : number { <ide> let node = fiber; <ide> if (!fiber.alternate) { <ide> // If there is no alternate, this might be a new tree that isn't inserted <ide> function isFiberMounted(fiber : Fiber) : number { <ide> // that has been unmounted. <ide> return UNMOUNTED; <ide> } <del>exports.isFiberMounted = isFiberMounted; <add>exports.isFiberMounted = function(fiber : Fiber) : boolean { <add> return isFiberMountedImpl(fiber) === MOUNTED; <add>}; <ide> <ide> exports.isMounted = function(component : ReactComponent<any, any, any>) : boolean { <ide> var fiber : ?Fiber = ReactInstanceMap.get(component); <ide> if (!fiber) { <ide> return false; <ide> } <del> return isFiberMounted(fiber) === MOUNTED; <add> return isFiberMountedImpl(fiber) === MOUNTED; <ide> }; <ide> <ide> exports.findCurrentHostFiber = function(parent : Fiber) : Fiber | null { <ide> // First check if this node itself is mounted. <del> const state = isFiberMounted(parent, true); <add> const state = isFiberMountedImpl(parent, true); <ide> if (state === UNMOUNTED) { <ide> invariant( <ide> false,
1
Javascript
Javascript
remove outdated todo
af2e5f95227506d08485cc2464ee1df9784eb726
<ide><path>lib/util.js <ide> Object.defineProperty(inspect, 'defaultOptions', { <ide> if (options === null || typeof options !== 'object') { <ide> throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); <ide> } <del> // TODO(BridgeAR): Add input validation and make sure `defaultOptions` are <del> // not configurable. <ide> return _extend(inspectDefaultOptions, options); <ide> } <ide> });
1
Text
Text
fix typo error
ff3175845f27864c38961f518040bb7e143822b2
<ide><path>guide/english/java/index.md <ide> Ok now since we are done with the installations, let's begin to understand first <ide> <ide> Java is a pretty secure language as it doesn't let your program run directly on the machine. Instead, your program runs on a Virtual Machine called JVM. This Virtual Machine exposes several APIs for low level machine interactions you can make, but other than that you cannot play with machine instructions explicitely. This adds a huge bonus of security. <ide> <del>Also, once your bytecode is compiled it can run on any Java VM. This Virtual Machine is machine dependent, i.e it has different implementations for Windows, Linux and Mac. But your program is guranteed to run in any system thanks to this VM. This philosophy is called <a href='https://en.wikipedia.org/wiki/Write_once,_run_anywhere' target='_blank' rel='nofollow'>"Write Once, Run Anywhere"</a>. <add>Also, once your bytecode is compiled it can run on any Java VM. This Virtual Machine is machine dependent, i.e it has different implementations for Windows, Linux and Mac. But your program is guaranteed to run in any system thanks to this VM. This philosophy is called <a href='https://en.wikipedia.org/wiki/Write_once,_run_anywhere' target='_blank' rel='nofollow'>"Write Once, Run Anywhere"</a>. <ide> <ide> ## Hello World! <ide>
1
Javascript
Javascript
change var to const
74d33630ce34969d6abf57e1e597fcdafef56ab2
<ide><path>lib/internal/tls.js <ide> // Example: <ide> // C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org <ide> function parseCertString(s) { <del> var out = Object.create(null); <del> var parts = s.split('\n'); <add> const out = Object.create(null); <add> const parts = s.split('\n'); <ide> for (var i = 0, len = parts.length; i < len; i++) { <del> var sepIndex = parts[i].indexOf('='); <add> const sepIndex = parts[i].indexOf('='); <ide> if (sepIndex > 0) { <del> var key = parts[i].slice(0, sepIndex); <del> var value = parts[i].slice(sepIndex + 1); <add> const key = parts[i].slice(0, sepIndex); <add> const value = parts[i].slice(sepIndex + 1); <ide> if (key in out) { <ide> if (!Array.isArray(out[key])) { <ide> out[key] = [out[key]];
1
Python
Python
warn user about duplicate operationids.
797518af6d996308781e283601057ff82ed8684c
<ide><path>rest_framework/schemas/openapi.py <ide> def get_info(self): <ide> <ide> return info <ide> <add> def check_duplicate_operation_id(self, paths): <add> ids = {} <add> for route in paths: <add> for method in paths[route]: <add> if 'operationId' not in paths[route][method]: <add> continue <add> operation_id = paths[route][method]['operationId'] <add> if operation_id in ids: <add> warnings.warn( <add> 'You have a duplicated operationId in your OpenAPI schema: {operation_id}\n' <add> '\tRoute: {route1}, Method: {method1}\n' <add> '\tRoute: {route2}, Method: {method2}\n' <add> '\tAn operationId has to be unique accros your schema. Your schema may not work in other tools.' <add> .format( <add> route1=ids[operation_id]['route'], <add> method1=ids[operation_id]['method'], <add> route2=route, <add> method2=method, <add> operation_id=operation_id <add> ) <add> ) <add> ids[operation_id] = { <add> 'route': route, <add> 'method': method <add> } <add> <ide> def get_schema(self, request=None, public=False): <ide> """ <ide> Generate a OpenAPI schema. <ide> def get_schema(self, request=None, public=False): <ide> paths.setdefault(path, {}) <ide> paths[path][method.lower()] = operation <ide> <add> self.check_duplicate_operation_id(paths) <add> <ide> # Compile final schema. <ide> schema = { <ide> 'openapi': '3.0.2', <ide><path>tests/schemas/test_openapi.py <ide> import uuid <add>import warnings <ide> <ide> import pytest <ide> from django.conf.urls import url <ide> def test_repeat_operation_ids(self): <ide> assert schema_str.count("newExample") == 1 <ide> assert schema_str.count("oldExample") == 1 <ide> <add> def test_duplicate_operation_id(self): <add> patterns = [ <add> url(r'^duplicate1/?$', views.ExampleOperationIdDuplicate1.as_view()), <add> url(r'^duplicate2/?$', views.ExampleOperationIdDuplicate2.as_view()), <add> ] <add> <add> generator = SchemaGenerator(patterns=patterns) <add> request = create_request('/') <add> <add> with warnings.catch_warnings(record=True) as w: <add> warnings.simplefilter('always') <add> generator.get_schema(request=request) <add> <add> assert len(w) == 1 <add> assert issubclass(w[-1].category, UserWarning) <add> print(str(w[-1].message)) <add> assert 'You have a duplicated operationId' in str(w[-1].message) <add> <ide> def test_serializer_datefield(self): <ide> path = '/' <ide> method = 'GET' <ide><path>tests/schemas/views.py <ide> DecimalValidator, MaxLengthValidator, MaxValueValidator, <ide> MinLengthValidator, MinValueValidator, RegexValidator <ide> ) <add>from django.db import models <ide> <ide> from rest_framework import generics, permissions, serializers <ide> from rest_framework.decorators import action <ide> def get(self, *args, **kwargs): <ide> url='http://localhost', uuid=uuid.uuid4(), ip4='127.0.0.1', ip6='::1', <ide> ip='192.168.1.1') <ide> return Response(serializer.data) <add> <add> <add># Serializer with model. <add>class OpenAPIExample(models.Model): <add> first_name = models.CharField(max_length=30) <add> <add> <add>class ExampleSerializerModel(serializers.Serializer): <add> date = serializers.DateField() <add> datetime = serializers.DateTimeField() <add> hstore = serializers.HStoreField() <add> uuid_field = serializers.UUIDField(default=uuid.uuid4) <add> <add> class Meta: <add> model = OpenAPIExample <add> <add> <add>class ExampleOperationIdDuplicate1(generics.GenericAPIView): <add> serializer_class = ExampleSerializerModel <add> <add> def get(self, *args, **kwargs): <add> pass <add> <add> <add>class ExampleOperationIdDuplicate2(generics.GenericAPIView): <add> serializer_class = ExampleSerializerModel <add> <add> def get(self, *args, **kwargs): <add> pass
3
Python
Python
update error messages for several keras/layers
8a4074b3e9e1c4d7a7133ba1e5600008c7309a39
<ide><path>keras/layers/advanced_activations.py <ide> class LeakyReLU(Layer): <ide> def __init__(self, alpha=0.3, **kwargs): <ide> super(LeakyReLU, self).__init__(**kwargs) <ide> if alpha is None: <del> raise ValueError('The alpha value of a Leaky ReLU layer ' <del> 'cannot be None, needs a float. ' <del> 'Got %s' % alpha) <add> raise ValueError( <add> 'The alpha value of a Leaky ReLU layer cannot be None, ' <add> f'Expecting a float. Received: {alpha}') <ide> self.supports_masking = True <ide> self.alpha = backend.cast_to_floatx(alpha) <ide> <ide> class ELU(Layer): <ide> def __init__(self, alpha=1.0, **kwargs): <ide> super(ELU, self).__init__(**kwargs) <ide> if alpha is None: <del> raise ValueError('Alpha of an ELU layer cannot be None, ' <del> 'requires a float. Got %s' % alpha) <add> raise ValueError( <add> 'Alpha of an ELU layer cannot be None, expecting a float. ' <add> f'Received: {alpha}') <ide> self.supports_masking = True <ide> self.alpha = backend.cast_to_floatx(alpha) <ide> <ide> class ThresholdedReLU(Layer): <ide> def __init__(self, theta=1.0, **kwargs): <ide> super(ThresholdedReLU, self).__init__(**kwargs) <ide> if theta is None: <del> raise ValueError('Theta of a Thresholded ReLU layer cannot be ' <del> 'None, requires a float. Got %s' % theta) <add> raise ValueError( <add> 'Theta of a Thresholded ReLU layer cannot be None, expecting a float.' <add> f' Received: {theta}') <ide> if theta < 0: <ide> raise ValueError('The theta value of a Thresholded ReLU layer ' <del> 'should be >=0, got %s' % theta) <add> f'should be >=0. Received: {theta}') <ide> self.supports_masking = True <ide> self.theta = backend.cast_to_floatx(theta) <ide> <ide> def __init__(self, max_value=None, negative_slope=0., threshold=0., **kwargs): <ide> super(ReLU, self).__init__(**kwargs) <ide> if max_value is not None and max_value < 0.: <ide> raise ValueError('max_value of a ReLU layer cannot be a negative ' <del> 'value. Got: %s' % max_value) <add> f'value. Received: {max_value}') <ide> if negative_slope is None or negative_slope < 0.: <ide> raise ValueError('negative_slope of a ReLU layer cannot be a negative ' <del> 'value. Got: %s' % negative_slope) <add> f'value. Received: {negative_slope}') <ide> if threshold is None or threshold < 0.: <ide> raise ValueError('threshold of a ReLU layer cannot be a negative ' <del> 'value. Got: %s' % threshold) <add> f'value. Received: {threshold}') <ide> <ide> self.supports_masking = True <ide> if max_value is not None: <ide><path>keras/layers/advanced_activations_test.py <ide> def test_relu(self): <ide> def test_relu_with_invalid_max_value(self): <ide> with self.assertRaisesRegex( <ide> ValueError, 'max_value of a ReLU layer cannot be a negative ' <del> 'value. Got: -10'): <add> 'value. Received: -10'): <ide> testing_utils.layer_test( <ide> keras.layers.ReLU, <ide> kwargs={'max_value': -10}, <ide> def test_relu_with_invalid_max_value(self): <ide> def test_relu_with_invalid_negative_slope(self): <ide> with self.assertRaisesRegex( <ide> ValueError, 'negative_slope of a ReLU layer cannot be a negative ' <del> 'value. Got: None'): <add> 'value. Received: None'): <ide> testing_utils.layer_test( <ide> keras.layers.ReLU, <ide> kwargs={'negative_slope': None}, <ide> def test_relu_with_invalid_negative_slope(self): <ide> <ide> with self.assertRaisesRegex( <ide> ValueError, 'negative_slope of a ReLU layer cannot be a negative ' <del> 'value. Got: -10'): <add> 'value. Received: -10'): <ide> testing_utils.layer_test( <ide> keras.layers.ReLU, <ide> kwargs={'negative_slope': -10}, <ide> def test_relu_with_invalid_negative_slope(self): <ide> def test_relu_with_invalid_threshold(self): <ide> with self.assertRaisesRegex( <ide> ValueError, 'threshold of a ReLU layer cannot be a negative ' <del> 'value. Got: None'): <add> 'value. Received: None'): <ide> testing_utils.layer_test( <ide> keras.layers.ReLU, <ide> kwargs={'threshold': None}, <ide> def test_relu_with_invalid_threshold(self): <ide> <ide> with self.assertRaisesRegex( <ide> ValueError, 'threshold of a ReLU layer cannot be a negative ' <del> 'value. Got: -10'): <add> 'value. Received: -10'): <ide> testing_utils.layer_test( <ide> keras.layers.ReLU, <ide> kwargs={'threshold': -10}, <ide> def test_leaky_relu_with_invalid_alpha(self): <ide> # Test case for GitHub issue 46993. <ide> with self.assertRaisesRegex( <ide> ValueError, 'The alpha value of a Leaky ReLU layer ' <del> 'cannot be None, needs a float. Got None'): <add> 'cannot be None. Expecting a float. Received: None'): <ide> testing_utils.layer_test( <ide> keras.layers.LeakyReLU, <ide> kwargs={'alpha': None}, <ide> def test_leaky_elu_with_invalid_alpha(self): <ide> # Test case for GitHub issue 46993. <ide> with self.assertRaisesRegex( <ide> ValueError, 'Alpha of an ELU layer cannot be None, ' <del> 'requires a float. Got None'): <add> 'expecting a float. Received: None'): <ide> testing_utils.layer_test( <ide> keras.layers.ELU, <ide> kwargs={'alpha': None}, <ide> def test_leaky_elu_with_invalid_alpha(self): <ide> def test_threshold_relu_with_invalid_theta(self): <ide> with self.assertRaisesRegex( <ide> ValueError, 'Theta of a Thresholded ReLU layer cannot ' <del> 'be None, requires a float. Got None'): <add> 'be None, expecting a float. Received: None'): <ide> testing_utils.layer_test( <ide> keras.layers.ThresholdedReLU, <ide> kwargs={'theta': None}, <ide> def test_threshold_relu_with_invalid_theta(self): <ide> <ide> with self.assertRaisesRegex( <ide> ValueError, 'The theta value of a Thresholded ReLU ' <del> 'layer should be >=0, got -10'): <add> 'layer should be >=0. Received: -10'): <ide> testing_utils.layer_test( <ide> keras.layers.ThresholdedReLU, <ide> kwargs={'theta': -10}, <ide><path>keras/layers/embeddings.py <ide> def __init__(self, <ide> else: <ide> kwargs['input_shape'] = (None,) <ide> if input_dim <= 0 or output_dim <= 0: <del> raise ValueError('Both `input_dim` and `output_dim` should be positive, ' <del> 'found input_dim {} and output_dim {}'.format( <del> input_dim, output_dim)) <add> raise ValueError( <add> 'Both `input_dim` and `output_dim` should be positive, ' <add> f'Received input_dim = {input_dim} and output_dim = {output_dim}') <ide> if (not base_layer_utils.v2_dtype_behavior_enabled() and <ide> 'dtype' not in kwargs): <ide> # In TF1, the dtype defaults to the input dtype which is typically int32, <ide> def compute_output_shape(self, input_shape): <ide> else: <ide> in_lens = [self.input_length] <ide> if len(in_lens) != len(input_shape) - 1: <del> raise ValueError('"input_length" is %s, ' <del> 'but received input has shape %s' % (str( <del> self.input_length), str(input_shape))) <add> raise ValueError( <add> f'"input_length" is {self.input_length}, but received input has ' <add> f'shape {input_shape}') <ide> else: <ide> for i, (s1, s2) in enumerate(zip(in_lens, input_shape[1:])): <ide> if s1 is not None and s2 is not None and s1 != s2: <del> raise ValueError('"input_length" is %s, ' <del> 'but received input has shape %s' % (str( <del> self.input_length), str(input_shape))) <add> raise ValueError( <add> f'"input_length" is {self.input_length}, but received input ' <add> f'has shape {input_shape}') <ide> elif s1 is None: <ide> in_lens[i] = s2 <ide> return (input_shape[0],) + tuple(in_lens) + (self.output_dim,) <ide><path>keras/layers/wrappers.py <ide> def __init__(self, layer, **kwargs): <ide> if not isinstance(layer, Layer): <ide> raise ValueError( <ide> 'Please initialize `TimeDistributed` layer with a ' <del> '`tf.keras.layers.Layer` instance. You passed: {input}'.format( <del> input=layer)) <add> f'`tf.keras.layers.Layer` instance. Received: {layer}') <ide> super(TimeDistributed, self).__init__(layer, **kwargs) <ide> self.supports_masking = True <ide> <ide> def build(self, input_shape): <ide> if any(dim < 3 for dim in input_dims): <ide> raise ValueError( <ide> '`TimeDistributed` Layer should be passed an `input_shape ` ' <del> 'with at least 3 dimensions, received: ' + str(input_shape)) <add> f'with at least 3 dimensions, received: {input_shape}') <ide> # Don't enforce the batch or time dimension. <ide> self.input_spec = tf.nest.map_structure( <ide> lambda x: InputSpec(shape=[None, None] + x.as_list()[2:]), input_shape) <ide> def step(x, _): <ide> lambda x: x.nested_row_lengths()[0], inputs) <ide> y = self.layer(input_values, **kwargs) <ide> y = tf.nest.map_structure(tf.RaggedTensor.from_row_lengths, y, <del> input_row_lenghts) <add> input_row_lenghts) <ide> elif any(is_ragged_input): <ide> raise ValueError('All inputs has to be either ragged or not, ' <del> 'but not mixed. You passed: {}'.format(inputs)) <add> f'but not mixed. Received: {inputs}') <ide> else: <ide> input_length = tf_utils.convert_shapes(input_shape) <ide> input_length = tf.nest.flatten(input_length)[1] <ide> def __init__(self, <ide> if not isinstance(layer, Layer): <ide> raise ValueError( <ide> 'Please initialize `Bidirectional` layer with a ' <del> '`Layer` instance. You passed: {input}'.format(input=layer)) <add> f'`tf.keras.layers.Layer` instance. Received: {layer}') <ide> if backward_layer is not None and not isinstance(backward_layer, Layer): <del> raise ValueError('`backward_layer` need to be a `Layer` instance. ' <del> 'You passed: {input}'.format(input=backward_layer)) <add> raise ValueError( <add> '`backward_layer` need to be a `tf.keras.layers.Layer` instance. ' <add> f'Received: {backward_layer}') <ide> if merge_mode not in ['sum', 'mul', 'ave', 'concat', None]: <del> raise ValueError('Invalid merge mode. ' <add> raise ValueError(f'Invalid merge mode. Received: {merge_mode}. ' <ide> 'Merge mode should be one of ' <ide> '{"sum", "mul", "ave", "concat", None}') <ide> # We don't want to track `layer` since we're already tracking the two copies <ide> def force_zero_output_for_mask(layer): <ide> def _verify_layer_config(self): <ide> """Ensure the forward and backward layers have valid common property.""" <ide> if self.forward_layer.go_backwards == self.backward_layer.go_backwards: <del> raise ValueError('Forward layer and backward layer should have different ' <del> '`go_backwards` value.') <add> raise ValueError( <add> 'Forward layer and backward layer should have different ' <add> '`go_backwards` value.' <add> f'forward_layer.go_backwards = {self.forward_layer.go_backwards},' <add> f'backward_layer.go_backwards = {self.backward_layer.go_backwards}') <ide> <ide> common_attributes = ('stateful', 'return_sequences', 'return_state') <ide> for a in common_attributes: <ide> def _verify_layer_config(self): <ide> if forward_value != backward_value: <ide> raise ValueError( <ide> 'Forward layer and backward layer are expected to have the same ' <del> 'value for attribute {attr}, got {forward} and {backward}'.format( <del> attr=a, forward=forward_value, backward=backward_value)) <add> f'value for attribute "{a}", got "{forward_value}" for forward ' <add> f'layer and "{backward_value}" for backward layer') <ide> <ide> def _recreate_layer_from_config(self, layer, go_backwards=False): <ide> # When recreating the layer from its config, it is possible that the layer <ide> def __call__(self, inputs, initial_state=None, constants=None, **kwargs): <ide> 'When passing `initial_state` to a Bidirectional RNN, ' <ide> 'the state should be a list containing the states of ' <ide> 'the underlying RNNs. ' <del> 'Found: ' + str(initial_state)) <add> f'Received: {initial_state}') <ide> <ide> kwargs['initial_state'] = initial_state <ide> additional_inputs += initial_state <ide> def call(self, <ide> output = [y, y_rev] <ide> else: <ide> raise ValueError( <del> 'Unrecognized value for `merge_mode`: %s' % (self.merge_mode)) <add> f'Unrecognized value for `merge_mode`. Received: {self.merge_mode}' <add> 'Expected values are ["concat", "sum", "ave", "mul"]') <ide> <ide> if self.return_state: <ide> if self.merge_mode is None: <ide><path>keras/layers/wrappers_test.py <ide> def test_bidirectional_invalid_init(self): <ide> x = tf.constant(np.zeros((1, 1)).astype('float32')) <ide> with self.assertRaisesRegex( <ide> ValueError, <del> 'Please initialize `Bidirectional` layer with a `Layer` instance.'): <add> 'Please initialize `Bidirectional` layer with a ' <add> '`tf.keras.layers.Layer` instance.'): <ide> keras.layers.Bidirectional(x) <ide> <ide> def test_bidirectional_weight_loading(self): <ide> def test_custom_backward_layer_error_check(self): <ide> kwargs = {attr: True} <ide> backward_layer = rnn(units, go_backwards=True, **kwargs) <ide> with self.assertRaisesRegex( <del> ValueError, 'expected to have the same value for attribute ' + attr): <add> ValueError, 'expected to have the same value for attribute "' + attr): <ide> keras.layers.Bidirectional( <ide> forward_layer, merge_mode='concat', backward_layer=backward_layer) <ide>
5
PHP
PHP
fix incorrect type
fd8c0a48201d35c19adaf15013255087a0459b25
<ide><path>tests/TestCase/Database/QueryTest.php <ide> public function testSelectWhereTypes() <ide> 'id' => '1something-crazy', <ide> 'created <' => new \DateTime('2013-01-01 12:00') <ide> ], <del> ['created' => 'datetime', 'id' => 'float'] <add> ['created' => 'datetime', 'id' => 'integer'] <ide> ) <ide> ->execute(); <ide> $this->assertCount(1, $result);
1
Mixed
Python
simplify negotiation. drop msie hacks. etc
a96211d3d1ba246512af5e32c31726a666c467ac
<ide><path>djangorestframework/exceptions.py <ide> def __init__(self, detail=None): <ide> self.detail = detail or self.default_detail <ide> <ide> <add>class InvalidFormat(APIException): <add> status_code = status.HTTP_404_NOT_FOUND <add> default_detail = "Format suffix '.%s' not found." <add> <add> def __init__(self, format, detail=None): <add> self.detail = (detail or self.default_detail) % format <add> <add> <ide> class MethodNotAllowed(APIException): <ide> status_code = status.HTTP_405_METHOD_NOT_ALLOWED <ide> default_detail = "Method '%s' not allowed." <add><path>djangorestframework/negotiation.py <del><path>djangorestframework/contentnegotiation.py <ide> from djangorestframework import exceptions <ide> from djangorestframework.settings import api_settings <ide> from djangorestframework.utils.mediatypes import order_by_precedence <del>from django.http import Http404 <del>import re <del> <del>MSIE_USER_AGENT_REGEX = re.compile(r'^Mozilla/[0-9]+\.[0-9]+ \([^)]*; MSIE [0-9]+\.[0-9]+[a-z]?;[^)]*\)(?!.* Opera )') <ide> <ide> <ide> class BaseContentNegotiation(object): <ide> def negotiate(self, request, renderers, format=None, force=False): <ide> fallback renderer and media_type. <ide> """ <ide> try: <del> return self._negotiate(request, renderers, format) <del> except (Http404, exceptions.NotAcceptable): <add> return self.unforced_negotiate(request, renderers, format) <add> except (exceptions.InvalidFormat, exceptions.NotAcceptable): <ide> if force: <ide> return (renderers[0], renderers[0].media_type) <ide> raise <ide> <del> def _negotiate(self, request, renderers, format=None): <add> def unforced_negotiate(self, request, renderers, format=None): <ide> """ <del> Actual implementation of negotiate, inside the 'force' wrapper. <add> As `.negotiate()`, but does not take the optional `force` agument, <add> or suppress exceptions. <ide> """ <del> renderers = self.filter_renderers(renderers, format) <add> # Allow URL style format override. eg. "?format=json <add> format = format or request.GET.get(self.settings.URL_FORMAT_OVERRIDE) <add> <add> if format: <add> renderers = self.filter_renderers(renderers, format) <add> <ide> accepts = self.get_accept_list(request) <ide> <ide> # Check the acceptable media types against each renderer, <ide> def _negotiate(self, request, renderers, format=None): <ide> <ide> def filter_renderers(self, renderers, format): <ide> """ <del> If there is a '.json' style format suffix, only use <del> renderers that accept that format. <add> If there is a '.json' style format suffix, filter the renderers <add> so that we only negotiation against those that accept that format. <ide> """ <del> if not format: <del> return renderers <del> <ide> renderers = [renderer for renderer in renderers <ide> if renderer.can_handle_format(format)] <ide> if not renderers: <del> raise Http404() <add> raise exceptions.InvalidFormat(format) <add> return renderers <ide> <ide> def get_accept_list(self, request): <ide> """ <del> Given the incoming request, return a tokenised list of <del> media type strings. <del> """ <del> if self.settings.URL_ACCEPT_OVERRIDE: <del> # URL style accept override. eg. "?accept=application/json" <del> override = request.GET.get(self.settings.URL_ACCEPT_OVERRIDE) <del> if override: <del> return [override] <del> <del> if (self.settings.IGNORE_MSIE_ACCEPT_HEADER and <del> 'HTTP_USER_AGENT' in request.META and <del> MSIE_USER_AGENT_REGEX.match(request.META['HTTP_USER_AGENT']) and <del> request.META.get('HTTP_X_REQUESTED_WITH', '').lower() != 'xmlhttprequest'): <del> # Ignore MSIE's broken accept behavior except for AJAX requests <del> # and do something sensible instead <del> return ['text/html', '*/*'] <add> Given the incoming request, return a tokenised list of media <add> type strings. <ide> <del> if 'HTTP_ACCEPT' in request.META: <del> # Standard HTTP Accept negotiation <del> # Accept header specified <del> tokens = request.META['HTTP_ACCEPT'].split(',') <del> return [token.strip() for token in tokens] <del> <del> # Standard HTTP Accept negotiation <del> # No accept header specified <del> return ['*/*'] <add> Allows URL style accept override. eg. "?accept=application/json" <add> """ <add> header = request.META.get('HTTP_ACCEPT', '*/*') <add> header = request.GET.get(self.settings.URL_ACCEPT_OVERRIDE, header) <add> return [token.strip() for token in header.split(',')] <ide><path>djangorestframework/response.py <ide> def __init__(self, data=None, status=None, headers=None, <ide> <ide> @property <ide> def rendered_content(self): <del> self['Content-Type'] = self.media_type <add> self['Content-Type'] = self.renderer.media_type <ide> if self.data is None: <ide> return self.renderer.render() <ide> return self.renderer.render(self.data, self.media_type) <ide><path>djangorestframework/settings.py <ide> ), <ide> 'DEFAULT_PERMISSIONS': (), <ide> 'DEFAULT_THROTTLES': (), <del> 'DEFAULT_CONTENT_NEGOTIATION': 'djangorestframework.contentnegotiation.DefaultContentNegotiation', <add> 'DEFAULT_CONTENT_NEGOTIATION': 'djangorestframework.negotiation.DefaultContentNegotiation', <ide> <ide> 'UNAUTHENTICATED_USER': 'django.contrib.auth.models.AnonymousUser', <ide> 'UNAUTHENTICATED_TOKEN': None, <ide> <ide> 'FORM_METHOD_OVERRIDE': '_method', <ide> 'FORM_CONTENT_OVERRIDE': '_content', <ide> 'FORM_CONTENTTYPE_OVERRIDE': '_content_type', <del> 'URL_ACCEPT_OVERRIDE': 'accept', <del> 'IGNORE_MSIE_ACCEPT_HEADER': True, <add> 'URL_ACCEPT_OVERRIDE': '_accept', <add> 'URL_FORMAT_OVERRIDE': 'format', <ide> <ide> 'FORMAT_SUFFIX_KWARG': 'format' <ide> } <ide><path>djangorestframework/tests/renderers.py <ide> def test_specified_renderer_is_used_on_format_query_with_matching_accept(self): <ide> self.assertEquals(resp.content, RENDERER_B_SERIALIZER(DUMMYCONTENT)) <ide> self.assertEquals(resp.status_code, DUMMYSTATUS) <ide> <del> def test_conflicting_format_query_and_accept_ignores_accept(self): <del> """If a 'format' query is specified that does not match the Accept <del> header, we should only honor the 'format' query string.""" <del> resp = self.client.get('/?format=%s' % RendererB.format, <del> HTTP_ACCEPT='dummy') <del> self.assertEquals(resp['Content-Type'], RendererB.media_type) <del> self.assertEquals(resp.content, RENDERER_B_SERIALIZER(DUMMYCONTENT)) <del> self.assertEquals(resp.status_code, DUMMYSTATUS) <del> <ide> <ide> _flat_repr = '{"foo": ["bar", "baz"]}' <ide> _indented_repr = '{\n "foo": [\n "bar",\n "baz"\n ]\n}' <ide><path>djangorestframework/tests/response.py <del>import json <ide> import unittest <ide> <ide> from django.conf.urls.defaults import patterns, url, include <ide> from django.test import TestCase <ide> <ide> from djangorestframework.response import Response <ide> from djangorestframework.views import APIView <del>from djangorestframework.compat import RequestFactory <del>from djangorestframework import status, exceptions <add>from djangorestframework import status <ide> from djangorestframework.renderers import ( <ide> BaseRenderer, <ide> JSONRenderer, <del> DocumentingHTMLRenderer, <del> DEFAULT_RENDERERS <add> DocumentingHTMLRenderer <ide> ) <ide> <ide> <ide> class MockJsonRenderer(BaseRenderer): <ide> media_type = 'application/json' <ide> <ide> <del>class TestResponseDetermineRenderer(TestCase): <del> <del> def get_response(self, url='', accept_list=[], renderer_classes=[]): <del> kwargs = {} <del> if accept_list is not None: <del> kwargs['HTTP_ACCEPT'] = ','.join(accept_list) <del> request = RequestFactory().get(url, **kwargs) <del> return Response(request=request, renderer_classes=renderer_classes) <del> <del> def test_determine_accept_list_accept_header(self): <del> """ <del> Test that determine_accept_list takes the Accept header. <del> """ <del> accept_list = ['application/pickle', 'application/json'] <del> response = self.get_response(accept_list=accept_list) <del> self.assertEqual(response._determine_accept_list(), accept_list) <del> <del> def test_determine_accept_list_default(self): <del> """ <del> Test that determine_accept_list takes the default renderer if Accept is not specified. <del> """ <del> response = self.get_response(accept_list=None) <del> self.assertEqual(response._determine_accept_list(), ['*/*']) <del> <del> def test_determine_accept_list_overriden_header(self): <del> """ <del> Test Accept header overriding. <del> """ <del> accept_list = ['application/pickle', 'application/json'] <del> response = self.get_response(url='?_accept=application/x-www-form-urlencoded', <del> accept_list=accept_list) <del> self.assertEqual(response._determine_accept_list(), ['application/x-www-form-urlencoded']) <del> <del> def test_determine_renderer(self): <del> """ <del> Test that right renderer is chosen, in the order of Accept list. <del> """ <del> accept_list = ['application/pickle', 'application/json'] <del> renderer_classes = (MockPickleRenderer, MockJsonRenderer) <del> response = self.get_response(accept_list=accept_list, renderer_classes=renderer_classes) <del> renderer, media_type = response._determine_renderer() <del> self.assertEqual(media_type, 'application/pickle') <del> self.assertTrue(isinstance(renderer, MockPickleRenderer)) <del> <del> renderer_classes = (MockJsonRenderer, ) <del> response = self.get_response(accept_list=accept_list, renderer_classes=renderer_classes) <del> renderer, media_type = response._determine_renderer() <del> self.assertEqual(media_type, 'application/json') <del> self.assertTrue(isinstance(renderer, MockJsonRenderer)) <del> <del> def test_determine_renderer_default(self): <del> """ <del> Test determine renderer when Accept was not specified. <del> """ <del> renderer_classes = (MockPickleRenderer, ) <del> response = self.get_response(accept_list=None, renderer_classes=renderer_classes) <del> renderer, media_type = response._determine_renderer() <del> self.assertEqual(media_type, '*/*') <del> self.assertTrue(isinstance(renderer, MockPickleRenderer)) <del> <del> def test_determine_renderer_no_renderer(self): <del> """ <del> Test determine renderer when no renderer can satisfy the Accept list. <del> """ <del> accept_list = ['application/json'] <del> renderer_classes = (MockPickleRenderer, ) <del> response = self.get_response(accept_list=accept_list, renderer_classes=renderer_classes) <del> self.assertRaises(exceptions.NotAcceptable, response._determine_renderer) <del> <del> <del>class TestResponseRenderContent(TestCase): <del> def get_response(self, url='', accept_list=[], content=None, renderer_classes=None): <del> request = RequestFactory().get(url, HTTP_ACCEPT=','.join(accept_list)) <del> return Response(request=request, content=content, renderer_classes=renderer_classes or DEFAULT_RENDERERS) <del> <del> def test_render(self): <del> """ <del> Test rendering simple data to json. <del> """ <del> content = {'a': 1, 'b': [1, 2, 3]} <del> content_type = 'application/json' <del> response = self.get_response(accept_list=[content_type], content=content) <del> response = response.render() <del> self.assertEqual(json.loads(response.content), content) <del> self.assertEqual(response['Content-Type'], content_type) <del> <del> def test_render_no_renderer(self): <del> """ <del> Test rendering response when no renderer can satisfy accept. <del> """ <del> content = 'bla' <del> content_type = 'weirdcontenttype' <del> response = self.get_response(accept_list=[content_type], content=content) <del> response = response.render() <del> self.assertEqual(response.status_code, 406) <del> self.assertIsNotNone(response.content) <del> <del> # def test_render_renderer_raises_ImmediateResponse(self): <del> # """ <del> # Test rendering response when renderer raises ImmediateResponse <del> # """ <del> # class PickyJSONRenderer(BaseRenderer): <del> # """ <del> # A renderer that doesn't make much sense, just to try <del> # out raising an ImmediateResponse <del> # """ <del> # media_type = 'application/json' <del> <del> # def render(self, obj=None, media_type=None): <del> # raise ImmediateResponse({'error': '!!!'}, status=400) <del> <del> # response = self.get_response( <del> # accept_list=['application/json'], <del> # renderers=[PickyJSONRenderer, JSONRenderer] <del> # ) <del> # response = response.render() <del> # self.assertEqual(response.status_code, 400) <del> # self.assertEqual(response.content, json.dumps({'error': '!!!'})) <del> <del> <ide> DUMMYSTATUS = status.HTTP_200_OK <ide> DUMMYCONTENT = 'dummycontent' <ide> <ide> def test_specified_renderer_is_used_on_format_query_with_matching_accept(self): <ide> self.assertEquals(resp.content, RENDERER_B_SERIALIZER(DUMMYCONTENT)) <ide> self.assertEquals(resp.status_code, DUMMYSTATUS) <ide> <del> def test_conflicting_format_query_and_accept_ignores_accept(self): <del> """If a 'format' query is specified that does not match the Accept <del> header, we should only honor the 'format' query string.""" <del> resp = self.client.get('/?format=%s' % RendererB.format, <del> HTTP_ACCEPT='dummy') <del> self.assertEquals(resp['Content-Type'], RendererB.media_type) <del> self.assertEquals(resp.content, RENDERER_B_SERIALIZER(DUMMYCONTENT)) <del> self.assertEquals(resp.status_code, DUMMYSTATUS) <del> <ide> <ide> class Issue122Tests(TestCase): <ide> """ <ide><path>docs/api-guide/content-negotiation.md <add><a class="github" href="negotiation.py"></a> <add> <ide> # Content negotiation <ide> <ide> > HTTP has provisions for several mechanisms for "content negotiation" - the process of selecting the best representation for a given response when there are multiple representations available. <ide><path>docs/topics/rest-hypermedia-hateoas.md <add>> You keep using that word "REST". I do not think it means what you think it means. <add>> <add>> &mdash; Mike Amundsen, [talking at REST fest 2012][cite]. <add> <add># REST, Hypermedia & HATEOAS <add> <add>First off, the disclaimer. The name "Django REST framework" was choosen with a view to making sure the project would be easily found by developers. Throughout the documentation we try to use the more simple and technically correct terminology of "Web APIs". <add> <add>If you are serious about designing a Hypermedia APIs, you should look to resources outside of this documentation to help inform your design choices. <add> <add>The following fall into the "required reading" category. <add> <add>* Fielding's dissertation - [Architectural Styles and <add>the Design of Network-based Software Architectures][dissertation]. <add>* Fielding's "[REST APIs must be hypertext-driven][hypertext-driven]" blog post. <add>* Leonard Richardson & Sam Ruby's [RESTful Web Services][restful-web-services]. <add>* Mike Amundsen's [Building Hypermedia APIs with HTML5 and Node][building-hypermedia-apis]. <add>* Steve Klabnik's [Designing Hypermedia APIs][designing-hypermedia-apis]. <add>* The [Richardson Maturity Model][maturitymodel]. <add> <add>For a more thorough background, check out Klabnik's [Hypermedia API reading list][readinglist]. <add> <add># Building Hypermedia APIs with REST framework <add> <add>REST framework is an agnositic Web API toolkit. It does help guide you towards building well-connected APIs, and makes it easy to design appropriate media types, but it does not strictly enforce any particular design style. <add> <add>### What REST framework *does* provide. <add> <add>It is self evident that REST framework makes it possible to build Hypermedia APIs. The browseable API that it offers is built on HTML - the hypermedia language of the web. <add> <add>REST framework also includes [serialization] and [parser]/[renderer] components that make it easy to build appropriate media types, [hyperlinked relations][fields] for building well-connected systems, and great support for [content negotiation][conneg]. <add> <add>### What REST framework *doesn't* provide. <add> <add>What REST framework doesn't do is give you is machine readable hypermedia formats such as [Collection+JSON][collection] by default, or the ability to auto-magically create HATEOAS style APIs. Doing so would involve making opinionated choices about API design that should really remain outside of the framework's scope. <add> <add>[cite]: http://vimeo.com/channels/restfest/page:2 <add>[dissertation]: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm <add>[hypertext-driven]: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven <add>[restful-web-services]: <add>[building-hypermedia-apis]: … <add>[designing-hypermedia-apis]: http://designinghypermediaapis.com/ <add>[restisover]: http://blog.steveklabnik.com/posts/2012-02-23-rest-is-over <add>[readinglist]: http://blog.steveklabnik.com/posts/2012-02-27-hypermedia-api-reading-list <add>[maturitymodel]: http://martinfowler.com/articles/richardsonMaturityModel.html <add> <add>[collection]: http://www.amundsen.com/media-types/collection/ <add>[serialization]: ../api-guide/serializers.md <add>[parser]: ../api-guide/parsers.md <add>[renderer]: ../api-guide/renderers.md <add>[fields]: ../api-guide/fields.md <add>[conneg]: ../api-guide/content-negotiation.md <ide>\ No newline at end of file
8
Go
Go
fix remaining compile issues
318b1612e1a74f1313d5bd087050cd535f267bd5
<ide><path>integration-cli/docker_cli_run_test.go <ide> import ( <ide> "time" <ide> <ide> "github.com/docker/docker/client" <del> "github.com/docker/docker/integration-cli/checker" <ide> "github.com/docker/docker/integration-cli/cli" <ide> "github.com/docker/docker/integration-cli/cli/build" <ide> "github.com/docker/docker/internal/test/fakecontext" <ide> func (s *DockerSuite) TestRunAttachFailedNoLeak(c *testing.T) { <ide> strings.Contains(string(out), "were not connected because a duplicate name exists") || <ide> strings.Contains(string(out), "The specified port already exists") || <ide> strings.Contains(string(out), "HNS failed with error : Failed to create endpoint") || <del> strings.Contains(string(out), "HNS failed with error : The object already exists"), checker.Equals, true, fmt.Sprintf("Output: %s", out)) <add> strings.Contains(string(out), "HNS failed with error : The object already exists"), fmt.Sprintf("Output: %s", out)) <ide> dockerCmd(c, "rm", "-f", "test") <ide> <ide> // NGoroutines is not updated right away, so we need to wait before failing <ide><path>integration-cli/docker_utils_test.go <ide> func waitAndAssert(t assert.TestingT, timeout time.Duration, f checkF, compariso <ide> default: <ide> } <ide> if shouldAssert { <del> if comment != nil { <del> args = append(args, comment.CheckCommentString()) <add> if len(comment) > 0 { <add> args = append(args, comment) <ide> } <ide> assert.Assert(t, comparison, args...) <ide> return <ide> func reducedCheck(r reducer, funcs ...checkF) checkF { <ide> for _, f := range funcs { <ide> v, comment := f(c) <ide> values = append(values, v) <del> if comment != nil { <del> comments = append(comments, comment.CheckCommentString()) <add> if len(comment) > 0 { <add> comments = append(comments, comment) <ide> } <ide> } <ide> return r(values...), fmt.Sprintf("%v", strings.Join(comments, ", "))
2
Python
Python
add examples to doc
9a0a8c1c6f4f2f0c80ff07d36713a3ada785eec5
<ide><path>src/transformers/configuration_encoder_decoder.py <ide> class EncoderDecoderConfig(PretrainedConfig): <ide> r""" <ide> :class:`~transformers.EncoderDecoderConfig` is the configuration class to store the configuration of a `EncoderDecoderModel`. <ide> <del> It is used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder configs. <del> Configuration objects inherit from :class:`~transformers.PretrainedConfig` <del> and can be used to control the model outputs. <del> See the documentation for :class:`~transformers.PretrainedConfig` for more information. <del> <del> <del> Arguments: <del> kwargs: (`optional`) Remaining dictionary of keyword arguments. Notably: <del> encoder (:class:`PretrainedConfig`, optional, defaults to `None`): <del> An instance of a configuration object that defines the encoder config. <del> encoder (:class:`PretrainedConfig`, optional, defaults to `None`): <del> An instance of a configuration object that defines the decoder config. <add> It is used to instantiate an Encoder Decoder model according to the specified arguments, defining the encoder and decoder configs. <add> Configuration objects inherit from :class:`~transformers.PretrainedConfig` <add> and can be used to control the model outputs. <add> See the documentation for :class:`~transformers.PretrainedConfig` for more information. <add> <add> Args: <add> kwargs (`optional`): <add> Remaining dictionary of keyword arguments. Notably: <add> encoder (:class:`PretrainedConfig`, optional, defaults to `None`): <add> An instance of a configuration object that defines the encoder config. <add> encoder (:class:`PretrainedConfig`, optional, defaults to `None`): <add> An instance of a configuration object that defines the decoder config. <add> <add> Example:: <add> <add> from transformers import BertConfig, EncoderDecoderConfig, EncoderDecoderModel <add> <add> # Initializing a BERT bert-base-uncased style configuration <add> config_encoder = BertConfig() <add> config_decoder = BertConfig() <add> <add> config = EncoderDecoderConfig.from_encoder_decoder_configs(config_encoder, config_decoder) <add> <add> # Initializing a Bert2Bert model from the bert-base-uncased style configurations <add> model = EncoderDecoderModel(config=config) <add> <add> # Accessing the model configuration <add> config_encoder = model.config.encoder <add> config_decoder = model.config.decoder <ide> """ <ide> model_type = "encoder_decoder" <ide> <ide><path>src/transformers/modeling_encoder_decoder.py <ide> def from_encoder_decoder_pretrained( <ide> <ide> Examples:: <ide> <add> from tranformers import EncoderDecoder <add> <ide> model = EncoderDecoder.from_encoder_decoder_pretrained('bert-base-uncased', 'bert-base-uncased') # initialize Bert2Bert <ide> """ <ide> <ide> def forward( <ide> kwargs: (`optional`) Remaining dictionary of keyword arguments. Keyword arguments come in two flavors: <ide> - Without a prefix which will be input as `**encoder_kwargs` for the encoder forward function. <ide> - With a `decoder_` prefix which will be input as `**decoder_kwargs` for the decoder forward function. <add> <add> Examples:: <add> <add> from transformers import EncoderDecoderModel, BertTokenizer <add> import torch <add> <add> tokenizer = BertTokenizer.from_pretrained('bert-base-uncased') <add> model = EncoderDecoderModel.from_encoder_decoder_pretrained('bert-base-uncased', 'bert-base-uncased') # initialize Bert2Bert <add> <add> # forward <add> input_ids = torch.tensor(tokenizer.encode("Hello, my dog is cute", add_special_tokens=True)).unsqueeze(0) # Batch size 1 <add> outputs = model(input_ids=input_ids, decoder_input_ids=input_ids) <add> <add> # training <add> loss, outputs = model(input_ids=input_ids, decoder_input_ids=input_ids, lm_labels=input_ids)[:2] <add> <add> # generation <add> generated = model.generate(input_ids, decoder_start_token_id=model.config.decoder.pad_token_id) <add> <ide> """ <ide> <ide> kwargs_encoder = {argument: value for argument, value in kwargs.items() if not argument.startswith("decoder_")}
2
Javascript
Javascript
add compatibility for older node.js versions
e632b1b7eeb0900472c710ae7269111d985de018
<ide><path>lib/internal/assert/assertion_error.js <ide> class AssertionError extends Error { <ide> const { <ide> message, <ide> operator, <del> stackStartFn <add> stackStartFn, <add> // Compatibility with older versions. <add> stackStartFunction <ide> } = options; <ide> let { <ide> actual, <ide> class AssertionError extends Error { <ide> this.expected = expected; <ide> this.operator = operator; <ide> // eslint-disable-next-line no-restricted-syntax <del> Error.captureStackTrace(this, stackStartFn); <add> Error.captureStackTrace(this, stackStartFn || stackStartFunction); <ide> // Create error message including the error code in the name. <ide> this.stack; <ide> // Reset the name. <ide><path>test/parallel/test-assert.js <ide> assert.throws( <ide> () => a.deepStrictEqual(), <ide> { code: 'ERR_MISSING_ARGS' } <ide> ); <add> <add>// Verify that `stackStartFunction` works as alternative to `stackStartFn`. <add>{ <add> (function hidden() { <add> const err = new assert.AssertionError({ <add> actual: 'foo', <add> operator: 'strictEqual', <add> stackStartFunction: hidden <add> }); <add> const err2 = new assert.AssertionError({ <add> actual: 'foo', <add> operator: 'strictEqual', <add> stackStartFn: hidden <add> }); <add> assert(!err.stack.includes('hidden')); <add> assert(!err2.stack.includes('hidden')); <add> })(); <add>}
2
Python
Python
remove the added json parameter
dcd0fe5f1f0f8cfc8e065498c431bd08ec54996c
<ide><path>libcloud/http.py <ide> def verification(self): <ide> return self.ca_cert if self.ca_cert is not None else self.verify <ide> <ide> def request(self, method, url, body=None, headers=None, raw=False, <del> stream=False, json=None): <add> stream=False): <ide> url = urlparse.urljoin(self.host, url) <ide> headers = self._normalize_headers(headers=headers) <ide> <ide> def request(self, method, url, body=None, headers=None, raw=False, <ide> headers=headers, <ide> allow_redirects=ALLOW_REDIRECTS, <ide> stream=stream, <del> verify=self.verification, <del> json=json <add> verify=self.verification <ide> ) <ide> <ide> def prepared_request(self, method, url, body=None, <ide><path>libcloud/test/__init__.py <ide> def _get_request(self, method, url, body=None, headers=None): <ide> self.test._add_executed_mock_method(method_name=meth_name) <ide> return meth(method, url, body, headers) <ide> <del> def request(self, method, url, body=None, headers=None, raw=False, stream=False, json=None): <add> def request(self, method, url, body=None, headers=None, raw=False, stream=False): <ide> headers = self._normalize_headers(headers=headers) <ide> r_status, r_body, r_headers, r_reason = self._get_request(method, url, body, headers) <ide> if r_body is None:
2
Text
Text
add id for es6 module breakout
4aecaeb33e8d70297d73e7bb12eea948dce99e8c
<ide><path>threejs/lessons/threejs-fundamentals.md <ide> a different color. <ide> I hope this short intro helps to get things started. [Next up we'll cover <ide> making our code responsive so it is adaptable to multiple situations](threejs-responsive.html). <ide> <del><div class="threejs_bottombar"> <add><div id="es6" class="threejs_bottombar"> <ide> <h3>es6 modules, three.js, and folder structure</h3> <ide> <p>As of version r106 the preferred way to use three.js is via <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import">es6 modules</a>.</p> <ide> <p>
1
Text
Text
update checklist boxes in pull request template
f9a8e11de6ae33e8a2d3e280ad79ce1635876ec5
<ide><path>.github/PULL_REQUEST_TEMPLATE.md <ide> Checklist: <ide> <ide> <!-- Please follow this checklist and put an x in each of the boxes, like this: [x]. It will ensure that our team takes your pull request seriously. --> <ide> <del>- [ ] I have read [freeCodeCamp's contribution guidelines](https://contribute.freecodecamp.org). <del>- [ ] My pull request has a descriptive title (not a vague title like `Update index.md`) <del>- [ ] My pull request targets the `main` branch of freeCodeCamp. <del>- [ ] I have tested these changes either locally on my machine, or GitPod. <add>- [] I have read [freeCodeCamp's contribution guidelines](https://contribute.freecodecamp.org). <add>- [] My pull request has a descriptive title (not a vague title like `Update index.md`) <add>- [] My pull request targets the `main` branch of freeCodeCamp. <add>- [] I have tested these changes either locally on my machine, or GitPod. <ide> <ide> <!--If your pull request closes a GitHub issue, replace the XXXXX below with the issue number.--> <ide>
1
Ruby
Ruby
use system path for more tools, for linux compat
51d1a8e3c5e1a0119837304c7678a3287eb66a67
<ide><path>Library/Homebrew/cmd/doctor.rb <ide> def check_for_multiple_volumes <ide> real_cellar = HOMEBREW_CELLAR.realpath <ide> <ide> tmp_prefix = ENV['HOMEBREW_TEMP'] || '/tmp' <del> tmp = Pathname.new `/usr/bin/mktemp -d #{tmp_prefix}/homebrew-brew-doctor-XXXX`.strip <add> tmp = Pathname.new with_system_path { `mktemp -d #{tmp_prefix}/homebrew-brew-doctor-XXXX` }.strip <ide> real_temp = tmp.realpath.parent <ide> <ide> where_cellar = volumes.which real_cellar <ide><path>Library/Homebrew/formula.rb <ide> def patch <ide> ohai "Patching" <ide> patch_list.each do |p| <ide> case p.compression <del> when :gzip then safe_system "/usr/bin/gunzip", p.compressed_filename <del> when :bzip2 then safe_system "/usr/bin/bunzip2", p.compressed_filename <add> when :gzip then with_system_path { safe_system "gunzip", p.compressed_filename } <add> when :bzip2 then with_system_path { safe_system "bunzip2", p.compressed_filename } <ide> end <ide> # -f means don't prompt the user if there are errors; just exit with non-zero status <ide> safe_system '/usr/bin/patch', '-f', *(p.patch_args) <ide><path>Library/Homebrew/utils.rb <ide> def safe_exec cmd, *args <ide> # GZips the given paths, and returns the gzipped paths <ide> def gzip *paths <ide> paths.collect do |path| <del> system "/usr/bin/gzip", path <add> with_system_path { safe_system 'gzip', path } <ide> Pathname.new("#{path}.gz") <ide> end <ide> end
3
Ruby
Ruby
remove debug message
243ff024e3944dedceb0d64712869385fc965d89
<ide><path>Library/Homebrew/cmd/info.rb <ide> def print_json(args:) <ide> if args.bottle? <ide> { "formulae" => formulae.map(&:to_recursive_bottle_hash) } <ide> elsif args.variations? <del> opoo "a" <ide> { <ide> "formulae" => formulae.map(&:to_hash_with_variations), <ide> "casks" => casks.map(&:to_hash_with_variations),
1
Javascript
Javascript
add loaders es6 unit tests
f74b17963d5e16c0195771b1aaa2e9b0727fbf48
<ide><path>test/unit/src/loaders/AnimationLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { AnimationLoader } from '../../../../src/loaders/AnimationLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'AnimationLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/AudioLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { AudioLoader } from '../../../../src/loaders/AudioLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'AudioLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/BufferGeometryLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { BufferGeometryLoader } from '../../../../src/loaders/BufferGeometryLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'BufferGeometryLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/Cache.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { Cache } from '../../../../src/loaders/Cache'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'Cache', () => { <add> <add> // PUBLIC STUFF <add> QUnit.test( "add", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "get", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "remove", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "clear", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/CompressedTextureLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { CompressedTextureLoader } from '../../../../src/loaders/CompressedTextureLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'CompressedTextureLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/CubeTextureLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { CubeTextureLoader } from '../../../../src/loaders/CubeTextureLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'CubeTextureLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setCrossOrigin", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/DataTextureLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { DataTextureLoader } from '../../../../src/loaders/DataTextureLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'DataTextureLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/FileLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { FileLoader } from '../../../../src/loaders/FileLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'FileLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setResponseType", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setWithCredentials", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setMimeType", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setRequestHeader", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/FontLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { FontLoader } from '../../../../src/loaders/FontLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'FontLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/ImageLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { ImageLoader } from '../../../../src/loaders/ImageLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'ImageLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setCrossOrigin", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/JSONLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { JSONLoader } from '../../../../src/loaders/JSONLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'JSONLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setTexturePath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/Loader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { Loader } from '../../../../src/loaders/Loader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'Loader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // STATIC STUFF <add> QUnit.test( "Handlers.add", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "Handlers.get", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "extractUrlBase", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "initMaterials", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "createMaterial", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/LoadingManager.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { LoadingManager } from '../../../../src/loaders/LoadingManager'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'LoadingManager', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "onStart", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "onLoad", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "onProgress", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "onError", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "itemStart", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "itemEnd", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "itemError", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/MaterialLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { MaterialLoader } from '../../../../src/loaders/MaterialLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'MaterialLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setTextures", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/ObjectLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { ObjectLoader } from '../../../../src/loaders/ObjectLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'ObjectLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setTexturePath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setCrossOrigin", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parse", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseGeometries", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseMaterials", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseAnimations", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseImages", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseTextures", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "parseObject", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} ); <ide><path>test/unit/src/loaders/TextureLoader.tests.js <add>/** <add> * @author TristanVALCKE / https://github.com/Itee <add> */ <add>/* global QUnit */ <add> <add>import { TextureLoader } from '../../../../src/loaders/TextureLoader'; <add> <add>export default QUnit.module( 'Loaders', () => { <add> <add> QUnit.module.todo( 'TextureLoader', () => { <add> <add> // INSTANCING <add> QUnit.test( "Instancing", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> // PUBLIC STUFF <add> QUnit.test( "load", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setCrossOrigin", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> QUnit.test( "setPath", ( assert ) => { <add> <add> assert.ok( false, "everything's gonna be alright" ); <add> <add> } ); <add> <add> } ); <add> <add>} );
16
Python
Python
add a note about record array dtypes
7e6021ebcd3529e8c952b675090ec40f2f17db84
<ide><path>numpy/typing/__init__.py <ide> 0D-array -> scalar cast, then one can consider manually remedying the <ide> situation with either `typing.cast` or a ``# type: ignore`` comment. <ide> <add>Record array dtypes <add>~~~~~~~~~~~~~~~~~~~ <add> <add>The dtype of `numpy.recarray`, and the `numpy.rec` functions in general, <add>can be specified in one of two ways: <add> <add>* Directly via the ``dtype`` argument. <add>* With up to five helper arguments that operate via `numpy.format_parser`: <add> ``formats``, ``names``, ``titles``, ``aligned`` and ``byteorder``. <add> <add>These two approaches are currently typed as being mutually exclusive, <add>*i.e.* if ``dtype`` is specified than one may not specify ``formats``. <add>While this mutual exclusivity is not (strictly) enforced during runtime, <add>combining both dtype specifiers can lead to unexpected or even downright <add>buggy behavior. <add> <ide> API <ide> --- <ide>
1
Ruby
Ruby
rename the last occurrence of unexpectedparameters
0102c817bfb8ca6810732e02a6eee888935a1b92
<ide><path>actionpack/test/controller/parameters/raise_on_unpermitted_parameters_test.rb <ide> def teardown <ide> fishing: "Turnips" <ide> }) <ide> <del> assert_raises(ActionController::UnexpectedParameters) do <add> assert_raises(ActionController::UnpermittedParameters) do <ide> params.permit(book: [:pages]) <ide> end <ide> end <ide> def teardown <ide> book: { pages: 65, title: "Green Cats and where to find then." } <ide> }) <ide> <del> assert_raises(ActionController::UnexpectedParameters) do <add> assert_raises(ActionController::UnpermittedParameters) do <ide> params.permit(book: [:pages]) <ide> end <ide> end
1
Javascript
Javascript
use object.create(null) directly
cfc8422a68c92808a4a2aee374623bebc768522a
<ide><path>lib/_http_outgoing.js <ide> const common = require('_http_common'); <ide> const checkIsHttpToken = common._checkIsHttpToken; <ide> const checkInvalidHeaderChar = common._checkInvalidHeaderChar; <ide> const outHeadersKey = require('internal/http').outHeadersKey; <del>const StorageObject = require('internal/querystring').StorageObject; <ide> <ide> const CRLF = common.CRLF; <ide> const debug = common.debug; <ide> Object.defineProperty(OutgoingMessage.prototype, '_headerNames', { <ide> get: function() { <ide> const headers = this[outHeadersKey]; <ide> if (headers) { <del> const out = new StorageObject(); <add> const out = Object.create(null); <ide> const keys = Object.keys(headers); <ide> for (var i = 0; i < keys.length; ++i) { <ide> const key = keys[i]; <ide> OutgoingMessage.prototype.getHeaderNames = function getHeaderNames() { <ide> // Returns a shallow copy of the current outgoing headers. <ide> OutgoingMessage.prototype.getHeaders = function getHeaders() { <ide> const headers = this[outHeadersKey]; <del> const ret = new StorageObject(); <add> const ret = Object.create(null); <ide> if (headers) { <ide> const keys = Object.keys(headers); <ide> for (var i = 0; i < keys.length; ++i) { <ide><path>lib/events.js <ide> <ide> var domain; <ide> <del>// This constructor is used to store event handlers. Instantiating this is <del>// faster than explicitly calling `Object.create(null)` to get a "clean" empty <del>// object (tested with v8 v4.9). <del>function EventHandlers() {} <del>EventHandlers.prototype = Object.create(null); <del> <ide> function EventEmitter() { <ide> EventEmitter.init.call(this); <ide> } <ide> EventEmitter.init = function() { <ide> } <ide> <ide> if (!this._events || this._events === Object.getPrototypeOf(this)._events) { <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> this._eventsCount = 0; <ide> } <ide> <ide> function _addListener(target, type, listener, prepend) { <ide> <ide> events = target._events; <ide> if (!events) { <del> events = target._events = new EventHandlers(); <add> events = target._events = Object.create(null); <ide> target._eventsCount = 0; <ide> } else { <ide> // To avoid recursion in the case that type === "newListener"! Before <ide> EventEmitter.prototype.removeListener = <ide> <ide> if (list === listener || list.listener === listener) { <ide> if (--this._eventsCount === 0) <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> else { <ide> delete events[type]; <ide> if (events.removeListener) <ide> EventEmitter.prototype.removeListener = <ide> if (list.length === 1) { <ide> list[0] = undefined; <ide> if (--this._eventsCount === 0) { <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> return this; <ide> } else { <ide> delete events[type]; <ide> EventEmitter.prototype.removeAllListeners = <ide> // not listening for removeListener, no need to emit <ide> if (!events.removeListener) { <ide> if (arguments.length === 0) { <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> this._eventsCount = 0; <ide> } else if (events[type]) { <ide> if (--this._eventsCount === 0) <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> else <ide> delete events[type]; <ide> } <ide> EventEmitter.prototype.removeAllListeners = <ide> this.removeAllListeners(key); <ide> } <ide> this.removeAllListeners('removeListener'); <del> this._events = new EventHandlers(); <add> this._events = Object.create(null); <ide> this._eventsCount = 0; <ide> return this; <ide> } <ide><path>lib/fs.js <ide> const internalUtil = require('internal/util'); <ide> const assertEncoding = internalFS.assertEncoding; <ide> const stringToFlags = internalFS.stringToFlags; <ide> const getPathFromURL = internalURL.getPathFromURL; <del>const { StorageObject } = require('internal/querystring'); <ide> <ide> Object.defineProperty(exports, 'constants', { <ide> configurable: false, <ide> if (isWindows) { <ide> nextPart = function nextPart(p, i) { return p.indexOf('/', i); }; <ide> } <ide> <del>const emptyObj = new StorageObject(); <add>const emptyObj = Object.create(null); <ide> fs.realpathSync = function realpathSync(p, options) { <ide> if (!options) <ide> options = emptyObj; <ide> fs.realpathSync = function realpathSync(p, options) { <ide> return maybeCachedResult; <ide> } <ide> <del> const seenLinks = new StorageObject(); <del> const knownHard = new StorageObject(); <add> const seenLinks = Object.create(null); <add> const knownHard = Object.create(null); <ide> const original = p; <ide> <ide> // current character position in p <ide> fs.realpath = function realpath(p, options, callback) { <ide> return; <ide> p = pathModule.resolve(p); <ide> <del> const seenLinks = new StorageObject(); <del> const knownHard = new StorageObject(); <add> const seenLinks = Object.create(null); <add> const knownHard = Object.create(null); <ide> <ide> // current character position in p <ide> var pos; <ide><path>lib/internal/querystring.js <ide> const isHexTable = [ <ide> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256 <ide> ]; <ide> <del>// Instantiating this is faster than explicitly calling `Object.create(null)` <del>// to get a "clean" empty object (tested with v8 v4.9). <del>function StorageObject() {} <del>StorageObject.prototype = Object.create(null); <del> <ide> module.exports = { <ide> hexTable, <del> isHexTable, <del> StorageObject <add> isHexTable <ide> }; <ide><path>lib/querystring.js <ide> <ide> const { Buffer } = require('buffer'); <ide> const { <del> StorageObject, <ide> hexTable, <ide> isHexTable <ide> } = require('internal/querystring'); <ide> const defEqCodes = [61]; // = <ide> <ide> // Parse a key/val string. <ide> function parse(qs, sep, eq, options) { <del> const obj = new StorageObject(); <add> const obj = Object.create(null); <ide> <ide> if (typeof qs !== 'string' || qs.length === 0) { <ide> return obj; <ide><path>lib/url.js <ide> <ide> const { toASCII } = process.binding('config').hasIntl ? <ide> process.binding('icu') : require('punycode'); <del>const { StorageObject, hexTable } = require('internal/querystring'); <add>const { hexTable } = require('internal/querystring'); <ide> const internalUrl = require('internal/url'); <ide> exports.parse = urlParse; <ide> exports.resolve = urlResolve; <ide> Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { <ide> } <ide> } else if (parseQueryString) { <ide> this.search = ''; <del> this.query = new StorageObject(); <add> this.query = Object.create(null); <ide> } <ide> return this; <ide> } <ide> Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { <ide> } else if (parseQueryString) { <ide> // no query string, but parseQueryString still requested <ide> this.search = ''; <del> this.query = new StorageObject(); <add> this.query = Object.create(null); <ide> } <ide> <ide> var firstIdx = (questionIdx !== -1 &&
6
Javascript
Javascript
fix github link
0262d1b6761be1ba1718b9e541cf3001d3f7e673
<ide><path>server/passport-providers.js <ide> module.exports = { <ide> authScheme: 'oauth2', <ide> module: 'passport-github', <ide> authPath: '/link/github', <del> callbackURL: '/link/github/callback', <del> callbackPath: '/link/github/callback', <add> callbackURL: '/auth/github/callback/link', <add> callbackPath: '/auth/github/callback/link', <ide> successRedirect: successRedirect, <ide> failureRedirect: failureRedirect, <ide> clientID: process.env.GITHUB_ID,
1
Javascript
Javascript
use jquery ready instead of vanilla js
523fb5c3f421129aea10045081dc5e519859c1ae
<ide><path>airflow/www/static/js/task_instance.js <ide> * under the License. <ide> */ <ide> <del>document.addEventListener('DOMContentLoaded', () => { <add>$(document).ready(() => { <ide> function dateChange() { <ide> // We don't want to navigate away if the datetimepicker is still visible <ide> if ($('.datetimepicker bootstrap-datetimepicker-widget :visible').length > 0) {
1
PHP
PHP
add missing subcommand definition
9de6a5f3cd53a81dd95b09f1f1ed97b875739d56
<ide><path>src/Console/Command/Task/FixtureTask.php <ide> public function getOptionParser() { <ide> ])->addOption('conditions', [ <ide> 'help' => __d('cake_console', 'The SQL snippet to use when importing records.'), <ide> 'default' => '1=1', <add> ])->addSubcommand('all', [ <add> 'help' => __d('cake_console', 'Bake all model files with associations and validation.') <ide> ]); <ide> <ide> return $parser;
1
Text
Text
update console.error example
440edaa6881bc6e4966558a10152b41838f9f28a
<ide><path>doc/api/console.md <ide> console.log('hello world'); <ide> console.log('hello %s', 'world'); <ide> // Prints: hello world, to stdout <ide> console.error(new Error('Whoops, something bad happened')); <del>// Prints: [Error: Whoops, something bad happened], to stderr <add>// Prints error message and stack trace to stderr: <add>// Error: Whoops, something bad happened <add>// at [eval]:5:15 <add>// at Script.runInThisContext (node:vm:132:18) <add>// at Object.runInThisContext (node:vm:309:38) <add>// at node:internal/process/execution:77:19 <add>// at [eval]-wrapper:6:22 <add>// at evalScript (node:internal/process/execution:76:60) <add>// at node:internal/main/eval_string:23:3 <ide> <ide> const name = 'Will Robinson'; <ide> console.warn(`Danger ${name}! Danger!`);
1
Javascript
Javascript
add method popn() to navigator
bbe95c2acf4df06a732ff319cd9c686440ddf29a
<ide><path>Libraries/CustomComponents/Navigator/Navigator.js <ide> var Navigator = React.createClass({ <ide> }); <ide> }, <ide> <del> _popN: function(n) { <del> if (n === 0) { <add> /** <add> * Go back N scenes at once. When N=1, behavior matches `pop()`. <add> * When N is invalid(negative or bigger than current routes count), do nothing. <add> * @param {number} n The number of scenes to pop. Should be an integer. <add> */ <add> popN: function(n) { <add> invariant(typeof n === 'number', 'Must supply a number to popN'); <add> n = parseInt(n, 10); <add> if (n <= 0 || this.state.presentedIndex - n < 0) { <ide> return; <ide> } <del> invariant( <del> this.state.presentedIndex - n >= 0, <del> 'Cannot pop below zero' <del> ); <ide> var popIndex = this.state.presentedIndex - n; <ide> var presentedRoute = this.state.routeStack[this.state.presentedIndex]; <ide> var popSceneConfig = this.props.configureScene(presentedRoute); // using the scene config of the currently presented view <ide> var Navigator = React.createClass({ <ide> return; <ide> } <ide> <del> if (this.state.presentedIndex > 0) { <del> this._popN(1); <del> } <add> this.popN(1); <ide> }, <ide> <ide> /** <ide> var Navigator = React.createClass({ <ide> 'Calling popToRoute for a route that doesn\'t exist!' <ide> ); <ide> var numToPop = this.state.presentedIndex - indexOfRoute; <del> this._popN(numToPop); <add> this.popN(numToPop); <ide> }, <ide> <ide> /** <ide> var Navigator = React.createClass({ <ide> this.replaceAtIndex(route, 0, () => { <ide> // Do not use popToRoute here, because race conditions could prevent the <ide> // route from existing at this time. Instead, just go to index 0 <del> if (this.state.presentedIndex > 0) { <del> this._popN(this.state.presentedIndex); <del> } <add> this.popN(this.state.presentedIndex); <ide> }); <ide> }, <ide>
1
Java
Java
avoid unnecessary autoboxing
e6020ed3777fe5d99e0c9333185f7f5ad143b9c9
<ide><path>spring-aop/src/main/java/org/springframework/aop/config/AopNamespaceUtils.java <ide> public static void registerAspectJAnnotationAutoProxyCreatorIfNecessary( <ide> <ide> private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, @Nullable Element sourceElement) { <ide> if (sourceElement != null) { <del> boolean proxyTargetClass = Boolean.valueOf(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE)); <add> boolean proxyTargetClass = Boolean.parseBoolean(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE)); <ide> if (proxyTargetClass) { <ide> AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry); <ide> } <del> boolean exposeProxy = Boolean.valueOf(sourceElement.getAttribute(EXPOSE_PROXY_ATTRIBUTE)); <add> boolean exposeProxy = Boolean.parseBoolean(sourceElement.getAttribute(EXPOSE_PROXY_ATTRIBUTE)); <ide> if (exposeProxy) { <ide> AopConfigUtils.forceAutoProxyCreatorToExposeProxy(registry); <ide> } <ide><path>spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java <ide> private void setNumberHits(BitSet bits, String value, int min, int max) { <ide> if (!split[0].contains("-")) { <ide> range[1] = max - 1; <ide> } <del> int delta = Integer.valueOf(split[1]); <add> int delta = Integer.parseInt(split[1]); <ide> if (delta <= 0) { <ide> throw new IllegalArgumentException("Incrementer delta must be 1 or higher: '" + <ide> field + "' in expression \"" + this.expression + "\""); <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/config/ViewControllerBeanDefinitionParser.java <ide> public BeanDefinition parse(Element element, ParserContext parserContext) { <ide> <ide> HttpStatus statusCode = null; <ide> if (element.hasAttribute("status-code")) { <del> int statusValue = Integer.valueOf(element.getAttribute("status-code")); <add> int statusValue = Integer.parseInt(element.getAttribute("status-code")); <ide> statusCode = HttpStatus.valueOf(statusValue); <ide> } <ide> <ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/WebContentInterceptor.java <ide> public void setCacheMappings(Properties cacheMappings) { <ide> Enumeration<?> propNames = cacheMappings.propertyNames(); <ide> while (propNames.hasMoreElements()) { <ide> String path = (String) propNames.nextElement(); <del> int cacheSeconds = Integer.valueOf(cacheMappings.getProperty(path)); <add> int cacheSeconds = Integer.parseInt(cacheMappings.getProperty(path)); <ide> this.cacheMappings.put(path, cacheSeconds); <ide> } <ide> }
4
Go
Go
fix typos whithin unit tests
483c9425208fbc649cd12d157892be5a7ea92924
<ide><path>api_test.go <ide> func TestGetImagesJson(t *testing.T) { <ide> <ide> func TestGetImagesViz(t *testing.T) { <ide> //FIXME: Implement this test (or remove this endpoint) <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestGetImagesSearch(t *testing.T) { <ide> func TestGetContainersPs(t *testing.T) { <ide> <ide> func TestGetContainersExport(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestGetContainerChanges(t *testing.T) { <ide> func TestGetContainerChanges(t *testing.T) { <ide> // t.Fatalf("Body expected, received: nil\n") <ide> // } <ide> <del> // if r.Code != http.StatusOK { <del> // t.Fatalf("%d OK expected, received %d\n", http.StatusNoContent, r.Code) <del> // } <add>func TestGetContainersByName(t *testing.T) { <add> //FIXME: Implement this test <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostAuth(t *testing.T) { <ide> func TestPostAuth(t *testing.T) { <ide> <ide> func TestPostCommit(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostBuild(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostImagesCreate(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostImagesInsert(t *testing.T) { <ide> //FIXME: Implement this test (or remove this endpoint) <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostImagesPush(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostImagesTag(t *testing.T) { <ide> //FIXME: Implement this test <del> t.Log("Test on implemented") <add> t.Log("Test not implemented") <ide> } <ide> <ide> func TestPostContainersCreate(t *testing.T) { <ide> func TestPostContainersWait(t *testing.T) { <ide> } <ide> <ide> setTimeout(t, "Wait timed out", 3*time.Second, func() { <del> body, err := postContainersWait(srv, nil, nil, nil) <add> body, err := postContainersWait(srv, nil, nil, map[string]string{"name": container.Id}) <ide> if err != nil { <ide> t.Fatal(err) <ide> } <ide><path>commands.go <ide> func CmdCommit(args ...string) error { <ide> return err <ide> } <ide> <del> var out ApiId <del> err = json.Unmarshal(body, &out) <add> apiId := &ApiId{} <add> err = json.Unmarshal(body, apiId) <ide> if err != nil { <ide> return err <ide> } <ide> <del> fmt.Println(out.Id) <add> fmt.Println(apiId.Id) <ide> return nil <ide> } <ide> <ide> func CmdDiff(args ...string) error { <ide> return err <ide> } <ide> <del> var changes []Change <add> changes := []Change{} <ide> err = json.Unmarshal(body, &changes) <ide> if err != nil { <ide> return err <ide> func CmdAttach(args ...string) error { <ide> return err <ide> } <ide> <del> var container Container <del> err = json.Unmarshal(body, &container) <add> container := &Container{} <add> err = json.Unmarshal(body, container) <ide> if err != nil { <ide> return err <ide> } <ide> func CmdSearch(args ...string) error { <ide> return err <ide> } <ide> <del> var outs []ApiSearch <add> outs := []ApiSearch{} <ide> err = json.Unmarshal(body, &outs) <ide> if err != nil { <ide> return err <ide> func CmdRun(args ...string) error { <ide> return err <ide> } <ide> <del> var out ApiRun <del> err = json.Unmarshal(body, &out) <add> out := &ApiRun{} <add> err = json.Unmarshal(body, out) <ide> if err != nil { <ide> return err <ide> }
2
Python
Python
remove remaining head() method
650c04662dc4b47f285601fefad3b71afc7f6461
<ide><path>djangorestframework/compat.py <ide> def http_method_not_allowed(self, request, *args, **kwargs): <ide> #) <ide> return http.HttpResponseNotAllowed(allowed_methods) <ide> <del> def head(self, request, *args, **kwargs): <del> return self.get(request, *args, **kwargs) <del> <ide> # PUT, DELETE do not require CSRF until 1.4. They should. Make it better. <ide> if django.VERSION >= (1, 4): <ide> from django.middleware.csrf import CsrfViewMiddleware
1
Text
Text
fix version number for dep006
6385340774fad3338dd00ba20468421b560be6b9
<ide><path>doc/api/deprecations.md <ide> changes: <ide> description: A deprecation code has been assigned. <ide> - version: v0.11.14 <ide> description: Runtime deprecation. <del> - version: v0.5.11 <add> - version: v0.5.10 <ide> description: Documentation-only deprecation. <ide> --> <ide>
1
Javascript
Javascript
improve use of primordials
b8922e8924a3da170878c9982342258f5deb0a7f
<ide><path>lib/wasi.js <ide> /* global WebAssembly */ <ide> const { <ide> ArrayIsArray, <del> ArrayPrototypeForEach, <ide> ArrayPrototypeMap, <add> ArrayPrototypePush, <ide> FunctionPrototypeBind, <del> ObjectKeys, <add> ObjectEntries, <ide> Symbol, <ide> } = primordials; <ide> <ide> class WASI { <ide> for (const key in env) { <ide> const value = env[key]; <ide> if (value !== undefined) <del> envPairs.push(`${key}=${value}`); <add> ArrayPrototypePush(envPairs, `${key}=${value}`); <ide> } <ide> } else if (env !== undefined) { <ide> throw new ERR_INVALID_ARG_TYPE('options.env', 'Object', env); <ide> class WASI { <ide> const preopenArray = []; <ide> <ide> if (typeof preopens === 'object' && preopens !== null) { <del> ArrayPrototypeForEach(ObjectKeys(preopens), (key) => { <del> preopenArray.push(String(key)); <del> preopenArray.push(String(preopens[key])); <del> }); <add> for (const [key, value] of ObjectEntries(preopens)) { <add> ArrayPrototypePush(preopenArray, String(key), String(value)); <add> } <ide> } else if (preopens !== undefined) { <ide> throw new ERR_INVALID_ARG_TYPE('options.preopens', 'Object', preopens); <ide> }
1
Go
Go
fix netlink dependency with new pkg
d0fdc3b5dfa951870f4a7c0a08dea8c1bc68a31b
<ide><path>daemon/daemon.go <ide> import ( <ide> "fmt" <ide> "io" <ide> "io/ioutil" <add> "net" <ide> "os" <ide> "path/filepath" <ide> "regexp" <ide> import ( <ide> "github.com/docker/docker/volume/local" <ide> "github.com/docker/docker/volume/store" <ide> "github.com/docker/libnetwork" <del> "github.com/opencontainers/runc/libcontainer/netlink" <add> "github.com/vishvananda/netlink" <ide> ) <ide> <ide> var ( <ide> var errNoDefaultRoute = errors.New("no default route was found") <ide> <ide> // getDefaultRouteMtu returns the MTU for the default route's interface. <ide> func getDefaultRouteMtu() (int, error) { <del> routes, err := netlink.NetworkGetRoutes() <add> routes, err := netlink.RouteList(nil, 0) <ide> if err != nil { <ide> return 0, err <ide> } <ide> for _, r := range routes { <del> if r.Default && r.Iface != nil { <del> return r.Iface.MTU, nil <add> // a nil Dst means that this is the default route. <add> if r.Dst == nil { <add> i, err := net.InterfaceByIndex(r.LinkIndex) <add> if err != nil { <add> continue <add> } <add> return i.MTU, nil <ide> } <ide> } <ide> return 0, errNoDefaultRoute
1
Ruby
Ruby
use a hash to look up column definitions
76c29a64b940ca82c7a15de5598f5340046b9cca
<ide><path>activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb <ide> class TableDefinition <ide> <ide> def initialize(base) <ide> @columns = [] <add> @columns_hash = {} <ide> @base = base <ide> end <ide> <ide> def primary_key(name) <ide> <ide> # Returns a ColumnDefinition for the column with name +name+. <ide> def [](name) <del> name = name.to_s <del> @columns.find { |column| column.name == name } <add> @columns_hash[name.to_s] <ide> end <ide> <ide> # Instantiates a new column for the table. <ide> def to_sql <ide> def new_column_definition(base, name, type) <ide> definition = ColumnDefinition.new base, name, type <ide> @columns << definition <add> @columns_hash[name] = definition <ide> definition <ide> end <ide>
1
Ruby
Ruby
simplify cache output
46e051b1c2ed44ce4db151da9a09a1870c485334
<ide><path>Library/Homebrew/cask/lib/hbc/cli/doctor.rb <ide> def self.render_load_path(paths) <ide> <ide> def self.render_cached_downloads <ide> cleanup = CLI::Cleanup.default <del> files = cleanup.cache_files <del> count = files.count <add> count = cleanup.cache_files.count <ide> size = cleanup.disk_cleanup_size <del> size_msg = "#{number_readable(count)} files, #{disk_usage_readable(size)}" <del> warn_msg = error_string('warning: run "brew cask cleanup"') <del> size_msg << " #{warn_msg}" if count > 0 <del> [Hbc.cache, size_msg] <add> msg = user_tilde(Hbc.cache.to_s) <add> msg << " (#{number_readable(count)} files, #{disk_usage_readable(size)})" unless count.zero? <add> msg <ide> end <ide> <ide> def self.help
1
Javascript
Javascript
serialize name in buffergeometry.tojson()
d06ece07677cf9bded2fce17c363e142624ae7fc
<ide><path>src/core/BufferGeometry.js <ide> BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy <ide> <ide> var array = Array.prototype.slice.call( attribute.array ); <ide> <del> data.data.attributes[ key ] = { <add> var attributeData = { <ide> itemSize: attribute.itemSize, <ide> type: attribute.array.constructor.name, <ide> array: array, <ide> normalized: attribute.normalized <ide> }; <ide> <add> if ( attribute.name !== '' ) attributeData.name = attribute.name; <add> <add> data.data.attributes[ key ] = attributeData; <add> <ide> } <ide> <ide> var morphAttributes = {}; <ide><path>src/loaders/BufferGeometryLoader.js <ide> Object.assign( BufferGeometryLoader.prototype, { <ide> var attribute = attributes[ key ]; <ide> var typedArray = new TYPED_ARRAYS[ attribute.type ]( attribute.array ); <ide> <del> geometry.addAttribute( key, new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized ) ); <add> var bufferAttribute = new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized ); <add> if ( attribute.name !== undefined ) bufferAttribute.name = attribute.name; <add> geometry.addAttribute( key, bufferAttribute ); <ide> <ide> } <ide>
2
Python
Python
fix bug in dilated conv for cntk
cd22c5a53bf738ea678cb5ce0e799093d527f2a6
<ide><path>keras/backend/cntk_backend.py <ide> def conv1d(x, kernel, strides=1, padding='valid', <ide> <ide> if data_format == 'channels_last': <ide> x = C.swapaxes(x, 0, 1) <del> kernel = C.swapaxes(kernel, 0, 2) <add> <add> # As of Keras 2.0.0, all kernels are normalized <add> # on the format `(steps, input_depth, depth)`, <add> # independently of `data_format`. <add> # CNTK expects `(depth, input_depth, steps)`. <add> kernel = C.swapaxes(kernel, 0, 2) <ide> <ide> padding = _preprocess_border_mode(padding) <ide> <ide> if dev.type() == 0 and dilation_rate != 1: <ide> raise ValueError('Dilated convolution on CPU is not supported by CNTK backend. ' <ide> 'Please set `dilation_rate` to 1. You passed: %s' % (dilation_rate,)) <ide> <add> dilation_rate = (1, dilation_rate) <add> <ide> x = C.convolution( <ide> kernel, <ide> x, <ide> def conv2d(x, kernel, strides=(1, 1), padding='valid', <ide> 'Please set `dilation_rate` to (1, 1). ' <ide> 'You passed: %s' % (dilation_rate,)) <ide> <add> dilation_rate = (1,) + dilation_rate <add> <ide> x = C.convolution(kernel, <ide> x, <ide> strides, <ide> def conv3d(x, kernel, strides=(1, 1, 1), padding='valid', <ide> 'Please set `dilation_rate` to (1, 1, 1). ' <ide> 'You passed: %s' % (dilation_rate,)) <ide> <add> dilation_rate = (1,) + dilation_rate <add> <ide> x = C.convolution( <ide> kernel, <ide> x, <ide> def conv2d_transpose(x, kernel, output_shape, strides=(1, 1), <ide> output_shape = transpose_shape(output_shape, 'channels_first', <ide> spatial_axes=(0, 1)) <ide> <add> dilation_rate = (1,) + dilation_rate <add> <ide> x = C.convolution_transpose( <ide> kernel, <ide> x, <ide><path>tests/keras/backend/backend_test.py <ide> WITH_NP = [KTH if K.backend() == 'theano' else KC if K.backend() == 'cntk' else KTF, KNP] <ide> <ide> <add># CNTK only supports dilated convolution on GPU <add>def get_dilated_conv_backends(): <add> backend_list = [] <add> if KTF is not None: <add> backend_list.append(KTF) <add> if KTH is not None: <add> backend_list.append(KTH) <add> if KC is not None and KC.dev.type() == 1: <add> backend_list.append(KC) <add> return backend_list <add> <add> <add>DILATED_CONV_BACKENDS = get_dilated_conv_backends() <add> <add> <ide> def check_dtype(var, dtype): <ide> if K._BACKEND == 'theano': <ide> assert var.dtype == dtype <ide> def test_in_top_k(self): <ide> @pytest.mark.parametrize('op,input_shape,kernel_shape,padding,data_format', [ <ide> ('conv1d', (2, 8, 2), (3, 2, 3), 'same', 'channels_last'), <ide> ('conv1d', (1, 8, 2), (3, 2, 3), 'valid', 'channels_last'), <add> ('conv1d', (1, 2, 8), (3, 2, 3), 'valid', 'channels_first'), <ide> ('conv2d', (2, 3, 4, 5), (3, 3, 3, 2), 'same', 'channels_first'), <ide> ('conv2d', (2, 3, 5, 6), (4, 3, 3, 4), 'valid', 'channels_first'), <ide> ('conv2d', (1, 6, 5, 3), (3, 4, 3, 2), 'valid', 'channels_last'), <ide> def test_conv(self, op, input_shape, kernel_shape, padding, data_format): <ide> padding=padding, data_format=data_format, <ide> cntk_dynamicity=True) <ide> <add> @pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <add> reason='cntk only supports dilated conv on GPU') <add> @pytest.mark.parametrize('op,input_shape,kernel_shape,padding,data_format,dilation_rate', [ <add> ('conv1d', (2, 8, 3), (4, 3, 2), 'valid', 'channels_last', 2), <add> ('conv1d', (2, 3, 8), (4, 3, 2), 'valid', 'channels_first', 2), <add> ('conv2d', (2, 8, 9, 3), (3, 3, 3, 2), 'same', 'channels_last', (2, 2)), <add> ('conv2d', (2, 3, 9, 8), (4, 3, 3, 4), 'valid', 'channels_first', (2, 2)), <add> ('conv3d', (2, 5, 4, 6, 3), (2, 2, 3, 3, 4), 'valid', 'channels_last', (2, 2, 2)), <add> ('conv3d', (2, 3, 5, 4, 6), (2, 2, 3, 3, 4), 'same', 'channels_first', (2, 2, 2)), <add> ]) <add> def test_conv_dilation(self, op, input_shape, kernel_shape, padding, <add> data_format, dilation_rate): <add> check_two_tensor_operation( <add> op, input_shape, kernel_shape, DILATED_CONV_BACKENDS, padding=padding, <add> data_format=data_format, dilation_rate=dilation_rate, cntk_dynamicity=True) <add> <add> @pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <add> reason='cntk only supports dilated conv transpose on GPU') <add> @pytest.mark.parametrize( <add> 'op,input_shape,kernel_shape,output_shape,padding,data_format,dilation_rate', [ <add> ('conv2d_transpose', (2, 5, 6, 3), (3, 3, 2, 3), (2, 5, 6, 2), <add> 'same', 'channels_last', (2, 2)), <add> ('conv2d_transpose', (2, 3, 8, 9), (3, 3, 2, 3), (2, 2, 8, 9), <add> 'same', 'channels_first', (2, 2)), <add> ]) <add> def test_conv_transpose_dilation(self, op, input_shape, kernel_shape, output_shape, <add> padding, data_format, dilation_rate): <add> check_two_tensor_operation( <add> op, input_shape, kernel_shape, DILATED_CONV_BACKENDS, output_shape=output_shape, <add> padding=padding, data_format=data_format, dilation_rate=dilation_rate, <add> cntk_dynamicity=True) <add> <ide> @pytest.mark.parametrize('op,input_shape,kernel_shape,padding,data_format', [ <ide> ('depthwise_conv2d', (2, 3, 4, 5), (3, 3, 3, 2), 'same', 'channels_first'), <ide> ('depthwise_conv2d', (2, 3, 5, 6), (4, 3, 3, 4), 'valid', 'channels_first'), <ide><path>tests/keras/layers/convolutional_test.py <ide> <ide> <ide> @keras_test <del>@pytest.mark.skipif((K.backend() == 'cntk'), <add>@pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <ide> reason='cntk only support dilated conv on GPU') <ide> @pytest.mark.parametrize( <ide> 'layer_kwargs,input_length,expected_output', <ide> def test_conv_1d(padding, strides): <ide> <ide> <ide> @keras_test <del>@pytest.mark.skipif((K.backend() == 'cntk'), <add>@pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <ide> reason='cntk only support dilated conv on GPU') <ide> def test_conv_1d_dilation(): <ide> batch_size = 2 <ide> def test_convolution_2d_channels_last(): <ide> <ide> <ide> @keras_test <del>@pytest.mark.skipif((K.backend() == 'cntk'), <add>@pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <ide> reason='cntk only supports dilated conv on GPU') <ide> def test_convolution_2d_dilation(): <ide> num_samples = 2 <ide> def test_convolution_2d_dilation(): <ide> num_col = 6 <ide> padding = 'valid' <ide> <del> # Test dilation <del> if K.backend() != 'cntk': <del> # cntk only support dilated conv on GPU <del> layer_test(convolutional.Conv2D, <del> kwargs={'filters': filters, <del> 'kernel_size': kernel_size, <del> 'padding': padding, <del> 'dilation_rate': (2, 2)}, <del> input_shape=(num_samples, num_row, num_col, stack_size)) <add> layer_test(convolutional.Conv2D, <add> kwargs={'filters': filters, <add> 'kernel_size': kernel_size, <add> 'padding': padding, <add> 'dilation_rate': (2, 2)}, <add> input_shape=(num_samples, num_row, num_col, stack_size)) <ide> <ide> <ide> @keras_test <ide> def test_conv2d_transpose(padding, out_padding, strides): <ide> <ide> <ide> @keras_test <del>@pytest.mark.skipif((K.backend() == 'cntk'), <add>@pytest.mark.skipif((K.backend() == 'cntk' and K.dev.type() == 0), <ide> reason='cntk only supports dilated conv transpose on GPU') <ide> def test_conv2d_transpose_dilation(): <ide>
3
Python
Python
fix error message
8e14d1af5bf1139c55e202b42a9ba78954c339c2
<ide><path>numpy/lib/arraysetops.py <ide> def in1d(ar1, ar2, assume_unique=False, invert=False, method='auto'): <ide> return outgoing_array <ide> elif method == 'dictionary': <ide> raise ValueError( <del> "'dictionary' method is only supported for non-integer arrays. " <add> "'dictionary' method is only " <add> "supported for boolean or integer arrays. " <ide> "Please select 'sort' or 'auto' for the method." <ide> ) <ide>
1
Text
Text
add note about linking stylesheet
50ec618748f848e73340696ced8a115b4d0e5a33
<ide><path>curriculum/challenges/english/01-responsive-web-design/responsive-web-design-projects/build-a-personal-portfolio-webpage.md <ide> dashedName: build-a-personal-portfolio-webpage <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> Your portfolio should have a "Welcome" section with an `id` of `welcome-section`. <ide><path>curriculum/challenges/english/01-responsive-web-design/responsive-web-design-projects/build-a-product-landing-page.md <ide> dashedName: build-a-product-landing-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `header` element with an `id` of `header` <ide><path>curriculum/challenges/english/01-responsive-web-design/responsive-web-design-projects/build-a-survey-form.md <ide> dashedName: build-a-survey-form <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have an `h1` element with an `id` of `title` <ide><path>curriculum/challenges/english/01-responsive-web-design/responsive-web-design-projects/build-a-technical-documentation-page.md <ide> dashedName: build-a-technical-documentation-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `main` element with an `id` of `main-doc` <ide><path>curriculum/challenges/english/01-responsive-web-design/responsive-web-design-projects/build-a-tribute-page.md <ide> dashedName: build-a-tribute-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `main` element with an `id` of `main` <ide><path>curriculum/challenges/english/14-responsive-web-design-22/build-a-personal-portfolio-webpage-project/build-a-personal-portfolio-webpage.md <ide> dashedName: build-a-personal-portfolio-webpage <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> Your portfolio should have a "Welcome" section with an `id` of `welcome-section`. <ide><path>curriculum/challenges/english/14-responsive-web-design-22/build-a-product-landing-page-project/build-a-product-landing-page.md <ide> dashedName: build-a-product-landing-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `header` element with an `id` of `header`. <ide><path>curriculum/challenges/english/14-responsive-web-design-22/build-a-survey-form-project/build-a-survey-form.md <ide> dashedName: build-a-survey-form <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have an `h1` element with an `id` of `title`. <ide><path>curriculum/challenges/english/14-responsive-web-design-22/build-a-technical-documentation-page-project/build-a-technical-documentation-page.md <ide> dashedName: build-a-technical-documentation-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `main` element with an `id` of `main-doc`. <ide><path>curriculum/challenges/english/14-responsive-web-design-22/build-a-tribute-page-project/build-a-tribute-page.md <ide> dashedName: build-a-tribute-page <ide> <ide> Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! <ide> <add>**Note:** Be sure to add `<link rel="stylesheet" href="styles.css">` in your HTML to link your stylesheet and apply your CSS <add> <ide> # --hints-- <ide> <ide> You should have a `main` element with an `id` of `main`.
10
Ruby
Ruby
remove invalid test
47871b025e2205c9686ab1a20464cb4fac98cd74
<ide><path>activerecord/test/cases/relations_test.rb <ide> def test_empty <ide> <ide> def test_empty_complex_chained_relations <ide> posts = Post.select("comments_count").where("id is not null").group("author_id").where("comments_count > 0") <add> <ide> assert_queries(1) { assert_equal false, posts.empty? } <ide> assert ! posts.loaded? <ide> <ide> no_posts = posts.where(:title => "") <ide> assert_queries(1) { assert_equal true, no_posts.empty? } <ide> assert ! no_posts.loaded? <del> <del> best_posts = posts.where(:comments_count => 0) <del> best_posts.to_a # force load <del> assert_no_queries { assert_equal true, best_posts.empty? } <del> assert best_posts.loaded? <ide> end <ide> <ide> def test_any
1
Javascript
Javascript
use shelltestenvironment in wpt
092755932b28bd4e53bb5db3faf31262cd47fc2d
<ide><path>test/common/wpt.js <ide> class WPTRunner { <ide> fetch(file) { <ide> return resource.fetch(file); <ide> }, <del> location: {}, <ide> GLOBAL: { <ide> isWindow() { return false; } <ide> }, <ide> class WPTRunner { <ide> // TODO(joyeecheung): we are not a window - work with the upstream to <ide> // add a new scope for us. <ide> <del> const { Worker } = require('worker_threads'); <del> sandbox.DedicatedWorker = Worker; // Pretend we are a Worker <ide> return context; <ide> } <ide>
1
PHP
PHP
add test for retaining and flash messages
f17ebfc7372d556f5e96970f2c1d138964df8a57
<ide><path>tests/TestCase/TestSuite/IntegrationTestTraitTest.php <ide> public function testFlashSessionAndCookieAssertsHttpServer() <ide> $this->assertCookie(1, 'remember_me'); <ide> } <ide> <add> /** <add> * Test flash assertions stored with enableRememberFlashMessages() after a <add> * redirect. <add> * <add> * @return void <add> */ <add> public function testFlashAssertionsAfterRedirect() <add> { <add> $this->get('/posts/someRedirect'); <add> <add> $this->assertResponseCode(302); <add> <add> $this->assertSession('An error message', 'Flash.flash.0.message'); <add> } <add> <ide> /** <ide> * Test flash assertions stored with enableRememberFlashMessages() after they <ide> * are rendered <ide> public function testFlashAssertionsAfterRender() <ide> $this->enableRetainFlashMessages(); <ide> $this->get('/posts/index/with_flash'); <ide> <add> $this->assertResponseCode(200); <add> <ide> $this->assertSession('An error message', 'Flash.flash.0.message'); <ide> } <ide> <ide><path>tests/test_app/TestApp/Controller/PostsController.php <ide> */ <ide> class PostsController extends AppController <ide> { <add> /** <add> * @return void <add> */ <ide> public function initialize(): void <ide> { <ide> $this->loadComponent('Flash'); <ide> public function initialize(): void <ide> } <ide> <ide> /** <del> * beforeFilter <del> * <add> * @param \Cake\Event\EventInterface $event <ide> * @return \Cake\Http\Response|null|void <ide> */ <ide> public function beforeFilter(EventInterface $event) <ide> public function index($layout = 'default') <ide> $this->viewBuilder()->setLayout($layout); <ide> } <ide> <add> /** <add> * @return \Cake\Http\Response|null <add> */ <add> public function someRedirect() <add> { <add> $this->Flash->error('An error message'); <add> <add> return $this->redirect('/somewhere'); <add> } <add> <ide> /** <ide> * Sets a flash message and redirects (no rendering) <ide> *
2