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
Ruby
Ruby
reduce explicit branches in dependency expansion
27f2aa5f2c0a9ee5679fcbd5cd6f0d31a6b0bd29
<ide><path>Library/Homebrew/formula_installer.rb <ide> def pour_bottle? install_bottle_options={:warn=>false} <ide> true <ide> end <ide> <del> def install_bottle_for_dep?(dep, build) <add> def install_bottle_for?(dep, build) <add> return pour_bottle? if dep == f <ide> return false if build_from_source? <ide> return false unless dep.bottle && dep.pour_bottle? <ide> return false unless build.used_options.empty? <ide> def expand_requirements <ide> <ide> if (req.optional? || req.recommended?) && build.without?(req) <ide> Requirement.prune <del> elsif req.build? && dependent == self.f && pour_bottle? <del> Requirement.prune <del> elsif req.build? && dependent != self.f && install_bottle_for_dep?(dependent, build) <add> elsif req.build? && install_bottle_for?(dependent, build) <ide> Requirement.prune <ide> elsif install_requirement_default_formula?(req, build) <ide> dep = req.to_dependency <ide> def expand_dependencies(deps) <ide> <ide> if (dep.optional? || dep.recommended?) && build.without?(dep) <ide> Dependency.prune <del> elsif dep.build? && dependent == f && pour_bottle? <del> Dependency.prune <del> elsif dep.build? && dependent != f && install_bottle_for_dep?(dependent, build) <add> elsif dep.build? && install_bottle_for?(dependent, build) <ide> Dependency.prune <ide> elsif dep.satisfied?(options) <ide> Dependency.skip
1
Javascript
Javascript
use expressioncompile function directly
1aa99c08e9ccd515a333478f00b361f40c622002
<ide><path>src/apis.js <ide> var angularArray = { <ide> descending = $.charAt(0) == '-'; <ide> $ = $.substring(1); <ide> } <del> var get = $ ? angular['Function']['compile']($) : identity; <add> var get = $ ? expressionCompile($).fnSelf : identity; <ide> return reverse(function(a,b){ <ide> return compare(get(a),get(b)); <ide> }, descending);
1
Javascript
Javascript
replace closure functions with arrow functions
93fb60d550df49b0b96fa49675e416e21a5c1824
<ide><path>test/parallel/test-http-write-callbacks.js <ide> let clientEndCb = false; <ide> let clientIncoming = ''; <ide> const clientIncomingExpect = 'asdffoobar'; <ide> <del>process.on('exit', function() { <add>process.on('exit', () => { <ide> assert(serverEndCb); <ide> assert.strictEqual(serverIncoming, serverIncomingExpect); <ide> assert(clientEndCb); <ide> process.on('exit', function() { <ide> }); <ide> <ide> // Verify that we get a callback when we do res.write(..., cb) <del>const server = http.createServer(function(req, res) { <add>const server = http.createServer((req, res) => { <ide> res.statusCode = 400; <ide> res.end('Bad Request.\nMust send Expect:100-continue\n'); <ide> }); <ide> <del>server.on('checkContinue', function(req, res) { <add>server.on('checkContinue', (req, res) => { <ide> server.close(); <ide> assert.strictEqual(req.method, 'PUT'); <del> res.writeContinue(function() { <add> res.writeContinue(() => { <ide> // continue has been written <del> req.on('end', function() { <del> res.write('asdf', function(er) { <add> req.on('end', () => { <add> res.write('asdf', (er) => { <ide> assert.ifError(er); <del> res.write('foo', 'ascii', function(er) { <add> res.write('foo', 'ascii', (er) => { <ide> assert.ifError(er); <del> res.end(Buffer.from('bar'), 'buffer', function(er) { <add> res.end(Buffer.from('bar'), 'buffer', (er) => { <ide> serverEndCb = true; <ide> }); <ide> }); <ide> server.on('checkContinue', function(req, res) { <ide> }); <ide> <ide> req.setEncoding('ascii'); <del> req.on('data', function(c) { <add> req.on('data', (c) => { <ide> serverIncoming += c; <ide> }); <ide> }); <ide> server.listen(0, function() { <ide> method: 'PUT', <ide> headers: { 'expect': '100-continue' } <ide> }); <del> req.on('continue', function() { <add> req.on('continue', () => { <ide> // ok, good to go. <del> req.write('YmF6', 'base64', function(er) { <add> req.write('YmF6', 'base64', (er) => { <ide> assert.ifError(er); <del> req.write(Buffer.from('quux'), function(er) { <add> req.write(Buffer.from('quux'), (er) => { <ide> assert.ifError(er); <del> req.end('626c657267', 'hex', function(er) { <add> req.end('626c657267', 'hex', (er) => { <ide> assert.ifError(er); <ide> clientEndCb = true; <ide> }); <ide> }); <ide> }); <ide> }); <del> req.on('response', function(res) { <add> req.on('response', (res) => { <ide> // this should not come until after the end is flushed out <ide> assert(clientEndCb); <ide> res.setEncoding('ascii'); <del> res.on('data', function(c) { <add> res.on('data', (c) => { <ide> clientIncoming += c; <ide> }); <ide> });
1
Ruby
Ruby
drop space between "-isystem" and path
6fc6dd791badba63e708623c6db5ecd3d8cb4ac6
<ide><path>Library/Homebrew/extend/ENV/std.rb <ide> def setup_build_environment(formula=nil) <ide> <ide> unless HOMEBREW_PREFIX.to_s == '/usr/local' <ide> # /usr/local is already an -isystem and -L directory so we skip it <del> self['CPPFLAGS'] = "-isystem #{HOMEBREW_PREFIX}/include" <add> self['CPPFLAGS'] = "-isystem#{HOMEBREW_PREFIX}/include" <ide> self['LDFLAGS'] = "-L#{HOMEBREW_PREFIX}/lib" <ide> # CMake ignores the variables above <ide> self['CMAKE_PREFIX_PATH'] = "#{HOMEBREW_PREFIX}"
1
Java
Java
implement tostring() for synthesized annotations
1e50d8d5c2ea044885c4f98198b96a773f3e8c97
<ide><path>spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java <ide> static AnnotationAttributes getAnnotationAttributes(AnnotatedElement annotatedEl <ide> AnnotationAttributes attrs = new AnnotationAttributes(annotationType); <ide> for (Method method : getAttributeMethods(annotationType)) { <ide> try { <del> ReflectionUtils.makeAccessible(method); <ide> Object value = method.invoke(annotation); <ide> <ide> Object defaultValue = method.getDefaultValue(); <ide> static List<Method> getAttributeMethods(Class<? extends Annotation> annotationTy <ide> List<Method> methods = new ArrayList<Method>(); <ide> for (Method method : annotationType.getDeclaredMethods()) { <ide> if ((method.getParameterTypes().length == 0) && (method.getReturnType() != void.class)) { <add> ReflectionUtils.makeAccessible(method); <ide> methods.add(method); <ide> } <ide> } <ide><path>spring-core/src/main/java/org/springframework/core/annotation/SynthesizedAnnotationInvocationHandler.java <ide> import java.lang.reflect.AnnotatedElement; <ide> import java.lang.reflect.InvocationHandler; <ide> import java.lang.reflect.Method; <add>import java.util.Iterator; <add>import java.util.List; <ide> import java.util.Map; <ide> <ide> import org.springframework.util.ObjectUtils; <ide> import org.springframework.util.ReflectionUtils; <add>import org.springframework.util.StringUtils; <ide> <ide> /** <ide> * {@link InvocationHandler} for an {@link Annotation} that Spring has <ide> * <ide> * @author Sam Brannen <ide> * @since 4.2 <add> * @see Annotation <ide> * @see AliasFor <ide> * @see AnnotationUtils#synthesizeAnnotation(Annotation, AnnotatedElement) <ide> */ <ide> public SynthesizedAnnotationInvocationHandler(AnnotatedElement annotatedElement, <ide> <ide> @Override <ide> public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { <del> String attributeName = method.getName(); <add> String methodName = method.getName(); <add> int parameterCount = method.getParameterCount(); <add> <add> if ("toString".equals(methodName) && (parameterCount == 0)) { <add> return toString(proxy); <add> } <add> <ide> Class<?> returnType = method.getReturnType(); <ide> boolean nestedAnnotation = (Annotation[].class.isAssignableFrom(returnType) || Annotation.class.isAssignableFrom(returnType)); <del> String aliasedAttributeName = aliasMap.get(attributeName); <add> String aliasedAttributeName = aliasMap.get(methodName); <ide> boolean aliasPresent = (aliasedAttributeName != null); <ide> <ide> ReflectionUtils.makeAccessible(method); <ide> public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl <ide> } <ide> catch (NoSuchMethodException e) { <ide> String msg = String.format("In annotation [%s], attribute [%s] is declared as an @AliasFor [%s], " <del> + "but attribute [%s] does not exist.", this.annotationType.getName(), attributeName, <add> + "but attribute [%s] does not exist.", this.annotationType.getName(), methodName, <ide> aliasedAttributeName, aliasedAttributeName); <ide> throw new AnnotationConfigurationException(msg); <ide> } <ide> <ide> ReflectionUtils.makeAccessible(aliasedMethod); <ide> Object aliasedValue = ReflectionUtils.invokeMethod(aliasedMethod, this.annotation, args); <del> Object defaultValue = AnnotationUtils.getDefaultValue(this.annotation, attributeName); <add> Object defaultValue = AnnotationUtils.getDefaultValue(this.annotation, methodName); <ide> <ide> if (!ObjectUtils.nullSafeEquals(value, aliasedValue) && !ObjectUtils.nullSafeEquals(value, defaultValue) <ide> && !ObjectUtils.nullSafeEquals(aliasedValue, defaultValue)) { <ide> String elementName = (this.annotatedElement == null ? "unknown element" : this.annotatedElement.toString()); <ide> String msg = String.format( <ide> "In annotation [%s] declared on [%s], attribute [%s] and its alias [%s] are " <ide> + "declared with values of [%s] and [%s], but only one declaration is permitted.", <del> this.annotationType.getName(), elementName, attributeName, aliasedAttributeName, <add> this.annotationType.getName(), elementName, methodName, aliasedAttributeName, <ide> ObjectUtils.nullSafeToString(value), ObjectUtils.nullSafeToString(aliasedValue)); <ide> throw new AnnotationConfigurationException(msg); <ide> } <ide> else if (value instanceof Annotation[]) { <ide> return value; <ide> } <ide> <add> private String toString(Object proxy) { <add> StringBuilder sb = new StringBuilder("@").append(annotationType.getName()).append("("); <add> <add> List<Method> attributeMethods = AnnotationUtils.getAttributeMethods(this.annotationType); <add> Iterator<Method> iterator = attributeMethods.iterator(); <add> while (iterator.hasNext()) { <add> Method attributeMethod = iterator.next(); <add> sb.append(attributeMethod.getName()); <add> sb.append('='); <add> sb.append(valueToString(ReflectionUtils.invokeMethod(attributeMethod, proxy))); <add> sb.append(iterator.hasNext() ? ", " : ""); <add> } <add> <add> return sb.append(")").toString(); <add> } <add> <add> private String valueToString(Object value) { <add> if (value instanceof Object[]) { <add> return "[" + StringUtils.arrayToDelimitedString((Object[]) value, ", ") + "]"; <add> } <add> <add> // else <add> return String.valueOf(value); <add> } <add> <ide> } <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java <ide> public void getAnnotationAttributesWithAttributeAliases() throws Exception { <ide> assertEquals("value attribute: ", "/test", attributes.getString(VALUE)); <ide> assertEquals("path attribute: ", "/test", attributes.getString("path")); <ide> <del> method = WebController.class.getMethod("handleMappedWithPathValueAndAttributes"); <add> method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes"); <ide> webMapping = method.getAnnotation(WebMapping.class); <ide> exception.expect(AnnotationConfigurationException.class); <ide> exception.expectMessage(containsString("attribute [value] and its alias [path]")); <ide> public void synthesizeAnnotationWithAttributeAliases() throws Exception { <ide> Method method = WebController.class.getMethod("handleMappedWithValueAttribute"); <ide> WebMapping webMapping = method.getAnnotation(WebMapping.class); <ide> assertNotNull(webMapping); <del> WebMapping synthesizedWebMapping = synthesizeAnnotation(webMapping); <del> assertNotSame(webMapping, synthesizedWebMapping); <del> assertThat(synthesizedWebMapping, instanceOf(SynthesizedAnnotation.class)); <ide> <del> assertNotNull(synthesizedWebMapping); <del> assertEquals("name attribute: ", "foo", synthesizedWebMapping.name()); <del> assertEquals("aliased path attribute: ", "/test", synthesizedWebMapping.path()); <del> assertEquals("actual value attribute: ", "/test", synthesizedWebMapping.value()); <add> WebMapping synthesizedWebMapping1 = synthesizeAnnotation(webMapping); <add> assertNotNull(synthesizedWebMapping1); <add> assertNotSame(webMapping, synthesizedWebMapping1); <add> assertThat(synthesizedWebMapping1, instanceOf(SynthesizedAnnotation.class)); <add> <add> assertEquals("name attribute: ", "foo", synthesizedWebMapping1.name()); <add> assertEquals("aliased path attribute: ", "/test", synthesizedWebMapping1.path()); <add> assertEquals("actual value attribute: ", "/test", synthesizedWebMapping1.value()); <add> <add> WebMapping synthesizedWebMapping2 = synthesizeAnnotation(webMapping); <add> assertNotNull(synthesizedWebMapping2); <add> assertNotSame(webMapping, synthesizedWebMapping2); <add> assertThat(synthesizedWebMapping2, instanceOf(SynthesizedAnnotation.class)); <add> <add> assertEquals("name attribute: ", "foo", synthesizedWebMapping2.name()); <add> assertEquals("aliased path attribute: ", "/test", synthesizedWebMapping2.path()); <add> assertEquals("actual value attribute: ", "/test", synthesizedWebMapping2.value()); <add> } <add> <add> @Test <add> public void toStringForSynthesizedAnnotations() throws Exception { <add> Method methodWithPath = WebController.class.getMethod("handleMappedWithPathAttribute"); <add> WebMapping webMappingWithAliases = methodWithPath.getAnnotation(WebMapping.class); <add> assertNotNull(webMappingWithAliases); <add> <add> Method methodWithPathAndValue = WebController.class.getMethod("handleMappedWithSamePathAndValueAttributes"); <add> WebMapping webMappingWithPathAndValue = methodWithPathAndValue.getAnnotation(WebMapping.class); <add> assertNotNull(webMappingWithPathAndValue); <add> <add> WebMapping synthesizedWebMapping1 = synthesizeAnnotation(webMappingWithAliases); <add> assertNotNull(synthesizedWebMapping1); <add> WebMapping synthesizedWebMapping2 = synthesizeAnnotation(webMappingWithAliases); <add> assertNotNull(synthesizedWebMapping2); <add> <add> assertThat(webMappingWithAliases.toString(), is(not(synthesizedWebMapping1.toString()))); <add> <add> // The unsynthesized annotation for handleMappedWithSamePathAndValueAttributes() <add> // should produce the same toString() results as synthesized annotations for <add> // handleMappedWithPathAttribute() <add> assertToStringForWebMappingWithPathAndValue(webMappingWithPathAndValue); <add> assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping1); <add> assertToStringForWebMappingWithPathAndValue(synthesizedWebMapping2); <add> } <add> <add> private void assertToStringForWebMappingWithPathAndValue(WebMapping webMapping) { <add> String string = webMapping.toString(); <add> assertThat(string, startsWith("@" + WebMapping.class.getName() + "(")); <add> assertThat(string, containsString("value=/test")); <add> assertThat(string, containsString("path=/test")); <add> assertThat(string, containsString("name=bar")); <add> assertThat(string, containsString("method=")); <add> assertThat(string, either(containsString("[GET, POST]")).or(containsString("[POST, GET]"))); <add> assertThat(string, endsWith(")")); <ide> } <ide> <ide> /** <ide> public interface InterfaceWithRepeated { <ide> void foo(); <ide> } <ide> <add> enum RequestMethod { <add> GET, POST <add> } <add> <ide> /** <ide> * Mock of {@code org.springframework.web.bind.annotation.RequestMapping}. <ide> */ <ide> public interface InterfaceWithRepeated { <ide> <ide> @AliasFor(attribute = "value") <ide> String path() default ""; <add> <add> RequestMethod[] method() default {}; <ide> } <ide> <ide> @Component("webController") <ide> static class WebController { <ide> public void handleMappedWithValueAttribute() { <ide> } <ide> <del> @WebMapping(path = "/test", name = "bar") <add> @WebMapping(path = "/test", name = "bar", method = { RequestMethod.GET, RequestMethod.POST }) <ide> public void handleMappedWithPathAttribute() { <ide> } <ide> <add> /** <add> * mapping is logically "equal" to handleMappedWithPathAttribute(). <add> */ <add> @WebMapping(value = "/test", path = "/test", name = "bar", method = { RequestMethod.GET, RequestMethod.POST }) <add> public void handleMappedWithSamePathAndValueAttributes() { <add> } <add> <ide> @WebMapping(value = "/enigma", path = "/test", name = "baz") <del> public void handleMappedWithPathValueAndAttributes() { <add> public void handleMappedWithDifferentPathAndValueAttributes() { <ide> } <ide> } <ide>
3
Go
Go
remove racy test causing tests to stall
a9d6eef2386a3d08840e2a30bd8d6f2ae3679688
<ide><path>integration-cli/docker_cli_start_test.go <del>package main <del> <del>import ( <del> "os/exec" <del> "testing" <del>) <del> <del>// Regression test for #3364 <del>func TestDockerStartWithPortCollision(t *testing.T) { <del> runCmd := exec.Command(dockerBinary, "run", "--name", "fail", "-p", "25:25", "busybox", "true") <del> out, stderr, exitCode, err := runCommandWithStdoutStderr(runCmd) <del> if err != nil && exitCode != 0 { <del> t.Fatal(out, stderr, err) <del> } <del> <del> runCmd = exec.Command(dockerBinary, "run", "--name", "conflict", "-dti", "-p", "25:25", "busybox", "sh") <del> out, stderr, exitCode, err = runCommandWithStdoutStderr(runCmd) <del> if err != nil && exitCode != 0 { <del> t.Fatal(out, stderr, err) <del> } <del> <del> startCmd := exec.Command(dockerBinary, "start", "-a", "fail") <del> out, stderr, exitCode, err = runCommandWithStdoutStderr(startCmd) <del> if err != nil && exitCode != 1 { <del> t.Fatal(out, err) <del> } <del> <del> killCmd := exec.Command(dockerBinary, "kill", "conflict") <del> runCommand(killCmd) <del> <del> deleteAllContainers() <del> <del> logDone("start - -a=true error on port use") <del>}
1
Ruby
Ruby
use guard clauses
84b2276fd866342cd84c6ada8ffc13c5c209c3cf
<ide><path>Library/Homebrew/cask/lib/hbc/cli/search.rb <ide> def self.render_results(exact_match, partial_matches, search_term) <ide> ohai "Exact match" <ide> puts exact_match <ide> end <del> unless partial_matches.empty? <del> if extract_regexp search_term <del> ohai "Regexp matches" <del> else <del> ohai "Partial matches" <del> end <del> puts Formatter.columns(partial_matches) <add> <add> return if partial_matches.empty? <add> <add> if extract_regexp search_term <add> ohai "Regexp matches" <add> else <add> ohai "Partial matches" <ide> end <add> puts Formatter.columns(partial_matches) <ide> end <ide> <ide> def self.help <ide><path>Library/Homebrew/cask/lib/hbc/installer.rb <ide> def initialize(cask, command: SystemCommand, force: false, skip_cask_deps: false <ide> <ide> def self.print_caveats(cask) <ide> odebug "Printing caveats" <del> unless cask.caveats.empty? <del> output = capture_output do <del> cask.caveats.each do |caveat| <del> if caveat.respond_to?(:eval_and_print) <del> caveat.eval_and_print(cask) <del> else <del> puts caveat <del> end <add> return if cask.caveats.empty? <add> <add> output = capture_output do <add> cask.caveats.each do |caveat| <add> if caveat.respond_to?(:eval_and_print) <add> caveat.eval_and_print(cask) <add> else <add> puts caveat <ide> end <ide> end <del> <del> unless output.empty? <del> ohai "Caveats" <del> puts output <del> end <ide> end <add> <add> return if output.empty? <add> ohai "Caveats" <add> puts output <ide> end <ide> <ide> def self.capture_output(&block) <ide><path>Library/Homebrew/cask/lib/hbc/utils.rb <ide> def self.method_missing_message(method, token, section = nil) <ide> <ide> def self.nowstamp_metadata_path(container_path) <ide> @timenow ||= Time.now.gmtime <del> if container_path.respond_to?(:join) <del> precision = 3 <del> timestamp = @timenow.strftime("%Y%m%d%H%M%S") <del> fraction = format("%.#{precision}f", @timenow.to_f - @timenow.to_i)[1..-1] <del> timestamp.concat(fraction) <del> container_path.join(timestamp) <del> end <add> return unless container_path.respond_to?(:join) <add> <add> precision = 3 <add> timestamp = @timenow.strftime("%Y%m%d%H%M%S") <add> fraction = format("%.#{precision}f", @timenow.to_f - @timenow.to_i)[1..-1] <add> timestamp.concat(fraction) <add> container_path.join(timestamp) <ide> end <ide> <ide> def self.size_in_bytes(files) <ide><path>Library/Homebrew/cleanup.rb <ide> def self.cleanup <ide> cleanup_cellar <ide> cleanup_cache <ide> cleanup_logs <del> unless ARGV.dry_run? <del> cleanup_lockfiles <del> rm_ds_store <del> end <add> return if ARGV.dry_run? <add> cleanup_lockfiles <add> rm_ds_store <ide> end <ide> <ide> def self.update_disk_cleanup_size(path_size) <ide><path>Library/Homebrew/descriptions.rb <ide> def self.ensure_cache <ide> # If it does exist, but the Report is empty, just touch the cache file. <ide> # Otherwise, use the report to update the cache. <ide> def self.update_cache(report) <del> if CACHE_FILE.exist? <del> if report.empty? <del> FileUtils.touch CACHE_FILE <del> else <del> renamings = report.select_formula(:R) <del> alterations = report.select_formula(:A) + report.select_formula(:M) + <del> renamings.map(&:last) <del> cache_formulae(alterations, save: false) <del> uncache_formulae(report.select_formula(:D) + <del> renamings.map(&:first)) <del> end <add> return unless CACHE_FILE.exist? <add> <add> if report.empty? <add> FileUtils.touch CACHE_FILE <add> else <add> renamings = report.select_formula(:R) <add> alterations = report.select_formula(:A) + report.select_formula(:M) + <add> renamings.map(&:last) <add> cache_formulae(alterations, save: false) <add> uncache_formulae(report.select_formula(:D) + <add> renamings.map(&:first)) <ide> end <ide> end <ide> <ide> # Given an array of formula names, add them and their descriptions to the <ide> # cache. Save the updated cache to disk, unless explicitly told not to. <ide> def self.cache_formulae(formula_names, options = { save: true }) <del> if cache <del> formula_names.each do |name| <del> begin <del> desc = Formulary.factory(name).desc <del> rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS <del> end <del> @cache[name] = desc <add> return unless cache <add> <add> formula_names.each do |name| <add> begin <add> desc = Formulary.factory(name).desc <add> rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS <ide> end <del> save_cache if options[:save] <add> @cache[name] = desc <ide> end <add> save_cache if options[:save] <ide> end <ide> <ide> # Given an array of formula names, remove them and their descriptions from <ide> # the cache. Save the updated cache to disk, unless explicitly told not to. <ide> def self.uncache_formulae(formula_names, options = { save: true }) <del> if cache <del> formula_names.each { |name| @cache.delete(name) } <del> save_cache if options[:save] <del> end <add> return unless cache <add> formula_names.each { |name| @cache.delete(name) } <add> save_cache if options[:save] <ide> end <ide> <ide> # Given a regex, find all formulae whose specified fields contain a match. <ide><path>Library/Homebrew/extend/ENV/std.rb <ide> module Stdenv <ide> DEFAULT_FLAGS = "-march=core2 -msse4".freeze <ide> <ide> def self.extended(base) <del> unless ORIGINAL_PATHS.include? HOMEBREW_PREFIX/"bin" <del> base.prepend_path "PATH", "#{HOMEBREW_PREFIX}/bin" <del> end <add> return if ORIGINAL_PATHS.include? HOMEBREW_PREFIX/"bin" <add> base.prepend_path "PATH", "#{HOMEBREW_PREFIX}/bin" <ide> end <ide> <ide> # @private <ide><path>Library/Homebrew/sandbox.rb <ide> def self.test? <ide> end <ide> <ide> def self.print_sandbox_message <del> unless @printed_sandbox_message <del> ohai "Using the sandbox" <del> @printed_sandbox_message = true <del> end <add> return if @printed_sandbox_message <add> ohai "Using the sandbox" <add> @printed_sandbox_message = true <ide> end <ide> <ide> def initialize
7
Javascript
Javascript
update the license url in the header
323270f6dcc4fdbef0e6d81f5e37b315fbffc599
<ide><path>src/intro.js <ide> * <ide> * Copyright 2010, John Resig <ide> * Dual licensed under the MIT or GPL Version 2 licenses. <del> * http://docs.jquery.com/License <add> * http://jquery.org/license <ide> * <ide> * Includes Sizzle.js <ide> * http://sizzlejs.com/
1
Text
Text
remove code sample
110df65101894d5f3396ece4549e3acb55337bef
<ide><path>guides/source/getting_started.md <ide> create test/controllers/articles_controller_test.rb <ide> invoke helper <ide> create app/helpers/articles_helper.rb <ide> invoke test_unit <del>invoke assets <del>invoke scss <del>create app/assets/stylesheets/articles.scss <ide> ``` <ide> <ide> The most important of these is the controller file,
1
Go
Go
add kill for other drivers on restart
5b9069bd990dca0a35d8e490c6f6b56d27163bb8
<ide><path>runtime/runtime.go <ide> func (runtime *Runtime) Register(container *Container) error { <ide> if container.State.IsGhost() { <ide> utils.Debugf("killing ghost %s", container.ID) <ide> <add> existingPid := container.State.Pid <ide> container.State.SetGhost(false) <ide> container.State.SetStopped(0) <ide> <ide> // We only have to handle this for lxc because the other drivers will ensure that <ide> // no ghost processes are left when docker dies <ide> if container.ExecDriver == "" || strings.Contains(container.ExecDriver, "lxc") { <ide> lxc.KillLxc(container.ID, 9) <del> if err := container.Unmount(); err != nil { <del> utils.Debugf("ghost unmount error %s", err) <add> } else { <add> // use the current driver and ensure that the container is dead x.x <add> cmd := &execdriver.Command{ <add> ID: container.ID, <ide> } <add> var err error <add> cmd.Process, err = os.FindProcess(existingPid) <add> if err != nil { <add> utils.Debugf("cannot find existing process for %d", existingPid) <add> } <add> runtime.execDriver.Kill(cmd, 9) <add> } <add> if err := container.Unmount(); err != nil { <add> utils.Debugf("ghost unmount error %s", err) <ide> } <ide> } <ide>
1
Python
Python
replace f-string in root setup.py
ca11e4e2ebde67743c3ce09ccd265ffd855dbf4f
<ide><path>setup.py <ide> <ide> # The first version not in the `Programming Language :: Python :: ...` classifiers above <ide> if sys.version_info >= (3, 10): <add> fmt = "NumPy {} may not yet support Python {}.{}." <ide> warnings.warn( <del> f"NumPy {VERSION} may not yet support Python " <del> f"{sys.version_info.major}.{sys.version_info.minor}.", <del> RuntimeWarning, <del> ) <add> fmt.format(VERSION, *sys.version_info[:2]), <add> RuntimeWarning) <add> del fmt <ide> <ide> # BEFORE importing setuptools, remove MANIFEST. Otherwise it may not be <ide> # properly updated when the contents of directories change (true for distutils,
1
Python
Python
update examples and demo
9d54084ce18ff9e14f87356d83fff25f636a57b8
<ide><path>demos/compute_demo.py <ide> def get_demo_driver(provider_name='RACKSPACE', *args, **kwargs): <ide> >>> driver.load_nodes() <ide> >>> images = driver.load_images() <ide> >>> sizes = driver.load_sizes() <del> <add> <ide> # And maybe do more than that: <ide> >>> node = driver.create_node( <ide> name='my_first_node', <ide><path>example_compute.py <ide> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <ide> # See the License for the specific language governing permissions and <ide> # limitations under the License. <add> <ide> from libcloud.compute.types import Provider <ide> from libcloud.compute.providers import get_driver <ide> <ide> EC2 = get_driver(Provider.EC2_US_EAST) <ide> Slicehost = get_driver(Provider.SLICEHOST) <ide> Rackspace = get_driver(Provider.RACKSPACE) <ide> <del>drivers = [ EC2('access key id', 'secret key'), <del> Slicehost('api key'), <add>drivers = [ EC2('access key id', 'secret key'), <add> Slicehost('api key'), <ide> Rackspace('username', 'api key') ] <ide> <ide> nodes = [ driver.list_nodes() for driver in drivers ] <ide> <del>print nodes <add>print(nodes) <ide> # [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>, <ide> # <Node: provider=Slicehost, status=REBOOT, name=korine, ip=6.7.8.9.10>, ... ] <ide> <ide> # grab the node named "test" <del>node = filter(lambda x: x.name == 'test', nodes)[0] <add>node = [n for n in nodes if n.name == 'test'][0] <ide> <ide> # reboot "test" <ide> node.reboot() <ide><path>example_loadbalancer.py <ide> def main(): <ide> <ide> balancers = driver.list_balancers() <ide> <del> print balancers <add> print(balancers) <ide> <ide> # creating a balancer which balances traffic across two <ide> # nodes: 192.168.86.1:80 and 192.168.86.2:8080. Balancer <ide> def main(): <ide> Member(None, '192.168.86.2', 8080)) <ide> ) <ide> <del> print new_balancer <add> print(new_balancer) <ide> <ide> # wait for balancer to become ready <ide> # NOTE: in real life code add timeout to not end up in <ide> def main(): <ide> if balancer.state == State.RUNNING: <ide> break <ide> <del> print "sleeping for 30 seconds for balancers to become ready" <add> print('sleeping for 30 seconds for balancers to become ready') <ide> time.sleep(30) <ide> <ide> # fetch list of members <ide> members = balancer.list_members() <del> print members <add> print(members) <ide> <ide> # remove first member <ide> balancer.detach_member(members[0])
3
PHP
PHP
use $this in closure
afe7528cc296b0ea873a1f608a819df70e0a6496
<ide><path>tests/Mail/MailMailerTest.php <ide> public function testGlobalFromIsRespectedOnAllMessages() <ide> $view->shouldReceive('render')->once()->andReturn('rendered.view'); <ide> $this->setSwiftMailer($mailer); <ide> $mailer->alwaysFrom('taylorotwell@gmail.com', 'Taylor Otwell'); <del> $me = $this; <del> $mailer->getSwiftMailer()->shouldReceive('send')->once()->with(m::type('Swift_Message'), [])->andReturnUsing(function ($message) use ($me) { <del> $me->assertEquals(['taylorotwell@gmail.com' => 'Taylor Otwell'], $message->getFrom()); <add> $mailer->getSwiftMailer()->shouldReceive('send')->once()->with(m::type('Swift_Message'), [])->andReturnUsing(function ($message) { <add> $this->assertEquals(['taylorotwell@gmail.com' => 'Taylor Otwell'], $message->getFrom()); <ide> }); <ide> $mailer->send('foo', ['data'], function ($m) {}); <ide> }
1
Python
Python
set version to 2.0.14
8612b758903216f81b05c6f50da22698696b4243
<ide><path>spacy/about.py <ide> # https://github.com/pypa/warehouse/blob/master/warehouse/__about__.py <ide> <ide> __title__ = 'spacy' <del>__version__ = '2.0.14.dev1' <add>__version__ = '2.0.14' <ide> __summary__ = 'Industrial-strength Natural Language Processing (NLP) with Python and Cython' <ide> __uri__ = 'https://spacy.io' <ide> __author__ = 'Explosion AI'
1
Python
Python
fix fine tuning
18b64e79ecdb13ac37e9d0d62324668ca57bf644
<ide><path>spacy/_ml.py <ide> def Tok2Vec(width, embed_size, preprocess=None): <ide> >> uniqued(embed, column=5) <ide> >> drop_layer( <ide> Residual( <del> (ExtractWindow(nW=1) >> BN(Maxout(width, width*3))) <add> (ExtractWindow(nW=1) >> ReLu(width, width*3)) <ide> ) <ide> ) ** 4, pad=4 <ide> ) <ide> def fine_tune_fwd(docs_tokvecs, drop=0.): <ide> vecs, bp_vecs = embedding.begin_update(docs, drop=drop) <ide> flat_tokvecs = embedding.ops.flatten(tokvecs) <ide> flat_vecs = embedding.ops.flatten(vecs) <del> alpha = model.mix <del> minus = 1-model.mix <ide> output = embedding.ops.unflatten( <del> (alpha * flat_tokvecs + minus * flat_vecs), lengths) <add> (model.mix[0] * flat_tokvecs + model.mix[1] * flat_vecs), lengths) <ide> <ide> def fine_tune_bwd(d_output, sgd=None): <ide> flat_grad = model.ops.flatten(d_output) <del> model.d_mix += flat_tokvecs.dot(flat_grad.T).sum() <del> model.d_mix += 1-flat_vecs.dot(flat_grad.T).sum() <add> model.d_mix[0] += flat_tokvecs.dot(flat_grad.T).sum() <add> model.d_mix[1] += flat_vecs.dot(flat_grad.T).sum() <ide> <del> bp_vecs([d_o * minus for d_o in d_output], sgd=sgd) <del> d_output = [d_o * alpha for d_o in d_output] <add> bp_vecs([d_o * model.mix[1] for d_o in d_output], sgd=sgd) <ide> sgd(model._mem.weights, model._mem.gradient, key=model.id) <del> model.mix = model.ops.xp.minimum(model.mix, 1.0) <del> return d_output <add> return [d_o * model.mix[0] for d_o in d_output] <ide> return output, fine_tune_bwd <ide> model = wrap(fine_tune_fwd, embedding) <del> model.mix = model._mem.add((model.id, 'mix'), (1,)) <add> model.mix = model._mem.add((model.id, 'mix'), (2,)) <ide> model.mix.fill(0.5) <ide> model.d_mix = model._mem.add_gradient((model.id, 'd_mix'), (model.id, 'mix')) <ide> return model
1
Javascript
Javascript
add path to the module object
d0043136e5d01517a3bf5e86ae725e2f74519909
<ide><path>lib/internal/modules/cjs/loader.js <ide> function updateChildren(parent, child, scan) { <ide> children.push(child); <ide> } <ide> <del>function Module(id, parent) { <add>function Module(id = '', parent) { <ide> this.id = id; <add> this.path = path.dirname(id); <ide> this.exports = {}; <ide> this.parent = parent; <ide> updateChildren(parent, this, false);
1
PHP
PHP
use a relative path to the plugins file
053bb058fd072a4e19cf12712780aa5b2ac7aaad
<ide><path>src/Core/Plugin.php <ide> protected static function _loadConfig() <ide> return; <ide> } <ide> <del> $vendorFile = ROOT . DS . 'vendor' . DS . 'cakephp-plugins.php'; <add> $vendorFile = dirname(dirname(dirname(dirname(__DIR__)))) . DS . 'cakephp-plugins.php'; <ide> if (!file_exists($vendorFile)) { <add> Configure::write(['plugins' => []]); <ide> return; <ide> } <ide>
1
Javascript
Javascript
allow operation with handlebars runtime only
a2fee026a5e38522b4ec8e858d13c4c4a825be8a
<ide><path>packages/ember-handlebars/lib/ext.js <ide> Ember.Handlebars.helpers = objectCreate(Handlebars.helpers); <ide> @constructor <ide> */ <ide> Ember.Handlebars.Compiler = function() {}; <del>Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); <add> <add>// Handlebars.Compiler doesn't exist in runtime-only <add>if (Handlebars.Compiler) { <add> Ember.Handlebars.Compiler.prototype = objectCreate(Handlebars.Compiler.prototype); <add>} <add> <ide> Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler; <ide> <ide> /** <ide> Ember.Handlebars.Compiler.prototype.compiler = Ember.Handlebars.Compiler; <ide> @constructor <ide> */ <ide> Ember.Handlebars.JavaScriptCompiler = function() {}; <del>Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); <del>Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler; <add> <add>// Handlebars.JavaScriptCompiler doesn't exist in runtime-only <add>if (Handlebars.JavaScriptCompiler) { <add> Ember.Handlebars.JavaScriptCompiler.prototype = objectCreate(Handlebars.JavaScriptCompiler.prototype); <add> Ember.Handlebars.JavaScriptCompiler.prototype.compiler = Ember.Handlebars.JavaScriptCompiler; <add>} <add> <add> <ide> Ember.Handlebars.JavaScriptCompiler.prototype.namespace = "Ember.Handlebars"; <ide> <ide> <ide> Ember.Handlebars.precompile = function(string) { <ide> return new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); <ide> }; <ide> <del>/** <del> The entry point for Ember Handlebars. This replaces the default Handlebars.compile and turns on <del> template-local data and String parameters. <del> <del> @method compile <del> @for Ember.Handlebars <del> @static <del> @param {String} string The template to compile <del> @return {Function} <del>*/ <del>Ember.Handlebars.compile = function(string) { <del> var ast = Handlebars.parse(string); <del> var options = { data: true, stringParams: true }; <del> var environment = new Ember.Handlebars.Compiler().compile(ast, options); <del> var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); <del> <del> return Handlebars.template(templateSpec); <del>}; <add>// We don't support this for Handlebars runtime-only <add>if (Handlebars.compile) { <add> /** <add> The entry point for Ember Handlebars. This replaces the default Handlebars.compile and turns on <add> template-local data and String parameters. <add> <add> @method compile <add> @for Ember.Handlebars <add> @static <add> @param {String} string The template to compile <add> @return {Function} <add> */ <add> Ember.Handlebars.compile = function(string) { <add> var ast = Handlebars.parse(string); <add> var options = { data: true, stringParams: true }; <add> var environment = new Ember.Handlebars.Compiler().compile(ast, options); <add> var templateSpec = new Ember.Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true); <add> <add> return Handlebars.template(templateSpec); <add> }; <add>} <ide> <ide> /** <ide> @private
1
PHP
PHP
fix version number
8c1baedfa603b5c217b7881989b40b1633a2982c
<ide><path>tests/TestCase/Http/UriTest.php <ide> * <ide> * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <ide> * @link https://cakephp.org CakePHP(tm) Project <del> * @since 4.3.0 <add> * @since 4.4.0 <ide> * @license https://opensource.org/licenses/mit-license.php MIT License <ide> */ <ide> namespace Cake\Test\TestCase\Http;
1
Python
Python
fix comma spelling from coma to comma (#722)
dd9f0b3f2e859d24a2dd442fe2bd45fd08a9ac86
<ide><path>searches/linear_search.py <ide> def linear_search(sequence, target): <ide> <ide> <ide> if __name__ == '__main__': <del> user_input = raw_input('Enter numbers separated by coma:\n').strip() <add> user_input = raw_input('Enter numbers separated by comma:\n').strip() <ide> sequence = [int(item) for item in user_input.split(',')] <ide> <ide> target_input = raw_input('Enter a single number to be found in the list:\n')
1
PHP
PHP
correct collection sort key test
20b12e7e5ef705633cea1eb768eca9b9578c3f0c
<ide><path>tests/Support/SupportCollectionTest.php <ide> public function testSortKeys() <ide> { <ide> $data = new Collection(['b' => 'dayle', 'a' => 'taylor']); <ide> <del> $this->assertEquals(['a' => 'taylor', 'b' => 'dayle'], $data->sortKeys()->all()); <add> $sortData = $data->sortKeys()->all(); <add> <add> $this->assertEquals(['a' => 'taylor', 'b' => 'dayle'], $sortData); <add> $this->assertEquals(['a', 'b'], array_keys($sortData)); <ide> } <ide> <ide> public function testSortKeysDesc() <ide> { <ide> $data = new Collection(['a' => 'taylor', 'b' => 'dayle']); <ide> <del> $this->assertEquals(['b' => 'dayle', 'a' => 'taylor'], $data->sortKeys()->all()); <add> $sortData = $data->sortKeysDesc()->all(); <add> <add> $this->assertEquals(['b' => 'dayle', 'a' => 'taylor'], $sortData); <add> $this->assertEquals(['b', 'a'], array_keys($sortData)); <ide> } <ide> <ide> public function testReverse()
1
Ruby
Ruby
fix example in migration docs [ci skip]
07a3c2103c0db8f960ea2ba2a8748a2fe2bed206
<ide><path>activerecord/lib/active_record/migration.rb <ide> def initialize <ide> # <ide> # class AddSystemSettings < ActiveRecord::Migration <ide> # def up <del> # create_table system_settings: do |t| <add> # create_table :system_settings do |t| <ide> # t.string :name <ide> # t.string :label <ide> # t.text :value
1
PHP
PHP
add test for database type injection
2bdec07d81bff40f29f698aaa2d3e625eb9f8e07
<ide><path>tests/TestCase/Database/TypeTest.php <ide> public function testMapAndBuild() <ide> $this->assertInstanceOf($fooType, $type); <ide> $this->assertEquals('foo', $type->getName()); <ide> $this->assertEquals('text', $type->getBaseType()); <add> <add> $fooType = new FooType(); <add> Type::map('foo2', $fooType); <add> $map = Type::map(); <add> $this->assertEquals($fooType, $map['foo2']); <add> $this->assertEquals($fooType, Type::map('foo2')); <ide> } <ide> <ide> /**
1
PHP
PHP
remove getmock() deprecations
197d2d773439c9acc5f4717858c82c432d3c4bf5
<ide><path>tests/TestCase/ORM/Association/BelongsToManyTest.php <ide> class BelongsToManyTest extends TestCase <ide> public function setUp() <ide> { <ide> parent::setUp(); <del> $this->tag = $this->getMock( <del> 'Cake\ORM\Table', <del> ['find', 'delete'], <del> [['alias' => 'Tags', 'table' => 'tags']] <del> ); <add> $this->tag = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['find', 'delete']) <add> ->setConstructorArgs([['alias' => 'Tags', 'table' => 'tags']]) <add> ->getMock(); <ide> $this->tag->schema([ <ide> 'id' => ['type' => 'integer'], <ide> 'name' => ['type' => 'string'], <ide> '_constraints' => [ <ide> 'primary' => ['type' => 'primary', 'columns' => ['id']] <ide> ] <ide> ]); <del> $this->article = $this->getMock( <del> 'Cake\ORM\Table', <del> ['find', 'delete'], <del> [['alias' => 'Articles', 'table' => 'articles']] <del> ); <add> $this->article = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['find', 'delete']) <add> ->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles']]) <add> ->getMock(); <ide> $this->article->schema([ <ide> 'id' => ['type' => 'integer'], <ide> 'name' => ['type' => 'string'], <ide> public function testSaveStrategyInvalid() <ide> */ <ide> public function testCascadeDelete() <ide> { <del> $articleTag = $this->getMock('Cake\ORM\Table', ['deleteAll'], []); <add> $articleTag = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['deleteAll']) <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->article, <ide> 'targetTable' => $this->tag, <ide> public function testCascadeDelete() <ide> */ <ide> public function testCascadeDeleteDependent() <ide> { <del> $articleTag = $this->getMock('Cake\ORM\Table', ['delete', 'deleteAll'], []); <add> $articleTag = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['delete', 'deleteAll']) <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->article, <ide> 'targetTable' => $this->tag, <ide> public function testCascadeDeleteWithCallbacks() <ide> $association->junction($articleTag); <ide> $this->article->association($articleTag->alias()); <ide> <del> $counter = $this->getMock('StdClass', ['__invoke']); <add> $counter = $this->getMockBuilder('StdClass') <add> ->setMethods(['__invoke']) <add> ->getMock(); <ide> $counter->expects($this->exactly(2))->method('__invoke'); <ide> $articleTag->eventManager()->on('Model.beforeDelete', $counter); <ide> <ide> public function testLinkWithNotPersistedTarget() <ide> public function testLinkSuccess() <ide> { <ide> $connection = ConnectionManager::get('test'); <del> $joint = $this->getMock( <del> '\Cake\ORM\Table', <del> ['save'], <del> [['alias' => 'ArticlesTags', 'connection' => $connection]] <del> ); <add> $joint = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['save']) <add> ->setConstructorArgs([['alias' => 'ArticlesTags', 'connection' => $connection]]) <add> ->getMock(); <add> <ide> $config = [ <ide> 'sourceTable' => $this->article, <ide> 'targetTable' => $this->tag, <ide> public function testSaveAssociatedNotEmptyNotIterable() <ide> */ <ide> public function testSaveAssociatedEmptySetSuccess($value) <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association\BelongsToMany', <del> ['_saveTarget', 'replaceLinks'], <del> ['tags', ['sourceTable' => $table]] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany') <add> ->setMethods(['_saveTarget', 'replaceLinks']) <add> ->setConstructorArgs(['tags', ['sourceTable' => $table]]) <add> ->getMock(); <ide> $entity = new Entity([ <ide> 'id' => 1, <ide> 'tags' => $value, <ide> public function testSaveAssociatedEmptySetSuccess($value) <ide> */ <ide> public function testSaveAssociatedEmptySetUpdateSuccess($value) <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association\BelongsToMany', <del> ['_saveTarget', 'replaceLinks'], <del> ['tags', ['sourceTable' => $table]] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany') <add> ->setMethods(['_saveTarget', 'replaceLinks']) <add> ->setConstructorArgs(['tags', ['sourceTable' => $table]]) <add> ->getMock(); <ide> $entity = new Entity([ <ide> 'id' => 1, <ide> 'tags' => $value, <ide> public function testSaveAssociatedEmptySetUpdateSuccess($value) <ide> */ <ide> public function testSaveAssociatedWithReplace() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association\BelongsToMany', <del> ['replaceLinks'], <del> ['tags', ['sourceTable' => $table]] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany') <add> ->setMethods(['replaceLinks']) <add> ->setConstructorArgs(['tags', ['sourceTable' => $table]]) <add> ->getMock(); <ide> $entity = new Entity([ <ide> 'id' => 1, <ide> 'tags' => [ <ide> public function testSaveAssociatedWithReplace() <ide> */ <ide> public function testSaveAssociatedWithReplaceReturnFalse() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association\BelongsToMany', <del> ['replaceLinks'], <del> ['tags', ['sourceTable' => $table]] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association\BelongsToMany') <add> ->setMethods(['replaceLinks']) <add> ->setConstructorArgs(['tags', ['sourceTable' => $table]]) <add> ->getMock(); <ide> $entity = new Entity([ <ide> 'id' => 1, <ide> 'tags' => [ <ide> public function testSaveAssociatedWithReplaceReturnFalse() <ide> public function testSaveAssociatedOnlyEntitiesAppend() <ide> { <ide> $connection = ConnectionManager::get('test'); <del> $mock = $this->getMock( <del> 'Cake\ORM\Table', <del> ['saveAssociated', 'schema'], <del> [['table' => 'tags', 'connection' => $connection]] <del> ); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['saveAssociated', 'schema']) <add> ->setConstructorArgs([['table' => 'tags', 'connection' => $connection]]) <add> ->getMock(); <ide> $mock->primaryKey('id'); <ide> <ide> $config = [ <ide> public function testPropertyOption() <ide> */ <ide> public function testPropertyNoPlugin() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->article, <ide> 'targetTable' => $mock, <ide><path>tests/TestCase/ORM/Association/BelongsToTest.php <ide> public function testAttachToMultiPrimaryKeyMistmatch() <ide> */ <ide> public function testCascadeDelete() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->client, <ide> 'targetTable' => $mock, <ide> public function testCascadeDelete() <ide> */ <ide> public function testSaveAssociatedOnlyEntities() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['saveAssociated']) <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->client, <ide> 'targetTable' => $mock, <ide> public function testPropertyOption() <ide> */ <ide> public function testPropertyNoPlugin() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->client, <ide> 'targetTable' => $mock, <ide> public function testAttachToBeforeFind() <ide> 'sourceTable' => $this->client, <ide> 'targetTable' => $this->company <ide> ]; <del> $listener = $this->getMock('stdClass', ['__invoke']); <add> $listener = $this->getMockBuilder('stdClass') <add> ->setMethods(['__invoke']) <add> ->getMock(); <ide> $this->company->eventManager()->attach($listener, 'Model.beforeFind'); <ide> $association = new BelongsTo('Companies', $config); <ide> $listener->expects($this->once())->method('__invoke') <ide> public function testAttachToBeforeFindExtraOptions() <ide> 'sourceTable' => $this->client, <ide> 'targetTable' => $this->company <ide> ]; <del> $listener = $this->getMock('stdClass', ['__invoke']); <add> $listener = $this->getMockBuilder('stdClass') <add> ->setMethods(['__invoke']) <add> ->getMock(); <ide> $this->company->eventManager()->attach($listener, 'Model.beforeFind'); <ide> $association = new BelongsTo('Companies', $config); <ide> $options = new \ArrayObject(['something' => 'more']); <ide><path>tests/TestCase/ORM/Association/HasManyTest.php <ide> public function setUp() <ide> ] <ide> ]); <ide> $connection = ConnectionManager::get('test'); <del> $this->article = $this->getMock( <del> 'Cake\ORM\Table', <del> ['find', 'deleteAll', 'delete'], <del> [['alias' => 'Articles', 'table' => 'articles', 'connection' => $connection]] <del> ); <add> $this->article = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['find', 'deleteAll', 'delete']) <add> ->setConstructorArgs([['alias' => 'Articles', 'table' => 'articles', 'connection' => $connection]]) <add> ->getMock(); <ide> $this->article->schema([ <ide> 'id' => ['type' => 'integer'], <ide> 'title' => ['type' => 'string'], <ide> public function testEagerLoaderMultipleKeys() <ide> $this->author->primaryKey(['id', 'site_id']); <ide> $association = new HasMany('Articles', $config); <ide> $keys = [[1, 10], [2, 20], [3, 30], [4, 40]]; <del> $query = $this->getMock('Cake\ORM\Query', ['all', 'andWhere'], [null, null]); <add> $query = $this->getMockBuilder('Cake\ORM\Query') <add> ->setMethods(['all', 'andWhere']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $this->article->method('find') <ide> ->with('all') <ide> ->will($this->returnValue($query)); <ide> public function testCascadeDeleteCallbacks() <ide> */ <ide> public function testSaveAssociatedOnlyEntities() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['saveAssociated']) <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->author, <ide> 'targetTable' => $mock, <ide> public function testPropertyOption() <ide> */ <ide> public function testPropertyNoPlugin() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->author, <ide> 'targetTable' => $mock, <ide><path>tests/TestCase/ORM/Association/HasOneTest.php <ide> public function testCanBeJoined() <ide> */ <ide> public function testAttachTo() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'foreignKey' => 'user_id', <ide> 'sourceTable' => $this->user, <ide> public function testAttachTo() <ide> */ <ide> public function testAttachToNoFields() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $this->profile, <ide> public function testAttachToNoFields() <ide> */ <ide> public function testAttachToMultiPrimaryKey() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $this->profile, <ide> public function testAttachToMultiPrimaryKey() <ide> */ <ide> public function testAttachToMultiPrimaryKeyMistmatch() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $this->profile, <ide> public function testAttachToMultiPrimaryKeyMistmatch() <ide> */ <ide> public function testSaveAssociatedOnlyEntities() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['saveAssociated']) <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $mock, <ide> public function testPropertyOption() <ide> */ <ide> public function testPropertyNoPlugin() <ide> { <del> $mock = $this->getMock('Cake\ORM\Table', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $config = [ <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $mock, <ide> public function testPropertyNoPlugin() <ide> */ <ide> public function testAttachToBeforeFind() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'foreignKey' => 'user_id', <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $this->profile, <ide> ]; <del> $listener = $this->getMock('stdClass', ['__invoke']); <add> $listener = $this->getMockBuilder('stdClass') <add> ->setMethods(['__invoke']) <add> ->getMock(); <ide> $this->profile->eventManager()->attach($listener, 'Model.beforeFind'); <ide> $association = new HasOne('Profiles', $config); <ide> $listener->expects($this->once())->method('__invoke') <ide> public function testAttachToBeforeFind() <ide> */ <ide> public function testAttachToBeforeFindExtraOptions() <ide> { <del> $query = $this->getMock('\Cake\ORM\Query', ['join', 'select'], [null, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join', 'select']) <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $config = [ <ide> 'foreignKey' => 'user_id', <ide> 'sourceTable' => $this->user, <ide> 'targetTable' => $this->profile, <ide> ]; <del> $listener = $this->getMock('stdClass', ['__invoke']); <add> $listener = $this->getMockBuilder('stdClass') <add> ->setMethods(['__invoke']) <add> ->getMock(); <ide> $this->profile->eventManager()->attach($listener, 'Model.beforeFind'); <ide> $association = new HasOne('Profiles', $config); <ide> $opts = new \ArrayObject(['something' => 'more']); <ide><path>tests/TestCase/ORM/AssociationCollectionTest.php <ide> public function testRemoveAll() <ide> */ <ide> public function testGetByProperty() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <ide> $belongsTo = new BelongsTo('Users', [ <ide> 'sourceTable' => $table <ide> public function testType() <ide> */ <ide> public function testCascadeDelete() <ide> { <del> $mockOne = $this->getMock('Cake\ORM\Association\BelongsTo', [], ['']); <del> $mockTwo = $this->getMock('Cake\ORM\Association\HasMany', [], ['']); <add> $mockOne = $this->getMockBuilder('Cake\ORM\Association\BelongsTo') <add> ->setConstructorArgs(['']) <add> ->getMock(); <add> $mockTwo = $this->getMockBuilder('Cake\ORM\Association\HasMany') <add> ->setConstructorArgs(['']) <add> ->getMock(); <ide> <ide> $entity = new Entity(); <ide> $options = ['option' => 'value']; <ide> public function testCascadeDelete() <ide> */ <ide> public function testSaveParents() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $mockOne = $this->getMock( <del> 'Cake\ORM\Association\BelongsTo', <del> ['saveAssociated'], <del> ['Parent', [ <add> $mockOne = $this->getMockBuilder('Cake\ORM\Association\BelongsTo') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Parent', [ <ide> 'sourceTable' => $table, <del> ]] <del> ); <del> $mockTwo = $this->getMock( <del> 'Cake\ORM\Association\HasMany', <del> ['saveAssociated'], <del> ['Child', [ <add> ]]) <add> ->getMock(); <add> $mockTwo = $this->getMockBuilder('Cake\ORM\Association\HasMany') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Child', [ <ide> 'sourceTable' => $table <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <ide> $this->associations->add('Parent', $mockOne); <ide> $this->associations->add('Child', $mockTwo); <ide> public function testSaveParents() <ide> */ <ide> public function testSaveParentsFiltered() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $mockOne = $this->getMock( <del> 'Cake\ORM\Association\BelongsTo', <del> ['saveAssociated'], <del> ['Parents', [ <add> $mockOne = $this->getMockBuilder('Cake\ORM\Association\BelongsTo') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Parents', [ <ide> 'sourceTable' => $table, <del> ]] <del> ); <del> $mockTwo = $this->getMock( <del> 'Cake\ORM\Association\BelongsTo', <del> ['saveAssociated'], <del> ['Categories', [ <add> ]]) <add> ->getMock(); <add> $mockTwo = $this->getMockBuilder('Cake\ORM\Association\BelongsTo') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Categories', [ <ide> 'sourceTable' => $table <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <ide> $this->associations->add('Parents', $mockOne); <ide> $this->associations->add('Categories', $mockTwo); <ide> public function testSaveParentsFiltered() <ide> */ <ide> public function testSaveChildrenFiltered() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['table'], [[]]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['table']) <add> ->getMock(); <ide> $table->schema([]); <del> $mockOne = $this->getMock( <del> 'Cake\ORM\Association\HasMany', <del> ['saveAssociated'], <del> ['Comments', [ <add> $mockOne = $this->getMockBuilder('Cake\ORM\Association\HasMany') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Comments', [ <ide> 'sourceTable' => $table, <del> ]] <del> ); <del> $mockTwo = $this->getMock( <del> 'Cake\ORM\Association\HasOne', <del> ['saveAssociated'], <del> ['Profiles', [ <add> ]]) <add> ->getMock(); <add> $mockTwo = $this->getMockBuilder('Cake\ORM\Association\HasOne') <add> ->setMethods(['saveAssociated']) <add> ->setConstructorArgs(['Profiles', [ <ide> 'sourceTable' => $table <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <ide> $this->associations->add('Comments', $mockOne); <ide> $this->associations->add('Profiles', $mockTwo); <ide> public function testSaveChildrenFiltered() <ide> */ <ide> public function testErrorOnUnknownAlias() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['save'], <del> [['alias' => 'Users']] <del> ); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['save']) <add> ->setConstructorArgs([['alias' => 'Users']]) <add> ->getMock(); <ide> <ide> $entity = new Entity(); <ide> $entity->set('profile', ['key' => 'value']); <ide><path>tests/TestCase/ORM/AssociationProxyTest.php <ide> public function testAssociationAsPropertyProxy() <ide> public function testAssociationMethodProxy() <ide> { <ide> $articles = TableRegistry::get('articles'); <del> $mock = $this->getMock('Cake\ORM\Table', ['crazy']); <add> $mock = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['crazy']) <add> ->getMock(); <ide> $articles->belongsTo('authors', [ <ide> 'targetTable' => $mock <ide> ]); <ide><path>tests/TestCase/ORM/AssociationTest.php <ide> public function setUp() <ide> 'sourceTable' => $this->source, <ide> 'joinType' => 'INNER' <ide> ]; <del> $this->association = $this->getMock( <del> '\Cake\ORM\Association', <del> [ <add> $this->association = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods([ <ide> '_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide', <ide> 'saveAssociated', 'eagerLoader', 'type' <del> ], <del> ['Foo', $config] <del> ); <add> ]) <add> ->setConstructorArgs(['Foo', $config]) <add> ->getMock(); <ide> } <ide> <ide> /** <ide> public function testClassNameUnnormalized() <ide> $config = [ <ide> 'className' => 'Test', <ide> ]; <del> $this->association = $this->getMock( <del> '\Cake\ORM\Association', <del> [ <add> $this->association = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods([ <ide> '_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide', <ide> 'saveAssociated', 'eagerLoader', 'type' <del> ], <del> ['Foo', $config] <del> ); <add> ]) <add> ->setConstructorArgs(['Foo', $config]) <add> ->getMock(); <ide> <ide> $this->assertEquals('Test', $this->association->className()); <ide> } <ide> public function testTargetPlugin() <ide> 'joinType' => 'INNER' <ide> ]; <ide> <del> $this->association = $this->getMock( <del> '\Cake\ORM\Association', <del> ['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'], <del> ['ThisAssociationName', $config] <del> ); <add> $this->association = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods(['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated']) <add> ->setConstructorArgs(['ThisAssociationName', $config]) <add> ->getMock(); <ide> <ide> $table = $this->association->target(); <ide> $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $table); <ide> public function testPropertyNameExplicitySet() <ide> 'joinType' => 'INNER', <ide> 'propertyName' => 'foo' <ide> ]; <del> $association = $this->getMock( <del> '\Cake\ORM\Association', <del> [ <add> $association = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods([ <ide> '_options', 'attachTo', '_joinCondition', 'cascadeDelete', 'isOwningSide', <ide> 'saveAssociated', 'eagerLoader', 'type' <del> ], <del> ['Foo', $config] <del> ); <add> ]) <add> ->setConstructorArgs(['Foo', $config]) <add> ->getMock(); <ide> <ide> $this->assertEquals('foo', $association->property()); <ide> } <ide> public function testFinderInConstructor() <ide> 'joinType' => 'INNER', <ide> 'finder' => 'published' <ide> ]; <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association', <del> ['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'], <del> ['Foo', $config] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods(['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated']) <add> ->setConstructorArgs(['Foo', $config]) <add> ->getMock(); <ide> $this->assertEquals('published', $assoc->finder()); <ide> } <ide> <ide> public function testLocatorInConstructor() <ide> 'className' => '\Cake\Test\TestCase\ORM\TestTable', <ide> 'tableLocator' => $locator <ide> ]; <del> $assoc = $this->getMock( <del> '\Cake\ORM\Association', <del> ['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'], <del> ['Foo', $config] <del> ); <add> $assoc = $this->getMockBuilder('\Cake\ORM\Association') <add> ->setMethods(['type', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated']) <add> ->setConstructorArgs(['Foo', $config]) <add> ->getMock(); <ide> $this->assertEquals($locator, $assoc->tableLocator()); <ide> } <ide> } <ide><path>tests/TestCase/ORM/BehaviorRegistryTest.php <ide> public function testCallFinder() <ide> ->getMock(); <ide> $this->Behaviors->set('Sluggable', $mockedBehavior); <ide> <del> $query = $this->getMock('Cake\ORM\Query', [], [null, null]); <add> $query = $this->getMockBuilder('Cake\ORM\Query') <add> ->setConstructorArgs([null, null]) <add> ->getMock(); <ide> $mockedBehavior <ide> ->expects($this->once()) <ide> ->method('findNoSlug') <ide><path>tests/TestCase/ORM/CompositeKeysTest.php <ide> public function testFindListCompositeKeys() <ide> public function testFindThreadedCompositeKeys() <ide> { <ide> $table = TableRegistry::get('SiteAuthors'); <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['_addDefaultFields', 'execute'], <del> [null, $table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['_addDefaultFields', 'execute']) <add> ->setConstructorArgs([null, $table]) <add> ->getMock(); <ide> <ide> $items = new \Cake\Datasource\ResultSetDecorator([ <ide> ['id' => 1, 'name' => 'a', 'site_id' => 1, 'parent_id' => null], <ide><path>tests/TestCase/ORM/EagerLoaderTest.php <ide> public function testContainToJoinsOneLevel() <ide> ] <ide> ]; <ide> <del> $query = $this->getMock('\Cake\ORM\Query', ['join'], [$this->connection, $this->table]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join']) <add> ->setConstructorArgs([$this->connection, $this->table]) <add> ->getMock(); <ide> <ide> $query->typeMap($this->clientsTypeMap); <ide> <ide> public function testNormalizedPath() <ide> ] <ide> ]; <ide> <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['join'], <del> [$this->connection, $this->table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['join']) <add> ->setConstructorArgs([$this->connection, $this->table]) <add> ->getMock(); <ide> <ide> $loader = new EagerLoader; <ide> $loader->contain($contains); <ide><path>tests/TestCase/ORM/EntityTest.php <ide> public function testExtractOriginalValues() <ide> */ <ide> public function testSetOneParamWithSetter() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setName']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_setName') <ide> ->with('Jones') <ide> ->will($this->returnCallback(function ($name) { <ide> public function testSetOneParamWithSetter() <ide> */ <ide> public function testMultipleWithSetter() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setName', '_setStuff']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setName', '_setStuff']) <add> ->getMock(); <ide> $entity->accessible('*', true); <ide> $entity->expects($this->once())->method('_setName') <ide> ->with('Jones') <ide> public function testMultipleWithSetter() <ide> */ <ide> public function testBypassSetters() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setName', '_setStuff']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setName', '_setStuff']) <add> ->getMock(); <ide> $entity->accessible('*', true); <ide> <ide> $entity->expects($this->never())->method('_setName'); <ide> public function testGetNoGetters() <ide> */ <ide> public function testGetCustomGetters() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->expects($this->any()) <ide> ->method('_getName') <ide> ->with('Jones') <ide> public function testGetCustomGetters() <ide> */ <ide> public function testGetCustomGettersAfterSet() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->expects($this->any()) <ide> ->method('_getName') <ide> ->will($this->returnCallback(function ($name) { <ide> public function testGetCustomGettersAfterSet() <ide> */ <ide> public function testGetCacheClearedByUnset() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->expects($this->any())->method('_getName') <ide> ->will($this->returnCallback(function ($name) { <ide> return 'Dr. ' . $name; <ide> public function testGetCacheClearedByUnset() <ide> */ <ide> public function testGetCamelCasedProperties() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getListIdName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getListIdName']) <add> ->getMock(); <ide> $entity->expects($this->any())->method('_getListIdName') <ide> ->will($this->returnCallback(function ($name) { <ide> return 'A name'; <ide> public function testMagicSet() <ide> */ <ide> public function testMagicSetWithSetter() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setName']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_setName') <ide> ->with('Jones') <ide> ->will($this->returnCallback(function ($name) { <ide> public function testMagicSetWithSetter() <ide> */ <ide> public function testMagicSetWithSetterTitleCase() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setName']) <add> ->getMock(); <ide> $entity->expects($this->once()) <ide> ->method('_setName') <ide> ->with('Jones') <ide> public function testMagicSetWithSetterTitleCase() <ide> */ <ide> public function testMagicGetWithGetter() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_getName') <ide> ->with('Jones') <ide> ->will($this->returnCallback(function ($name) { <ide> public function testMagicGetWithGetter() <ide> */ <ide> public function testMagicGetWithGetterTitleCase() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->expects($this->once()) <ide> ->method('_getName') <ide> ->with('Jones') <ide> public function testHas() <ide> $this->assertFalse($entity->has(['id', 'foo'])); <ide> $this->assertFalse($entity->has(['id', 'nope'])); <ide> <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getThings']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getThings']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_getThings') <ide> ->will($this->returnValue(0)); <ide> $this->assertTrue($entity->has('things')); <ide> public function testMagicIsset() <ide> */ <ide> public function testMagicUnset() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['unsetProperty']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['unsetProperty']) <add> ->getMock(); <ide> $entity->expects($this->at(0)) <ide> ->method('unsetProperty') <ide> ->with('foo'); <ide> public function testIssetArrayAccess() <ide> */ <ide> public function testGetArrayAccess() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['get']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['get']) <add> ->getMock(); <ide> $entity->expects($this->at(0)) <ide> ->method('get') <ide> ->with('foo') <ide> public function testGetArrayAccess() <ide> */ <ide> public function testSetArrayAccess() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['set']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['set']) <add> ->getMock(); <ide> $entity->accessible('*', true); <ide> <ide> $entity->expects($this->at(0)) <ide> public function testSetArrayAccess() <ide> */ <ide> public function testUnsetArrayAccess() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['unsetProperty']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['unsetProperty']) <add> ->getMock(); <ide> $entity->expects($this->at(0)) <ide> ->method('unsetProperty') <ide> ->with('foo'); <ide> public function testUnsetArrayAccess() <ide> */ <ide> public function testMethodCache() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_setFoo', '_getBar']); <del> $entity2 = $this->getMock('\Cake\ORM\Entity', ['_setBar']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setFoo', '_getBar']) <add> ->getMock(); <add> $entity2 = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_setBar']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_setFoo'); <ide> $entity->expects($this->once())->method('_getBar'); <ide> $entity2->expects($this->once())->method('_setBar'); <ide> public function testMethodCache() <ide> */ <ide> public function testSetGetLongProperyNames() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getVeryLongProperty', '_setVeryLongProperty']); <add> $entity = $this->getMockBUilder('\Cake\ORM\Entity') <add> ->setMethods(['_getVeryLongProperty', '_setVeryLongProperty']) <add> ->getMock(); <ide> $entity->expects($this->once())->method('_getVeryLongProperty'); <ide> $entity->expects($this->once())->method('_setVeryLongProperty'); <ide> $entity->get('very_long_property'); <ide> public function testToArrayMixed() <ide> */ <ide> public function testToArrayWithAccessor() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->accessible('*', true); <ide> $entity->set(['name' => 'Mark', 'email' => 'mark@example.com']); <ide> $entity->expects($this->any()) <ide> public function testToArrayHiddenProperties() <ide> */ <ide> public function testToArrayVirtualProperties() <ide> { <del> $entity = $this->getMock('\Cake\ORM\Entity', ['_getName']); <add> $entity = $this->getMockBuilder('\Cake\ORM\Entity') <add> ->setMethods(['_getName']) <add> ->getMock(); <ide> $entity->accessible('*', true); <ide> <ide> $entity->expects($this->any()) <ide><path>tests/TestCase/ORM/QueryTest.php <ide> public function collectionMethodsProvider() <ide> */ <ide> public function testCollectionProxy($method, $arg) <ide> { <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['all'], <del> [$this->connection, $this->table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['all']) <add> ->setConstructorArgs([$this->connection, $this->table]) <add> ->getMock(); <ide> $query->select(); <del> $resultSet = $this->getMock('\Cake\ORM\ResultSet', [], [$query, null]); <add> $resultSet = $this->getMockbuilder('\Cake\ORM\ResultSet') <add> ->setConstructorArgs([$query, null]) <add> ->getMock(); <ide> $query->expects($this->once()) <ide> ->method('all') <ide> ->will($this->returnValue($resultSet)); <ide> public function testCacheErrorOnNonSelect() <ide> */ <ide> public function testCacheReadIntegration() <ide> { <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['execute'], <del> [$this->connection, $this->table] <del> ); <del> $resultSet = $this->getMock('\Cake\ORM\ResultSet', [], [$query, null]); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['execute']) <add> ->setConstructorArgs([$this->connection, $this->table]) <add> ->getMock(); <add> $resultSet = $this->getMockBuilder('\Cake\ORM\ResultSet') <add> ->setConstructorArgs([$query, null]) <add> ->getMock(); <ide> <ide> $query->expects($this->never()) <ide> ->method('execute'); <ide><path>tests/TestCase/ORM/TableTest.php <ide> public function testSchema() <ide> public function testSchemaInitialize() <ide> { <ide> $schema = $this->connection->schemaCollection()->describe('users'); <del> $table = $this->getMock('Cake\ORM\Table', ['_initializeSchema'], [ <del> ['table' => 'users', 'connection' => $this->connection] <del> ]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['_initializeSchema']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <ide> $table->expects($this->once()) <ide> ->method('_initializeSchema') <ide> ->with($schema) <ide> public function testUpdateAll() <ide> */ <ide> public function testUpdateAllFailure() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <del> $query = $this->getMock('Cake\ORM\Query', ['execute'], [$this->connection, $table]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <add> $query = $this->getMockBuilder('Cake\ORM\Query') <add> ->setMethods(['execute']) <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> $table->expects($this->once()) <ide> ->method('query') <ide> ->will($this->returnValue($query)); <ide> public function testDeleteAllAliasedConditions() <ide> */ <ide> public function testDeleteAllFailure() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <del> $query = $this->getMock('Cake\ORM\Query', ['execute'], [$this->connection, $table]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <add> $query = $this->getMockBuilder('Cake\ORM\Query') <add> ->setMethods(['execute']) <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> $table->expects($this->once()) <ide> ->method('query') <ide> ->will($this->returnValue($query)); <ide> public function testDeleteAllFailure() <ide> */ <ide> public function testFindApplyOptions() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['query', 'findAll'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <del> $query = $this->getMock('Cake\ORM\Query', [], [$this->connection, $table]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['query', 'findAll']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <add> $query = $this->getMockBuilder('Cake\ORM\Query') <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> $table->expects($this->once()) <ide> ->method('query') <ide> ->will($this->returnValue($query)); <ide> public function testFindThreadedNoHydration() <ide> */ <ide> public function testStackingFinders() <ide> { <del> $table = $this->getMock('\Cake\ORM\Table', ['find', 'findList'], [], '', false); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['find', 'findList']) <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $params = [$this->connection, $table]; <del> $query = $this->getMock('\Cake\ORM\Query', ['addDefaultTypes'], $params); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['addDefaultTypes']) <add> ->setConstructorArgs($params) <add> ->getMock(); <ide> <ide> $table->expects($this->once()) <ide> ->method('find') <ide> public function testExists() <ide> */ <ide> public function testAddBehavior() <ide> { <del> $mock = $this->getMock('Cake\ORM\BehaviorRegistry', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\BehaviorRegistry') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $mock->expects($this->once()) <ide> ->method('load') <ide> ->with('Sluggable'); <ide> public function testAddBehaviorDuplicate() <ide> */ <ide> public function testRemoveBehavior() <ide> { <del> $mock = $this->getMock('Cake\ORM\BehaviorRegistry', [], [], '', false); <add> $mock = $this->getMockBuilder('Cake\ORM\BehaviorRegistry') <add> ->disableOriginalConstructor() <add> ->getMock(); <ide> $mock->expects($this->once()) <ide> ->method('unload') <ide> ->with('Sluggable'); <ide> public function testCallBehaviorAliasedFinder() <ide> */ <ide> public function testImplementedEvents() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['beforeFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete'] <del> ); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['beforeFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete']) <add> ->getMock(); <ide> $result = $table->implementedEvents(); <ide> $expected = [ <ide> 'Model.beforeFind' => 'beforeFind', <ide> public function testSaveNewEmptyEntity() <ide> */ <ide> public function testSaveNewEntityNoExists() <ide> { <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['exists'], <del> [[ <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['exists']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'alias' => 'Users', <ide> 'table' => 'users', <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> $entity = $table->newEntity(['username' => 'mark']); <ide> $this->assertTrue($entity->isNew()); <ide> <ide> public function testSaveNewEntityNoExists() <ide> public function testSavePrimaryKeyEntityExists() <ide> { <ide> $this->skipIfSqlServer(); <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['exists'], <del> [ <del> [ <del> 'connection' => $this->connection, <del> 'alias' => 'Users', <del> 'table' => 'users', <del> ] <del> ] <del> ); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['exists']) <add> ->setConstructorArgs([[ <add> 'connection' => $this->connection, <add> 'alias' => 'Users', <add> 'table' => 'users', <add> ]]) <add> ->getMock(); <ide> $entity = $table->newEntity(['id' => 20, 'username' => 'mark']); <ide> $this->assertTrue($entity->isNew()); <ide> <ide> public function testSaveReplaceSaveStrategyAdding() <ide> public function testSavePrimaryKeyEntityNoExists() <ide> { <ide> $this->skipIfSqlServer(); <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['exists'], <del> [ <del> [ <del> 'connection' => $this->connection, <del> 'alias' => 'Users', <del> 'table' => 'users', <del> ] <del> ] <del> ); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['exists']) <add> ->setConstructorArgs([[ <add> 'connection' => $this->connection, <add> 'alias' => 'Users', <add> 'table' => 'users', <add> ]]) <add> ->getMock(); <ide> $entity = $table->newEntity(['id' => 20, 'username' => 'mark']); <ide> $this->assertTrue($entity->isNew()); <ide> <ide> public function testAfterSaveCommitWithNonAtomicAndTransactionRunning() <ide> */ <ide> public function testAfterSaveNotCalled() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['execute', 'addDefaultTypes'], <del> [null, $table] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['execute', 'addDefaultTypes']) <add> ->setConstructorArgs([null, $table]) <add> ->getMock(); <ide> $statement = $this->getMockBuilder('\Cake\Database\Statement\StatementDecorator')->getMock(); <ide> $data = new \Cake\ORM\Entity([ <ide> 'username' => 'superuser', <ide> public function testAtomicSave() <ide> { <ide> $config = ConnectionManager::config('test'); <ide> <del> $connection = $this->getMock( <del> '\Cake\Database\Connection', <del> ['begin', 'commit'], <del> [$config] <del> ); <add> $connection = $this->getMockBuilder('\Cake\Database\Connection') <add> ->setMethods(['begin', 'commit']) <add> ->setConstructorArgs([$config]) <add> ->getMock(); <ide> $connection->driver($this->connection->driver()); <ide> <del> $table = $this->getMock('\Cake\ORM\Table', ['connection'], [['table' => 'users']]); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['connection']) <add> ->setConstructorArgs([['table' => 'users']]) <add> ->getMock(); <ide> $table->expects($this->any())->method('connection') <ide> ->will($this->returnValue($connection)); <ide> <ide> public function testAtomicSave() <ide> */ <ide> public function testAtomicSaveRollback() <ide> { <del> $connection = $this->getMock( <del> '\Cake\Database\Connection', <del> ['begin', 'rollback'], <del> [ConnectionManager::config('test')] <del> ); <add> $connection = $this->getMockBuilder('\Cake\Database\Connection') <add> ->setMethods(['begin', 'rollback']) <add> ->setConstructorArgs([ConnectionManager::config('test')]) <add> ->getMock(); <ide> $connection->driver(ConnectionManager::get('test')->driver()); <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query', 'connection'], <del> [['table' => 'users']] <del> ); <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['execute', 'addDefaultTypes'], <del> [null, $table] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query', 'connection']) <add> ->setConstructorArgs([['table' => 'users']]) <add> ->getMock(); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['execute', 'addDefaultTypes']) <add> ->setConstructorArgs([null, $table]) <add> ->getMock(); <ide> $table->expects($this->any())->method('connection') <ide> ->will($this->returnValue($connection)); <ide> <ide> public function testAtomicSaveRollback() <ide> */ <ide> public function testAtomicSaveRollbackOnFailure() <ide> { <del> $connection = $this->getMock( <del> '\Cake\Database\Connection', <del> ['begin', 'rollback'], <del> [ConnectionManager::config('test')] <del> ); <add> $connection = $this->getMockBuilder('\Cake\Database\Connection') <add> ->setMethods(['begin', 'rollback']) <add> ->setConstructorArgs([ConnectionManager::config('test')]) <add> ->getMock(); <ide> $connection->driver(ConnectionManager::get('test')->driver()); <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query', 'connection', 'exists'], <del> [['table' => 'users']] <del> ); <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['execute', 'addDefaultTypes'], <del> [null, $table] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query', 'connection', 'exists']) <add> ->setConstructorArgs([['table' => 'users']]) <add> ->getMock(); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['execute', 'addDefaultTypes']) <add> ->setConstructorArgs([null, $table]) <add> ->getMock(); <ide> <ide> $table->expects($this->any())->method('connection') <ide> ->will($this->returnValue($connection)); <ide> public function testBeforeSaveGetsCorrectPersistance() <ide> */ <ide> public function testSaveUpdateWithHint() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['exists'], <del> [['table' => 'users', 'connection' => ConnectionManager::get('test')]] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['exists']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => ConnectionManager::get('test')]]) <add> ->getMock(); <ide> $entity = new \Cake\ORM\Entity([ <ide> 'id' => 2, <ide> 'username' => 'baggins' <ide> public function testSaveUpdateWithHint() <ide> */ <ide> public function testSaveUpdatePrimaryKeyNotModified() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <ide> <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['execute', 'addDefaultTypes', 'set'], <del> [null, $table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['execute', 'addDefaultTypes', 'set']) <add> ->setConstructorArgs([null, $table]) <add> ->getMock(); <ide> <ide> $table->expects($this->once())->method('query') <ide> ->will($this->returnValue($query)); <ide> public function testSaveUpdatePrimaryKeyNotModified() <ide> */ <ide> public function testUpdateNoChange() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <ide> $table->expects($this->never())->method('query'); <ide> $entity = new \Cake\ORM\Entity([ <ide> 'id' => 2, <ide> public function testUpdateDirtyNoActualChanges() <ide> */ <ide> public function testUpdateNoPrimaryButOtherKeys() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['query'], <del> [['table' => 'users', 'connection' => $this->connection]] <del> ); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['table' => 'users', 'connection' => $this->connection]]) <add> ->getMock(); <ide> $table->expects($this->never())->method('query'); <ide> $entity = new \Cake\ORM\Entity([ <ide> 'username' => 'mariano', <ide> public function testDeleteIsNew() <ide> { <ide> $entity = new \Cake\ORM\Entity(['id' => 1, 'name' => 'mark']); <ide> <del> $table = $this->getMock( <del> 'Cake\ORM\Table', <del> ['query'], <del> [['connection' => $this->connection]] <del> ); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['query']) <add> ->setConstructorArgs([['connection' => $this->connection]]) <add> ->getMock(); <ide> $table->expects($this->never()) <ide> ->method('query'); <ide> <ide> public function testValidatorDefault() <ide> */ <ide> public function functionTestValidationWithDefiner() <ide> { <del> $table = $this->getMock('\Cake\ORM\Table', ['validationForOtherStuff']); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['validationForOtherStuff']) <add> ->getMock(); <ide> $table->expects($this->once())->method('validationForOtherStuff') <ide> ->will($this->returnArgument(0)); <ide> $other = $table->validator('forOtherStuff'); <ide> public function testSaveBelongsToManyIgnoreNonEntityData() <ide> */ <ide> public function testSaveCleanEntity() <ide> { <del> $table = $this->getMock('\Cake\ORM\Table', ['_processSave']); <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['_processSave']) <add> ->getMock(); <ide> $entity = new \Cake\ORM\Entity( <ide> ['id' => 'foo'], <ide> ['markNew' => false, 'markClean' => true] <ide> public function testBelongsToManyIntegration() <ide> */ <ide> public function testSaveDeepAssociationOptions() <ide> { <del> $articles = $this->getMock( <del> '\Cake\ORM\Table', <del> ['_insert'], <del> [['table' => 'articles', 'connection' => $this->connection]] <del> ); <del> $authors = $this->getMock( <del> '\Cake\ORM\Table', <del> ['_insert'], <del> [['table' => 'authors', 'connection' => $this->connection]] <del> ); <del> $supervisors = $this->getMock( <del> '\Cake\ORM\Table', <del> ['_insert', 'validate'], <del> [[ <add> $articles = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['_insert']) <add> ->setConstructorArgs([['table' => 'articles', 'connection' => $this->connection]]) <add> ->getMock(); <add> $authors = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['_insert']) <add> ->setConstructorArgs([['table' => 'authors', 'connection' => $this->connection]]) <add> ->getMock(); <add> $supervisors = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['_insert', 'validate']) <add> ->setConstructorArgs([[ <ide> 'table' => 'authors', <ide> 'alias' => 'supervisors', <ide> 'connection' => $this->connection <del> ]] <del> ); <del> $tags = $this->getMock( <del> '\Cake\ORM\Table', <del> ['_insert'], <del> [['table' => 'tags', 'connection' => $this->connection]] <del> ); <add> ]]) <add> ->getMock(); <add> $tags = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['_insert']) <add> ->setConstructorArgs([['table' => 'tags', 'connection' => $this->connection]]) <add> ->getMock(); <ide> <ide> $articles->belongsTo('authors', ['targetTable' => $authors]); <ide> $authors->hasOne('supervisors', ['targetTable' => $supervisors]); <ide> public function testUnlinkHasManyEmpty() <ide> */ <ide> public function testReplaceHasManyOnErrorDependentCascadeCallbacks() <ide> { <del> $articles = $this->getMock( <del> 'Cake\ORM\Table', <del> ['delete'], <del> [[ <add> $articles = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['delete']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'alias' => 'Articles', <ide> 'table' => 'articles', <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <ide> $articles->method('delete')->willReturn(false); <ide> <ide> $associations = new AssociationCollection(); <ide> <del> $hasManyArticles = $this->getMock( <del> 'Cake\ORM\Association\HasMany', <del> ['target'], <del> [ <add> $hasManyArticles = $this->getMockBuilder('Cake\ORM\Association\HasMany') <add> ->setMethods(['target']) <add> ->setConstructorArgs([ <ide> 'articles', <ide> [ <ide> 'target' => $articles, <ide> 'foreignKey' => 'author_id', <ide> 'dependent' => true, <ide> 'cascadeCallbacks' => true <ide> ] <del> ] <del> ); <add> ]) <add> ->getMock(); <ide> $hasManyArticles->method('target')->willReturn($articles); <ide> <ide> $associations->add('articles', $hasManyArticles); <ide> function (Event $event, Entity $entity, ArrayObject $options) use (&$actualOptio <ide> */ <ide> public function testSimplifiedFind() <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['callFinder'], <del> [[ <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['callFinder']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'schema' => ['id' => ['type' => 'integer']] <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <ide> $query = (new \Cake\ORM\Query($this->connection, $table))->select(); <ide> $table->expects($this->once())->method('callFinder') <ide> public function providerForTestGet() <ide> */ <ide> public function testGet($options) <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['callFinder', 'query'], <del> [[ <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['callFinder', 'query']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'schema' => [ <ide> 'id' => ['type' => 'integer'], <ide> 'bar' => ['type' => 'integer'], <ide> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]] <ide> ] <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['addDefaultTypes', 'firstOrFail', 'where', 'cache'], <del> [$this->connection, $table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache']) <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> <ide> $entity = new \Cake\ORM\Entity; <ide> $table->expects($this->once())->method('query') <ide> public function providerForTestGetWithCustomFinder() <ide> */ <ide> public function testGetWithCustomFinder($options) <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['callFinder', 'query'], <del> [[ <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['callFinder', 'query']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'schema' => [ <ide> 'id' => ['type' => 'integer'], <ide> 'bar' => ['type' => 'integer'], <ide> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]] <ide> ] <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['addDefaultTypes', 'firstOrFail', 'where', 'cache'], <del> [$this->connection, $table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache']) <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> <ide> $entity = new \Cake\ORM\Entity; <ide> $table->expects($this->once())->method('query') <ide> public function providerForTestGetWithCache() <ide> */ <ide> public function testGetWithCache($options, $cacheKey, $cacheConfig) <ide> { <del> $table = $this->getMock( <del> '\Cake\ORM\Table', <del> ['callFinder', 'query'], <del> [[ <add> $table = $this->getMockBuilder('\Cake\ORM\Table') <add> ->setMethods(['callFinder', 'query']) <add> ->setConstructorArgs([[ <ide> 'connection' => $this->connection, <ide> 'schema' => [ <ide> 'id' => ['type' => 'integer'], <ide> 'bar' => ['type' => 'integer'], <ide> '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['bar']]] <ide> ] <del> ]] <del> ); <add> ]]) <add> ->getMock(); <ide> $table->table('table_name'); <ide> <del> $query = $this->getMock( <del> '\Cake\ORM\Query', <del> ['addDefaultTypes', 'firstOrFail', 'where', 'cache'], <del> [$this->connection, $table] <del> ); <add> $query = $this->getMockBuilder('\Cake\ORM\Query') <add> ->setMethods(['addDefaultTypes', 'firstOrFail', 'where', 'cache']) <add> ->setConstructorArgs([$this->connection, $table]) <add> ->getMock(); <ide> <ide> $entity = new \Cake\ORM\Entity; <ide> $table->expects($this->once())->method('query') <ide> public function testGetExceptionOnTooMuchData() <ide> */ <ide> public function testPatchEntity() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['marshaller']); <del> $marshaller = $this->getMock('Cake\ORM\Marshaller', [], [$table]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['marshaller']) <add> ->getMock(); <add> $marshaller = $this->getMockBuilder('Cake\ORM\Marshaller') <add> ->setConstructorArgs([$table]) <add> ->getMock(); <ide> $table->belongsTo('users'); <ide> $table->hasMany('articles'); <ide> $table->expects($this->once())->method('marshaller') <ide> public function testPatchEntity() <ide> */ <ide> public function testPatchEntities() <ide> { <del> $table = $this->getMock('Cake\ORM\Table', ['marshaller']); <del> $marshaller = $this->getMock('Cake\ORM\Marshaller', [], [$table]); <add> $table = $this->getMockBuilder('Cake\ORM\Table') <add> ->setMethods(['marshaller']) <add> ->getMock(); <add> $marshaller = $this->getMockBuilder('Cake\ORM\Marshaller') <add> ->setConstructorArgs([$table]) <add> ->getMock(); <ide> $table->belongsTo('users'); <ide> $table->hasMany('articles'); <ide> $table->expects($this->once())->method('marshaller')
13
Java
Java
expose method to set custom baseline function
9c2caaac3e0a0f932ff67e4e80f90b6c5626b56f
<ide><path>ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java <ide> import com.facebook.yoga.YogaDirection; <ide> import com.facebook.yoga.YogaFlexDirection; <ide> import com.facebook.yoga.YogaJustify; <add>import com.facebook.yoga.YogaBaselineFunction; <ide> import com.facebook.yoga.YogaMeasureFunction; <ide> import com.facebook.yoga.YogaNode; <ide> import com.facebook.yoga.YogaOverflow; <ide> public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) { <ide> mShouldNotifyOnLayout = shouldNotifyOnLayout; <ide> } <ide> <add> public void setBaselineFunction(YogaBaselineFunction baselineFunction) { <add> mYogaNode.setBaselineFunction(baselineFunction); <add> } <add> <ide> public void setMeasureFunction(YogaMeasureFunction measureFunction) { <ide> if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) && <ide> getChildCount() != 0) {
1
PHP
PHP
keep layout in line with other new pages
387156f2fb9b6e1ea983c1c94747a6f0f49fe1c5
<ide><path>resources/views/home.blade.php <ide> @extends('layouts.app') <ide> <ide> @section('content') <del><div class="row"> <del> <div class="col-sm-10 col-sm-offset-1"> <del> <div class="panel panel-default"> <del> <div class="panel-heading">Dashboard</div> <del> <div class="panel-body"> <del> <del> Application dashboard. <del> <add><div class="container"> <add> <div class="row"> <add> <div class="col-sm-8 col-sm-offset-2"> <add> <div class="panel panel-default"> <add> <div class="panel-heading">Dashboard</div> <add> <div class="panel-body"> <add> <add> Application dashboard. <add> <add> </div> <ide> </div> <ide> </div> <ide> </div>
1
Go
Go
move functions to be in line with "secret" tests
25424cf7722ca6da3b4c7f667ec83a6d0e63fd1b
<ide><path>integration/config/config_test.go <ide> import ( <ide> "gotest.tools/v3/skip" <ide> ) <ide> <add>func TestConfigInspect(t *testing.T) { <add> skip.If(t, testEnv.DaemonInfo.OSType == "windows") <add> <add> defer setupTest(t)() <add> d := swarm.NewSwarm(t, testEnv) <add> defer d.Stop(t) <add> c := d.NewClientT(t) <add> defer c.Close() <add> <add> ctx := context.Background() <add> <add> testName := t.Name() <add> configID := createConfig(ctx, t, c, testName, []byte("TESTINGDATA"), nil) <add> <add> insp, body, err := c.ConfigInspectWithRaw(ctx, configID) <add> assert.NilError(t, err) <add> assert.Check(t, is.Equal(insp.Spec.Name, testName)) <add> <add> var config swarmtypes.Config <add> err = json.Unmarshal(body, &config) <add> assert.NilError(t, err) <add> assert.Check(t, is.DeepEqual(config, insp)) <add>} <add> <ide> func TestConfigList(t *testing.T) { <ide> skip.If(t, testEnv.DaemonInfo.OSType == "windows") <ide> <ide> func assertAttachedStream(t *testing.T, attach types.HijackedResponse, expect st <ide> assert.Check(t, is.Contains(buf.String(), expect)) <ide> } <ide> <del>func TestConfigInspect(t *testing.T) { <del> skip.If(t, testEnv.DaemonInfo.OSType == "windows") <del> <del> defer setupTest(t)() <del> d := swarm.NewSwarm(t, testEnv) <del> defer d.Stop(t) <del> c := d.NewClientT(t) <del> defer c.Close() <del> <del> ctx := context.Background() <del> <del> testName := t.Name() <del> configID := createConfig(ctx, t, c, testName, []byte("TESTINGDATA"), nil) <del> <del> insp, body, err := c.ConfigInspectWithRaw(ctx, configID) <del> assert.NilError(t, err) <del> assert.Check(t, is.Equal(insp.Spec.Name, testName)) <del> <del> var config swarmtypes.Config <del> err = json.Unmarshal(body, &config) <del> assert.NilError(t, err) <del> assert.Check(t, is.DeepEqual(config, insp)) <del>} <del> <ide> func TestConfigCreateWithLabels(t *testing.T) { <ide> skip.If(t, testEnv.DaemonInfo.OSType != "linux") <ide>
1
Python
Python
extend unicode character block for sinhala
a3509f67d48d8ba9f7eb83201ef38de4165cd50f
<ide><path>spacy/lang/char_classes.py <ide> _russian_upper = r"ЁА-Я" <ide> _russian = r"ёа-яЁА-Я" <ide> <del>_sinhala = r"\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6" <add>_sinhala = r"\u0D80-\u0DFF" <ide> <ide> _tatar_lower = r"әөүҗңһ" <ide> _tatar_upper = r"ӘӨҮҖҢҺ" <ide><path>spacy/tests/pipeline/test_sentencizer.py <ide> from __future__ import unicode_literals <ide> <ide> import pytest <add>import spacy <ide> from spacy.pipeline import Sentencizer <ide> from spacy.tokens import Doc <ide> <ide> def test_sentencizer_serialize_bytes(en_vocab): <ide> bytes_data = sentencizer.to_bytes() <ide> new_sentencizer = Sentencizer().from_bytes(bytes_data) <ide> assert new_sentencizer.punct_chars == set(punct_chars) <add> <add> <add>@pytest.mark.parametrize( <add> # fmt: off <add> "lang,text", <add> [ <add> ('bn', 'বাংলা ভাষা (বাঙলা, বাঙ্গলা, তথা বাঙ্গালা নামগুলোতেও পরিচিত) একটি ইন্দো-আর্য ভাষা, যা দক্ষিণ এশিয়ার বাঙালি জাতির প্রধান কথ্য ও লেখ্য ভাষা। মাতৃভাষীর সংখ্যায় বাংলা ইন্দো-ইউরোপীয় ভাষা পরিবারের চতুর্থ ও বিশ্বের ষষ্ঠ বৃহত্তম ভাষা।[৫] মোট ব্যবহারকারীর সংখ্যা অনুসারে বাংলা বিশ্বের সপ্তম বৃহত্তম ভাষা। বাংলা সার্বভৌম ভাষাভিত্তিক জাতিরাষ্ট্র বাংলাদেশের একমাত্র রাষ্ট্রভাষা তথা সরকারি ভাষা[৬] এবং ভারতের পশ্চিমবঙ্গ, ত্রিপুরা, আসামের বরাক উপত্যকার সরকারি ভাষা। বঙ্গোপসাগরে অবস্থিত আন্দামান দ্বীপপুঞ্জের প্রধান কথ্য ভাষা বাংলা। এছাড়া ভারতের ঝাড়খণ্ড, বিহার, মেঘালয়, মিজোরাম, উড়িষ্যা রাজ্যগুলোতে উল্লেখযোগ্য পরিমাণে বাংলাভাষী জনগণ রয়েছে। ভারতে হিন্দির পরেই সর্বাধিক প্রচলিত ভাষা বাংলা।[৭][৮] এছাড়াও মধ্য প্রাচ্য, আমেরিকা ও ইউরোপে উল্লেখযোগ্য পরিমাণে বাংলাভাষী অভিবাসী রয়েছে।[৯] সারা বিশ্বে সব মিলিয়ে ২৬ কোটির অধিক লোক দৈনন্দিন জীবনে বাংলা ব্যবহার করে।[২] বাংলাদেশের জাতীয় সঙ্গীত এবং ভারতের জাতীয় সঙ্গীত ও স্তোত্র বাংলাতে রচিত।'), <add> ('de', 'Die deutsche Sprache bzw. Deutsch ([dɔʏ̯t͡ʃ]; abgekürzt dt. oder dtsch.) ist eine westgermanische Sprache. Ihr Sprachraum umfasst Deutschland, Österreich, die Deutschschweiz, Liechtenstein, Luxemburg, Ostbelgien, Südtirol, das Elsass und Lothringen sowie Nordschleswig. Außerdem ist sie eine Minderheitensprache in einigen europäischen und außereuropäischen Ländern, z. B. in Rumänien und Südafrika, sowie Nationalsprache im afrikanischen Namibia.'), <add> ('hi', 'हिन्दी विश्व की एक प्रमुख भाषा है एवं भारत की राजभाषा है। केन्द्रीय स्तर पर भारत में दूसरी आधिकारिक भाषा अंग्रेजी है। यह हिंदुस्तानी भाषा की एक मानकीकृत रूप है जिसमें संस्कृत के तत्सम तथा तद्भव शब्दों का प्रयोग अधिक है और अरबी-फ़ारसी शब्द कम हैं। हिंदी संवैधानिक रूप से भारत की राजभाषा और भारत की सबसे अधिक बोली और समझी जाने वाली भाषा है। हालाँकि, हिन्दी भारत की राष्ट्रभाषा नहीं है,[3] क्योंकि भारत के संविधान में कोई भी भाषा को ऐसा दर्जा नहीं दिया गया था।[4][5] चीनी के बाद यह विश्व में सबसे अधिक बोली जाने वाली भाषा भी है। विश्व आर्थिक मंच की गणना के अनुसार यह विश्व की दस शक्तिशाली भाषाओं में से एक है।[6]'), <add> ('kn', 'ದ್ರಾವಿಡ ಭಾಷೆಗಳಲ್ಲಿ ಪ್ರಾಮುಖ್ಯವುಳ್ಳ ಭಾಷೆಯೂ ಭಾರತದ ಪುರಾತನವಾದ ಭಾಷೆಗಳಲ್ಲಿ ಒಂದೂ ಆಗಿರುವ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಅದರ ವಿವಿಧ ರೂಪಗಳಲ್ಲಿ ಸುಮಾರು ೪೫ ದಶಲಕ್ಷ ಜನರು ಆಡು ನುಡಿಯಾಗಿ ಬಳಸುತ್ತಲಿದ್ದಾರೆ. ಕನ್ನಡ ಕರ್ನಾಟಕ ರಾಜ್ಯದ ಆಡಳಿತ ಭಾಷೆ.[೧೧] ಜಗತ್ತಿನಲ್ಲಿ ಅತ್ಯಂತ ಹೆಚ್ಚು ಮಂದಿ ಮಾತನಾಡುವ ಭಾಷೆಯೆಂಬ ನೆಲೆಯಲ್ಲಿ ಇಪ್ಪತೊಂಬತ್ತನೆಯ ಸ್ಥಾನ ಕನ್ನಡಕ್ಕಿದೆ. ೨೦೧೧ರ ಜನಗಣತಿಯ ಪ್ರಕಾರ ಜಗತ್ತಿನಲ್ಲಿ ೬.೪ ಕೋಟಿ ಜನಗಳು ಕನ್ನಡ ಮಾತನಾಡುತ್ತಾರೆ ಎಂದು ತಿಳಿದುಬಂದಿದೆ. ಇವರಲ್ಲಿ ೫.೫ ಕೋಟಿ ಜನಗಳ ಮಾತೃಭಾಷೆ ಕನ್ನಡವಾಗಿದೆ. ಬ್ರಾಹ್ಮಿ ಲಿಪಿಯಿಂದ ರೂಪುಗೊಂಡ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಉಪಯೋಗಿಸಿ ಕನ್ನಡ ಭಾಷೆಯನ್ನು ಬರೆಯಲಾಗುತ್ತದೆ. ಕನ್ನಡ ಬರಹದ ಮಾದರಿಗಳಿಗೆ ಸಾವಿರದ ಐನೂರು ವರುಷಗಳ ಚರಿತ್ರೆಯಿದೆ. ಕ್ರಿ.ಶ. ಆರನೆಯ ಶತಮಾನದ ಪಶ್ಚಿಮ ಗಂಗ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ [೧೨] ಮತ್ತು ಒಂಬತ್ತನೆಯ ಶತಮಾನದ ರಾಷ್ಟ್ರಕೂಟ ಸಾಮ್ರಾಜ್ಯದ ಕಾಲದಲ್ಲಿ ಹಳಗನ್ನಡ ಸಾಹಿತ್ಯ ಅತ್ಯಂತ ಹೆಚ್ಚಿನ ರಾಜಾಶ್ರಯ ಪಡೆಯಿತು.[೧೩][೧೪] ಅದಲ್ಲದೆ ಸಾವಿರ ವರುಷಗಳ ಸಾಹಿತ್ಯ ಪರಂಪರೆ ಕನ್ನಡಕ್ಕಿದೆ.[೧೫]ವಿನೋಬಾ ಭಾವೆ ಕನ್ನಡ ಲಿಪಿಯನ್ನು ಲಿಪಿಗಳ ರಾಣಿಯೆಂದು ಹೊಗಳಿದ್ದಾರೆ.[ಸೂಕ್ತ ಉಲ್ಲೇಖನ ಬೇಕು]'), <add> ('si', 'ශ්‍රී ලංකාවේ ප්‍රධාන ජාතිය වන සිංහල ජනයාගේ මව් බස සිංහල වෙයි. අද වන විට මිලියන 20 කට අධික සිංහල සහ මිලියන 3කට අධික සිංහල නොවන ජනගහනයක් සිංහල භාෂාව භාවිත කරති. සිංහල‍ ඉන්දු-යුරෝපීය භාෂාවල උප ගණයක් වන ඉන්දු-ආර්ය භාෂා ගණයට අයිති වන අතර මාල දිවයින භාවිත කරන දිවෙහි භාෂාව සිංහලයෙන් පැවත එන්නකි. සිංහල ශ්‍රී ලංකාවේ නිල භාෂාවයි .'), <add> ('ta', 'தமிழ் மொழி (Tamil language) தமிழர்களினதும், தமிழ் பேசும் பலரதும் தாய்மொழி ஆகும். தமிழ் திராவிட மொழிக் குடும்பத்தின் முதன்மையான மொழிகளில் ஒன்றும் செம்மொழியும் ஆகும். இந்தியா, இலங்கை, மலேசியா, சிங்கப்பூர் ஆகிய நாடுகளில் அதிக அளவிலும், ஐக்கிய அரபு அமீரகம், தென்னாப்பிரிக்கா, மொரிசியசு, பிஜி, ரீயூனியன், டிரினிடாட் போன்ற நாடுகளில் சிறிய அளவிலும் தமிழ் பேசப்படுகிறது. 1997ஆம் ஆண்டுப் புள்ளி விவரப்படி உலகம் முழுவதிலும் 8 கோடி (80 மில்லியன்) மக்களால் பேசப்படும் தமிழ்[13], ஒரு மொழியைத் தாய்மொழியாகக் கொண்டு பேசும் மக்களின் எண்ணிக்கை அடிப்படையில் பதினெட்டாவது இடத்தில் உள்ளது.[14] இணையத்தில் அதிகம் பயன்படுத்தப்படும் இந்திய மொழிகளில் தமிழ் முதன்மையாக உள்ளதாக 2017 ஆவது ஆண்டில் நடைபெற்ற கூகுள் கணக்கெடுப்பில் தெரிய வந்தது.[15]'), <add> ('te', 'ఆంధ్ర ప్రదేశ్, తెలంగాణ రాష్ట్రాల అధికార భాష తెలుగు. భారత దేశంలో తెలుగు మాతృభాషగా మాట్లాడే 8.7 కోట్ల (2001) జనాభాతో [1] ప్రాంతీయ భాషలలో మొదటి స్థానంలో ఉంది. ప్రపంచంలోని ప్రజలు అత్యధికముగా మాట్లాడే భాషలలో 15 స్థానములోనూ, భారత దేశములో హిందీ, తర్వాత స్థానములోనూ నిలుస్తుంది. పాతవైన ప్రపంచ భాష గణాంకాల (ఎథ్నోలాగ్) ప్రకారం ప్రపంచవ్యాప్తంగా 7.4 కోట్లు మందికి మాతృభాషగా ఉంది.[2] మొదటి భాషగా మాట్లాడతారు. అతి ప్రాచీన దేశ భాషలలో సంస్కృతము తమిళముతో బాటు తెలుగు భాషను 2008 అక్టోబరు 31న భారత ప్రభుత్వము గుర్తించింది.'), <add> ('ur', 'اُردُو لشکری زبان[8] (یا جدید معیاری اردو) برصغیر کی معیاری زبانوں میں سے ایک ہے۔ یہ پاکستان کی قومی اور رابطہ عامہ کی زبان ہے، جبکہ بھارت کی چھے ریاستوں کی دفتری زبان کا درجہ رکھتی ہے۔ آئین ہند کے مطابق اسے 22 دفتری شناخت زبانوں میں شامل کیا جاچکا ہے۔ 2001ء کی مردم شماری کے مطابق اردو کو بطور مادری زبان بھارت میں 5.01% فیصد لوگ بولتے ہیں اور اس لحاظ سے یہ بھارت کی چھٹی بڑی زبان ہے جبکہ پاکستان میں اسے بطور مادری زبان 7.59% فیصد لوگ استعمال کرتے ہیں، یہ پاکستان کی پانچویں بڑی زبان ہے۔ اردو تاریخی طور پر ہندوستان کی مسلم آبادی سے جڑی ہے۔[حوالہ درکار] بعض ذخیرہ الفاظ کے علاوہ یہ زبان معیاری ہندی سے قابل فہم ہے جو اس خطے کی ہندوؤں سے منسوب ہے۔[حوالہ درکار] زبانِ اردو کو پہچان و ترقی اس وقت ملی جب برطانوی دور میں انگریز حکمرانوں نے اسے فارسی کی بجائے انگریزی کے ساتھ شمالی ہندوستان کے علاقوں اور جموں و کشمیر میں اسے سنہ 1846ء اور پنجاب میں سنہ 1849ء میں بطور دفتری زبان نافذ کیا۔ اس کے علاوہ خلیجی، یورپی، ایشیائی اور امریکی علاقوں میں اردو بولنے والوں کی ایک بڑی تعداد آباد ہے جو بنیادی طور پر جنوبی ایشیاء سے کوچ کرنے والے اہلِ اردو ہیں۔ 1999ء کے اعداد وشمار کے مطابق اردو زبان کے مجموعی متکلمین کی تعداد دس کروڑ ساٹھ لاکھ کے لگ بھگ تھی۔ اس لحاظ سے یہ دنیا کی نویں بڑی زبان ہے۔'), <add> ], <add> # fmt: on <add>) <add>def test_sentencizer_across_scripts(lang, text): <add> nlp = spacy.blank(lang) <add> sentencizer = Sentencizer() <add> nlp.add_pipe(sentencizer) <add> doc = nlp(text) <add> assert len(list(doc.sents)) > 1
2
Text
Text
add getir to in the wild!
dee304b222d355b03794aa063f39e3ee13997730
<ide><path>INTHEWILD.md <ide> Currently, **officially** using Airflow: <ide> 1. [GeneCards](https://www.genecards.org) [[@oferze](https://github.com/oferze)] <ide> 1. [Gentner Lab](http://github.com/gentnerlab) [[@neuromusic](https://github.com/neuromusic)] <ide> 1. [Get Simpl](https://getsimpl.com/) [[@rootcss](https://github.com/rootcss)] <add>1. [Getir](https://www.getir.com/) [[@mpolatcan](https://github.com/mpolatcan)] <ide> 1. [GitLab](https://about.gitlab.com/) [[@tayloramurphy](https://gitlab.com/tayloramurphy) & [@m_walker](https://gitlab.com/m_walker)] <ide> 1. [Glassdoor](https://github.com/Glassdoor) [[@syvineckruyk](https://github.com/syvineckruyk) & [@sid88in](https://github.com/sid88in)] <ide> 1. [Global Fashion Group](http://global-fashion-group.com) [[@GFG](https://github.com/GFG)]
1
Text
Text
update some words to commons spanish words
2a61d4327cd618f4a2d8870e7361c9875b03ab2f
<ide><path>curriculum/challenges/spanish/01-responsive-web-design/basic-html-and-html5/turn-an-image-into-a-link.spanish.md <ide> localeTitle: Convertir una imagen en un enlace <ide> --- <ide> <ide> ## Description <del><section id="description"> Puede hacer que los elementos en los enlaces por los nidos de ellos dentro de un <code>a</code> elemento. Nido de su imagen dentro de un <code>a</code> elemento. Aquí hay un ejemplo: <code>&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;https://bit.ly/fcc-running-cats&quot; alt=&quot;Three kittens running towards the camera.&quot;&gt;&lt;/a&gt;</code> Recuerda usar <code>#</code> como propiedad <code>href</code> <code>a</code> elemento para convertirlo en un enlace muerto. </section> <add><section id="description"> Puede convertir los elementos en enlaces anidandolos dentro de un elemento <code>a</code>. Anide su imagen dentro de un elemento <code>a</code>. Aquí hay un ejemplo: <code>&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;https://bit.ly/fcc-running-cats&quot; alt=&quot;Three kittens running towards the camera.&quot;&gt;&lt;/a&gt;</code> Recuerda usar <code>#</code> en la propiedad <code>href</code> de tu elemento <code>a</code> para convertirlo en un enlace muerto. </section> <ide> <ide> ## Instructions <del><section id="instructions"> Coloque el elemento de imagen existente dentro de un elemento de anclaje. Una vez que hayas hecho esto, desplázate sobre tu imagen con el cursor. El puntero normal de su cursor debe convertirse en el enlace que hace clic en el puntero. La foto es ahora un enlace. </section> <add><section id="instructions"> Coloque el elemento de imagen existente dentro de un elemento de anclaje. Una vez que hayas hecho esto, desplázate sobre tu imagen con el cursor. El puntero normal de su cursor debe convertirse en el puntero para hacer clic en el enlace. La foto es ahora un enlace. </section> <ide> <ide> ## Tests <ide> <section id='tests'>
1
Javascript
Javascript
fix skeleton.pose() bug
d2933332783b3b0d113f048dfb8dd7cc5999320b
<ide><path>src/objects/Skeleton.js <ide> Object.assign( THREE.Skeleton.prototype, { <ide> <ide> if ( bone ) { <ide> <del> if ( bone.parent ) { <add> if ( bone.parent instanceof THREE.Bone ) { <ide> <ide> bone.matrix.getInverse( bone.parent.matrixWorld ); <ide> bone.matrix.multiply( bone.matrixWorld );
1
Text
Text
update title to reference packages too
133bf0cedb9e5ed93ddd2039ebedc9826c9ce251
<ide><path>docs/upgrading/upgrading-your-ui-theme.md <del># Upgrading your UI Theme <add># Upgrading your UI Theme or Package Stylesheets <ide> <del>In addition to changes in Atom's scripting API, we'll also be making some breaking changes to Atom's DOM structure, requiring style sheets in both packages and themes to be updated. Deprecation cop will list usages of deprecated selector patterns to guide you. <add>In addition to changes in Atom's scripting API, we'll also be making some breaking changes to Atom's DOM structure, requiring stylesheets in both packages and themes to be updated. Deprecation cop will list usages of deprecated selector patterns to guide you. <ide> <ide> ## Custom Tags <ide>
1
Javascript
Javascript
fix another outlet assertion
793613059d3e029e17b38a89c67d592b4f535164
<ide><path>packages/ember-htmlbars/lib/keywords/real_outlet.js <ide> import merge from "ember-metal/merge"; <ide> import { get } from "ember-metal/property_get"; <ide> import ComponentNode from "ember-htmlbars/system/component-node"; <add>import { isStream } from "ember-metal/streams/utils"; <ide> import topLevelViewTemplate from "ember-htmlbars/templates/top-level-view"; <ide> topLevelViewTemplate.revision = 'Ember@VERSION_STRING_PLACEHOLDER'; <ide> <ide> export default { <ide> var outletState = env.outletState; <ide> var read = env.hooks.getValue; <ide> <add> Ember.assert( <add> "Using {{outlet}} with an unquoted name is not supported.", <add> !params[0] || !isStream(params[0]) <add> ); <add> <ide> var outletName = read(params[0]) || 'main'; <ide> var selectedOutletState = outletState[outletName]; <ide> <ide><path>packages/ember-routing-htmlbars/tests/helpers/outlet_test.js <ide> QUnit.test("should not throw deprecations if {{outlet}} is used with a quoted na <ide> runAppend(top); <ide> }); <ide> <del>QUnit.skip("should throw an assertion if {{outlet}} used with unquoted name", function() { <add>QUnit.test("should throw an assertion if {{outlet}} used with unquoted name", function() { <ide> top.setOutletState(withTemplate("{{outlet foo}}")); <ide> expectAssertion(function() { <ide> runAppend(top);
2
Python
Python
fix dummy doctest to work with pypy
503bbe3359668f7e3e8b3311f255e345623c1247
<ide><path>libcloud/storage/drivers/dummy.py <ide> def download_object_as_stream(self, obj, chunk_size=None): <ide> ... iterator=DummyFileObject(5, 10), extra={}) <ide> >>> stream = container.download_object_as_stream(obj) <ide> >>> stream #doctest: +ELLIPSIS <del> <closed file '<uninitialized file>', mode '<uninitialized file>' at 0x...> <add> <closed file ..., mode '<uninitialized file>' at 0x...> <ide> """ <ide> <ide> return DummyFileObject()
1
Ruby
Ruby
fix error with absolute alias paths
0a7063ac511df5f325b63588ef3524ca2b70d4fe
<ide><path>Library/Homebrew/formulary.rb <ide> def self.loader_for(ref, from: nil) <ide> return TapLoader.new(ref, from: from) <ide> end <ide> <del> return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && Pathname.new(ref).expand_path.exist? <add> pathname_ref = Pathname.new(ref) <add> return FromPathLoader.new(ref) if File.extname(ref) == ".rb" && pathname_ref.expand_path.exist? <ide> <ide> if Homebrew::EnvConfig.install_from_api? <ide> return FormulaAPILoader.new(ref) if Homebrew::API::Formula.all_formulae.key?(ref) <ide> def self.loader_for(ref, from: nil) <ide> formula_with_that_name = core_path(ref) <ide> return FormulaLoader.new(ref, formula_with_that_name) if formula_with_that_name.file? <ide> <del> possible_alias = core_alias_path(ref) <del> return AliasLoader.new(possible_alias) if possible_alias.file? <add> possible_alias = if pathname_ref.absolute? <add> pathname_ref <add> else <add> core_alias_path(ref) <add> end <add> return AliasLoader.new(possible_alias) if possible_alias.symlink? <ide> <ide> possible_tap_formulae = tap_paths(ref) <ide> raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae) if possible_tap_formulae.size > 1
1
PHP
PHP
relax email validation rules even more
dc34d80f6f622e883b8c7db9ef489bd514c8701f
<ide><path>lib/Cake/Network/Email/CakeEmail.php <ide> class CakeEmail { <ide> <ide> /** <ide> * Regex for email validation <del> * If null, filter_var() will be used. <add> * <add> * If null, filter_var() will be used. Use the emailPattern() method <add> * to set a custom pattern.' <ide> * <ide> * @var string <ide> */ <del> protected $_emailPattern = null; <add> protected $_emailPattern = '/^((?:[\p{L}0-9!#$%&\'*+\/=?^_`{|}~-]+)*@[\p{L}0-9-.]+)$/ui'; <ide> <ide> /** <ide> * The class name used for email configuration. <ide> public function headerCharset($charset = null) { <ide> * @param string $regex for email address validation <ide> * @return string|$this <ide> */ <del> public function emailPattern($regex = null) { <del> if ($regex === null) { <add> public function emailPattern($regex = false) { <add> if ($regex === false) { <ide> return $this->_emailPattern; <ide> } <ide> $this->_emailPattern = $regex; <ide> protected function _setEmail($varName, $email, $name) { <ide> * @throws SocketException If email address does not validate <ide> */ <ide> protected function _validateEmail($email) { <del> $valid = (($this->_emailPattern !== null && <del> preg_match($this->_emailPattern, $email)) || <del> filter_var($email, FILTER_VALIDATE_EMAIL) <del> ); <del> if (!$valid) { <del> throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); <add> if ($this->_emailPattern === null && filter_var($email, FILTER_VALIDATE_EMAIL)) { <add> return; <add> } elseif (preg_match($this->_emailPattern, $email)) { <add> return; <ide> } <add> throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email)); <ide> } <ide> <ide> /** <ide><path>lib/Cake/Test/Case/Network/Email/CakeEmailTest.php <ide> public function testTo() { <ide> $this->assertSame($this->CakeEmail->to(), $expected); <ide> <ide> $list = array( <add> 'root@localhost' => 'root', <add> 'bjørn@hammeröath.com' => 'Bjorn', <ide> 'cake@cakephp.org' => 'Cake PHP', <ide> 'cake-php@googlegroups.com' => 'Cake Groups', <ide> 'root@cakephp.org' <ide> ); <ide> $this->CakeEmail->to($list); <ide> $expected = array( <add> 'root@localhost' => 'root', <add> 'bjørn@hammeröath.com' => 'Bjorn', <ide> 'cake@cakephp.org' => 'Cake PHP', <ide> 'cake-php@googlegroups.com' => 'Cake Groups', <ide> 'root@cakephp.org' => 'root@cakephp.org' <ide> public function testTo() { <ide> $this->CakeEmail->addTo('mark_story@cakephp.org', 'Mark Story'); <ide> $result = $this->CakeEmail->addTo(array('phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org')); <ide> $expected = array( <add> 'root@localhost' => 'root', <add> 'bjørn@hammeröath.com' => 'Bjorn', <ide> 'cake@cakephp.org' => 'Cake PHP', <ide> 'cake-php@googlegroups.com' => 'Cake Groups', <ide> 'root@cakephp.org' => 'root@cakephp.org', <ide> public function testTo() { <ide> ); <ide> $this->assertSame($this->CakeEmail->to(), $expected); <ide> $this->assertSame($this->CakeEmail, $result); <del> <del> $this->setExpectedException('SocketException'); <del> $this->CakeEmail->to(array('cake@localhost', 'CakePHP')); <ide> } <ide> <add> <ide> /** <ide> * Data provider function for testBuildInvalidData <ide> * <ide> public static function invalidEmails() { <ide> array(''), <ide> array('string'), <ide> array('<tag>'), <del> array('some@one-whereis'), <del> array('wrong@key' => 'Name'), <ide> array(array('ok@cakephp.org', 1.0, '', 'string')) <ide> ); <ide> }
2
Text
Text
fix reference to googletest test fixture
5947862801a98b885ead6b8d24e29a383345b726
<ide><path>doc/guides/writing-tests.md <ide> Nightly coverage reports for the Node.js master branch are available at <ide> [all maintained branches]: https://github.com/nodejs/lts <ide> [directory structure overview]: https://github.com/nodejs/node/blob/master/test/README.md#test-directories <ide> [node.green]: https://node.green/ <del>[test fixture]: https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests <add>[test fixture]: https://github.com/google/googletest/blob/master/googletest/docs/primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests-same-data-multiple-tests
1
Ruby
Ruby
extend ssl checks
51956d343a5b38a683db9afe51e39dabbd715ac0
<ide><path>Library/Homebrew/cmd/audit.rb <ide> def audit_urls <ide> problem "Savannah homepages should be https:// links (URL is #{homepage})." <ide> end <ide> <add> if homepage =~ %r[^http://((?:trac|tools|www)\.)?ietf\.org] <add> problem "ietf homepages should be https:// links (URL is #{homepage})." <add> end <add> <add> if homepage =~ %r[^http://((?:www)\.)?gnupg.org/] <add> problem "GnuPG homepages should be https:// links (URL is #{homepage})." <add> end <add> <add> # Freedesktop is complicated to handle - It has SSL/TLS, but only on certain subdomains. <add> # To enable https Freedesktop change the url from http://project.freedesktop.org/wiki to <add> # https://wiki.freedesktop.org/project_name. <add> # "Software" is redirected to https://wiki.freedesktop.org/www/Software/project_name <add> if homepage =~ %r[^http://((?:www|nice|libopenraw|liboil|telepathy|xorg)\.)?freedesktop\.org/(?:wiki/)?] <add> if homepage =~ /Software/ <add> problem "The url should be styled `https://wiki.freedesktop.org/www/Software/project_name`, not #{homepage})." <add> else <add> problem "The url should be styled `https://wiki.freedesktop.org/project_name`, not #{homepage})." <add> end <add> end <add> <add> if homepage =~ %r[^http://wiki\.freedesktop\.org/] <add> problem "Freedesktop's Wiki subdomain should be https:// (URL is #{homepage})." <add> end <add> <ide> # There's an auto-redirect here, but this mistake is incredibly common too. <ide> if homepage =~ %r[^http://packages\.debian\.org] <ide> problem "Debian homepage should be https:// links (URL is #{homepage})." <ide> end <ide> <del> if homepage =~ %r[^http://((?:trac|tools|www)\.)?ietf\.org] <del> problem "ietf homepages should be https:// links (URL is #{homepage})." <add> # People will run into mixed content sometimes, but we should enforce and then add <add> # exemptions as they are discovered. Treat mixed content on homepages as a bug. <add> # Justify each exemptions with a code comment so we can keep track here. <add> if homepage =~ %r[^http://[^/]*github\.io/] <add> problem "Github Pages links should be https:// (URL is #{homepage})." <ide> end <ide> <ide> # There's an auto-redirect here, but this mistake is incredibly common too. <ide> def audit_urls <ide> end <ide> <ide> def audit_specs <del> if head_only?(formula) && formula.tap != "homebrew/homebrew-head-only" <add> if head_only?(formula) && formula.tap != "Homebrew/homebrew-head-only" <ide> problem "Head-only (no stable download)" <ide> end <ide> <del> if devel_only?(formula) && formula.tap != "homebrew/homebrew-devel-only" <add> if devel_only?(formula) && formula.tap != "Homebrew/homebrew-devel-only" <ide> problem "Devel-only (no stable download)" <ide> end <ide>
1
Javascript
Javascript
use const in view_history.js
cf5af97b0240a95dfbd0a5e7e3425ce60ee7350c
<ide><path>web/view_history.js <ide> * See the License for the specific language governing permissions and <ide> * limitations under the License. <ide> */ <add>/* eslint no-var: error, prefer-const: error */ <ide> <ide> const DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20; <ide> <ide> class ViewHistory { <ide> this.cacheSize = cacheSize; <ide> <ide> this._initializedPromise = this._readFromStorage().then((databaseStr) => { <del> let database = JSON.parse(databaseStr || '{}'); <add> const database = JSON.parse(databaseStr || '{}'); <ide> if (!('files' in database)) { <ide> database.files = []; <ide> } else { <ide> class ViewHistory { <ide> } <ide> let index = -1; <ide> for (let i = 0, length = database.files.length; i < length; i++) { <del> let branch = database.files[i]; <add> const branch = database.files[i]; <ide> if (branch.fingerprint === this.fingerprint) { <ide> index = i; <ide> break; <ide> class ViewHistory { <ide> } <ide> <ide> async _writeToStorage() { <del> let databaseStr = JSON.stringify(this.database); <add> const databaseStr = JSON.stringify(this.database); <ide> <ide> if (typeof PDFJSDev !== 'undefined' && <ide> PDFJSDev.test('FIREFOX || MOZCENTRAL')) { <ide> class ViewHistory { <ide> <ide> async setMultiple(properties) { <ide> await this._initializedPromise; <del> for (let name in properties) { <add> for (const name in properties) { <ide> this.file[name] = properties[name]; <ide> } <ide> return this._writeToStorage(); <ide> } <ide> <ide> async get(name, defaultValue) { <ide> await this._initializedPromise; <del> let val = this.file[name]; <add> const val = this.file[name]; <ide> return val !== undefined ? val : defaultValue; <ide> } <ide> <ide> async getMultiple(properties) { <ide> await this._initializedPromise; <del> let values = Object.create(null); <add> const values = Object.create(null); <ide> <del> for (let name in properties) { <del> let val = this.file[name]; <add> for (const name in properties) { <add> const val = this.file[name]; <ide> values[name] = val !== undefined ? val : properties[name]; <ide> } <ide> return values;
1
Python
Python
move tests under correct test class
e1aa7d92721fd09c1188a04f546711c69fbb45ed
<ide><path>tests/jobs/test_scheduler_job.py <ide> def test_mapped_dag(self, dag_id, session): <ide> dr.refresh_from_db(session) <ide> assert dr.state == DagRunState.SUCCESS <ide> <add> def test_should_mark_dummy_task_as_success(self): <add> dag_file = os.path.join( <add> os.path.dirname(os.path.realpath(__file__)), '../dags/test_only_dummy_tasks.py' <add> ) <add> <add> # Write DAGs to dag and serialized_dag table <add> dagbag = DagBag(dag_folder=dag_file, include_examples=False, read_dags_from_db=False) <add> dagbag.sync_to_db() <add> <add> self.scheduler_job = SchedulerJob(subdir=os.devnull) <add> self.scheduler_job.processor_agent = mock.MagicMock() <add> dag = self.scheduler_job.dagbag.get_dag("test_only_dummy_tasks") <add> <add> # Create DagRun <add> session = settings.Session() <add> orm_dag = session.query(DagModel).get(dag.dag_id) <add> self.scheduler_job._create_dag_runs([orm_dag], session) <add> <add> drs = DagRun.find(dag_id=dag.dag_id, session=session) <add> assert len(drs) == 1 <add> dr = drs[0] <add> <add> # Schedule TaskInstances <add> self.scheduler_job._schedule_dag_run(dr, session) <add> with create_session() as session: <add> tis = session.query(TaskInstance).all() <add> <add> dags = self.scheduler_job.dagbag.dags.values() <add> assert ['test_only_dummy_tasks'] == [dag.dag_id for dag in dags] <add> assert 5 == len(tis) <add> assert { <add> ('test_task_a', 'success'), <add> ('test_task_b', None), <add> ('test_task_c', 'success'), <add> ('test_task_on_execute', 'scheduled'), <add> ('test_task_on_success', 'scheduled'), <add> } == {(ti.task_id, ti.state) for ti in tis} <add> for state, start_date, end_date, duration in [ <add> (ti.state, ti.start_date, ti.end_date, ti.duration) for ti in tis <add> ]: <add> if state == 'success': <add> assert start_date is not None <add> assert end_date is not None <add> assert 0.0 == duration <add> else: <add> assert start_date is None <add> assert end_date is None <add> assert duration is None <add> <add> self.scheduler_job._schedule_dag_run(dr, session) <add> with create_session() as session: <add> tis = session.query(TaskInstance).all() <add> <add> assert 5 == len(tis) <add> assert { <add> ('test_task_a', 'success'), <add> ('test_task_b', 'success'), <add> ('test_task_c', 'success'), <add> ('test_task_on_execute', 'scheduled'), <add> ('test_task_on_success', 'scheduled'), <add> } == {(ti.task_id, ti.state) for ti in tis} <add> for state, start_date, end_date, duration in [ <add> (ti.state, ti.start_date, ti.end_date, ti.duration) for ti in tis <add> ]: <add> if state == 'success': <add> assert start_date is not None <add> assert end_date is not None <add> assert 0.0 == duration <add> else: <add> assert start_date is None <add> assert end_date is None <add> assert duration is None <add> <add> @pytest.mark.need_serialized_dag <add> def test_catchup_works_correctly(self, dag_maker): <add> """Test that catchup works correctly""" <add> session = settings.Session() <add> with dag_maker( <add> dag_id='test_catchup_schedule_dag', <add> schedule_interval=timedelta(days=1), <add> start_date=DEFAULT_DATE, <add> catchup=True, <add> max_active_runs=1, <add> session=session, <add> ) as dag: <add> DummyOperator(task_id='dummy') <add> <add> self.scheduler_job = SchedulerJob(subdir=os.devnull) <add> self.scheduler_job.executor = MockExecutor() <add> self.scheduler_job.processor_agent = mock.MagicMock(spec=DagFileProcessorAgent) <add> <add> self.scheduler_job._create_dag_runs([dag_maker.dag_model], session) <add> self.scheduler_job._start_queued_dagruns(session) <add> # first dagrun execution date is DEFAULT_DATE 2016-01-01T00:00:00+00:00 <add> dr = DagRun.find(execution_date=DEFAULT_DATE, session=session)[0] <add> ti = dr.get_task_instance(task_id='dummy') <add> ti.state = State.SUCCESS <add> session.merge(ti) <add> session.flush() <add> <add> self.scheduler_job._schedule_dag_run(dr, session) <add> session.flush() <add> <add> # Run the second time so _update_dag_next_dagrun will run <add> self.scheduler_job._schedule_dag_run(dr, session) <add> session.flush() <add> <add> dag.catchup = False <add> dag.sync_to_db() <add> assert not dag.catchup <add> <add> dm = DagModel.get_dagmodel(dag.dag_id) <add> self.scheduler_job._create_dag_runs([dm], session) <add> <add> # Check catchup worked correctly by ensuring execution_date is quite new <add> # Our dag is a daily dag <add> assert ( <add> session.query(DagRun.execution_date) <add> .filter(DagRun.execution_date != DEFAULT_DATE) # exclude the first run <add> .scalar() <add> ) > (timezone.utcnow() - timedelta(days=2)) <add> <ide> <ide> @pytest.mark.xfail(reason="Work out where this goes") <ide> def test_task_with_upstream_skip_process_task_instances(): <ide> def test_process_dags_queries_count( <ide> prefix = "Collected database query count mismatches:" <ide> joined = "\n\n".join(failures) <ide> raise AssertionError(f"{prefix}\n\n{joined}") <del> <del> def test_should_mark_dummy_task_as_success(self): <del> dag_file = os.path.join( <del> os.path.dirname(os.path.realpath(__file__)), '../dags/test_only_dummy_tasks.py' <del> ) <del> <del> # Write DAGs to dag and serialized_dag table <del> dagbag = DagBag(dag_folder=dag_file, include_examples=False, read_dags_from_db=False) <del> dagbag.sync_to_db() <del> <del> self.scheduler_job = SchedulerJob(subdir=os.devnull) <del> self.scheduler_job.processor_agent = mock.MagicMock() <del> dag = self.scheduler_job.dagbag.get_dag("test_only_dummy_tasks") <del> <del> # Create DagRun <del> session = settings.Session() <del> orm_dag = session.query(DagModel).get(dag.dag_id) <del> self.scheduler_job._create_dag_runs([orm_dag], session) <del> <del> drs = DagRun.find(dag_id=dag.dag_id, session=session) <del> assert len(drs) == 1 <del> dr = drs[0] <del> <del> # Schedule TaskInstances <del> self.scheduler_job._schedule_dag_run(dr, session) <del> with create_session() as session: <del> tis = session.query(TaskInstance).all() <del> <del> dags = self.scheduler_job.dagbag.dags.values() <del> assert ['test_only_dummy_tasks'] == [dag.dag_id for dag in dags] <del> assert 5 == len(tis) <del> assert { <del> ('test_task_a', 'success'), <del> ('test_task_b', None), <del> ('test_task_c', 'success'), <del> ('test_task_on_execute', 'scheduled'), <del> ('test_task_on_success', 'scheduled'), <del> } == {(ti.task_id, ti.state) for ti in tis} <del> for state, start_date, end_date, duration in [ <del> (ti.state, ti.start_date, ti.end_date, ti.duration) for ti in tis <del> ]: <del> if state == 'success': <del> assert start_date is not None <del> assert end_date is not None <del> assert 0.0 == duration <del> else: <del> assert start_date is None <del> assert end_date is None <del> assert duration is None <del> <del> self.scheduler_job._schedule_dag_run(dr, session) <del> with create_session() as session: <del> tis = session.query(TaskInstance).all() <del> <del> assert 5 == len(tis) <del> assert { <del> ('test_task_a', 'success'), <del> ('test_task_b', 'success'), <del> ('test_task_c', 'success'), <del> ('test_task_on_execute', 'scheduled'), <del> ('test_task_on_success', 'scheduled'), <del> } == {(ti.task_id, ti.state) for ti in tis} <del> for state, start_date, end_date, duration in [ <del> (ti.state, ti.start_date, ti.end_date, ti.duration) for ti in tis <del> ]: <del> if state == 'success': <del> assert start_date is not None <del> assert end_date is not None <del> assert 0.0 == duration <del> else: <del> assert start_date is None <del> assert end_date is None <del> assert duration is None <del> <del> @pytest.mark.need_serialized_dag <del> def test_catchup_works_correctly(self, dag_maker): <del> """Test that catchup works correctly""" <del> session = settings.Session() <del> with dag_maker( <del> dag_id='test_catchup_schedule_dag', <del> schedule_interval=timedelta(days=1), <del> start_date=DEFAULT_DATE, <del> catchup=True, <del> max_active_runs=1, <del> session=session, <del> ) as dag: <del> DummyOperator(task_id='dummy') <del> <del> self.scheduler_job = SchedulerJob(subdir=os.devnull) <del> self.scheduler_job.executor = MockExecutor() <del> self.scheduler_job.processor_agent = mock.MagicMock(spec=DagFileProcessorAgent) <del> <del> self.scheduler_job._create_dag_runs([dag_maker.dag_model], session) <del> self.scheduler_job._start_queued_dagruns(session) <del> # first dagrun execution date is DEFAULT_DATE 2016-01-01T00:00:00+00:00 <del> dr = DagRun.find(execution_date=DEFAULT_DATE, session=session)[0] <del> ti = dr.get_task_instance(task_id='dummy') <del> ti.state = State.SUCCESS <del> session.merge(ti) <del> session.flush() <del> <del> self.scheduler_job._schedule_dag_run(dr, session) <del> session.flush() <del> <del> # Run the second time so _update_dag_next_dagrun will run <del> self.scheduler_job._schedule_dag_run(dr, session) <del> session.flush() <del> <del> dag.catchup = False <del> dag.sync_to_db() <del> assert not dag.catchup <del> <del> dm = DagModel.get_dagmodel(dag.dag_id) <del> self.scheduler_job._create_dag_runs([dm], session) <del> <del> # Check catchup worked correctly by ensuring execution_date is quite new <del> # Our dag is a daily dag <del> assert ( <del> session.query(DagRun.execution_date) <del> .filter(DagRun.execution_date != DEFAULT_DATE) # exclude the first run <del> .scalar() <del> ) > (timezone.utcnow() - timedelta(days=2))
1
Javascript
Javascript
add a css class while the element is held down
52a55ec61895951999cb0d74e706725b965e9c9f
<ide><path>src/ngMobile/directive/ngClick.js <ide> <ide> /** <ide> * @ngdoc directive <del> * @name ngMobile.directive:ngTap <add> * @name ngMobile.directive:ngClick <ide> * <ide> * @description <del> * Specify custom behavior when element is tapped on a touchscreen device. <del> * A tap is a brief, down-and-up touch without much motion. <add> * A more powerful replacement for the default ngClick designed to be used on touchscreen <add> * devices. Most mobile browsers wait about 300ms after a tap-and-release before sending <add> * the click event. This version handles them immediately, and then prevents the <add> * following click event from propagating. <add> * <add> * This directive can fall back to using an ordinary click event, and so works on desktop <add> * browsers as well as mobile. <add> * <add> * This directive also sets the CSS class `ng-click-active` while the element is being held <add> * down (by a mouse click or touch) so you can restyle the depressed element if you wish. <ide> * <ide> * @element ANY <ide> * @param {expression} ngClick {@link guide/expression Expression} to evaluate <ide> * @example <ide> <doc:example> <ide> <doc:source> <del> <button ng-tap="count = count + 1" ng-init="count=0"> <add> <button ng-click="count = count + 1" ng-init="count=0"> <ide> Increment <ide> </button> <ide> count: {{ count }} <ide> ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', <ide> var MOVE_TOLERANCE = 12; // 12px seems to work in most mobile browsers. <ide> var PREVENT_DURATION = 2500; // 2.5 seconds maximum from preventGhostClick call to click <ide> var CLICKBUSTER_THRESHOLD = 25; // 25 pixels in any dimension is the limit for busting clicks. <add> <add> var ACTIVE_CLASS_NAME = 'ng-click-active'; <ide> var lastPreventedTime; <ide> var touchCoordinates; <ide> <ide> ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', <ide> <ide> function resetState() { <ide> tapping = false; <add> element.removeClass(ACTIVE_CLASS_NAME); <ide> } <ide> <ide> element.bind('touchstart', function(event) { <ide> ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', <ide> tapElement = tapElement.parentNode; <ide> } <ide> <add> element.addClass(ACTIVE_CLASS_NAME); <add> <ide> startTime = Date.now(); <ide> <ide> var touches = event.touches && event.touches.length ? event.touches : [event]; <ide> ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', <ide> clickHandler(scope, {$event: event}); <ide> }); <ide> } <del> tapping = false; <add> <add> resetState(); <ide> }); <ide> <ide> // Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click <ide> ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement', <ide> clickHandler(scope, {$event: event}); <ide> }); <ide> }); <add> <add> element.bind('mousedown', function(event) { <add> element.addClass(ACTIVE_CLASS_NAME); <add> }); <add> <add> element.bind('mousemove mouseup', function(event) { <add> element.removeClass(ACTIVE_CLASS_NAME); <add> }); <add> <ide> }; <ide> }]); <ide> <ide><path>test/ngMobile/directive/ngClickSpec.js <ide> describe('ngClick (mobile)', function() { <ide> <ide> <ide> it('should not click if a touchmove comes before touchend', inject(function($rootScope, $compile, $rootElement) { <del> element = $compile('<div ng-tap="tapped = true"></div>')($rootScope); <add> element = $compile('<div ng-click="tapped = true"></div>')($rootScope); <ide> $rootElement.append(element); <ide> $rootScope.$digest(); <ide> <ide> describe('ngClick (mobile)', function() { <ide> expect($rootScope.tapped).toBeUndefined(); <ide> })); <ide> <add> it('should add the CSS class while the element is held down, and then remove it', inject(function($rootScope, $compile, $rootElement) { <add> element = $compile('<div ng-click="tapped = true"></div>')($rootScope); <add> $rootElement.append(element); <add> $rootScope.$digest(); <add> expect($rootScope.tapped).toBeUndefined(); <add> <add> var CSS_CLASS = 'ng-click-active'; <add> <add> expect(element.hasClass(CSS_CLASS)).toBe(false); <add> browserTrigger(element, 'touchstart', 10, 10); <add> expect(element.hasClass(CSS_CLASS)).toBe(true); <add> browserTrigger(element, 'touchend', 10, 10); <add> expect(element.hasClass(CSS_CLASS)).toBe(false); <add> expect($rootScope.tapped).toBe(true); <add> })); <add> <ide> <ide> describe('the clickbuster', function() { <ide> var element1, element2; <ide> describe('ngClick (mobile)', function() { <ide> expect($rootScope.event).toBeDefined(); <ide> })); <ide> }); <add> <add> <ide> });
2
Ruby
Ruby
use the formula stored in the bottle
3ed832d4f0465aa9d938d3f4867ad12aaf394710
<ide><path>Library/Homebrew/exceptions.rb <ide> def initialize(resource) <ide> # raised when a single patch file is not found and apply hasn't been specified <ide> class MissingApplyError < RuntimeError; end <ide> <del>class BottleVersionMismatchError < RuntimeError <del> def initialize(bottle_file, bottle_version, formula, formula_version) <add>class BottleFormulaUnavailableError < RuntimeError <add> def initialize(bottle_path, formula_path) <ide> super <<-EOS.undent <del> Bottle version mismatch <del> Bottle: #{bottle_file} (#{bottle_version}) <del> Formula: #{formula.full_name} (#{formula_version}) <add> This bottle does not contain the formula file: <add> #{bottle_path} <add> #{formula_path} <ide> EOS <ide> end <ide> end <ide><path>Library/Homebrew/formulary.rb <ide> def initialize(bottle_name) <ide> super name, Formulary.path(full_name) <ide> end <ide> <del> def get_formula(spec, alias_path: nil) <del> formula = super <add> def get_formula(spec, **) <add> contents = Utils::Bottles.formula_contents @bottle_filename, name: name <add> formula = Formulary.from_contents name, @bottle_filename, contents, spec <ide> formula.local_bottle_path = @bottle_filename <del> formula_version = formula.pkg_version <del> bottle_version = Utils::Bottles.resolve_version(@bottle_filename) <del> unless formula_version == bottle_version <del> raise BottleVersionMismatchError.new(@bottle_filename, bottle_version, formula, formula_version) <del> end <ide> formula <ide> end <ide> end <ide><path>Library/Homebrew/test/exceptions_spec.rb <ide> class Baz < Formula; end <ide> its(:to_s) { is_expected.to eq("Resource <resource foo> is defined more than once") } <ide> end <ide> <del>describe BottleVersionMismatchError do <del> subject { described_class.new("/foo.bottle.tar.gz", "1.0", formula, "1.1") } <add>describe BottleFormulaUnavailableError do <add> subject { described_class.new("/foo.bottle.tar.gz", "foo/1.0/.brew/foo.rb") } <ide> let(:formula) { double(Formula, full_name: "foo") } <del> its(:to_s) { is_expected.to match(/Bottle version mismatch/) } <add> its(:to_s) { is_expected.to match(/This bottle does not contain the formula file/) } <ide> end
3
Javascript
Javascript
fix eslint issues
54ecdd9d7e1a838521d5660253d8004d760048cf
<ide><path>src/lib/create/check-overflow.js <ide> import { YEAR, MONTH, DATE, HOUR, MINUTE, SECOND, MILLISECOND, WEEK, WEEKDAY } f <ide> import getParsingFlags from '../create/parsing-flags'; <ide> <ide> export default function checkOverflow (m) { <del> var overflow; <del> var a = m._a; <add> var overflow, <add> a = m._a; <ide> <ide> if (a && getParsingFlags(m).overflow === -2) { <ide> overflow = <ide><path>src/lib/create/date-from-array.js <ide> export function createDate (y, m, d, h, M, s, ms) { <ide> } <ide> <ide> export function createUTCDate (y) { <del> var date; <add> var date, args; <ide> // the Date.UTC function remaps years 0-99 to 1900-1999 <ide> if (y < 100 && y >= 0) { <del> var args = Array.prototype.slice.call(arguments); <add> args = Array.prototype.slice.call(arguments); <ide> // preserve leap years using a full 400 year cycle, then reset <ide> args[0] = y + 400; <ide> date = new Date(Date.UTC.apply(null, args)); <ide><path>src/lib/create/from-array.js <ide> export function configFromArray (config) { <ide> } <ide> <ide> function dayOfYearFromWeekInfo(config) { <del> var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow; <add> var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek; <ide> <ide> w = config._w; <ide> if (w.GG != null || w.W != null || w.E != null) { <ide> function dayOfYearFromWeekInfo(config) { <ide> dow = config._locale._week.dow; <ide> doy = config._locale._week.doy; <ide> <del> var curWeek = weekOfYear(createLocal(), dow, doy); <add> curWeek = weekOfYear(createLocal(), dow, doy); <ide> <ide> weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); <ide> <ide><path>src/lib/create/from-object.js <ide> export function configFromObject(config) { <ide> return; <ide> } <ide> <del> var i = normalizeObjectUnits(config._i); <add> var i = normalizeObjectUnits(config._i), <ide> <del> var dayOrDate = i.day === undefined ? i.date : i.day; <add> dayOrDate = i.day === undefined ? i.date : i.day; <ide> config._a = map([i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], function (obj) { <ide> return obj && parseInt(obj, 10); <ide> }); <ide><path>src/lib/create/from-string.js <ide> import {defaultLocaleWeekdaysShort} from '../units/day-of-week'; <ide> <ide> // iso 8601 regex <ide> // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) <del>var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/; <del>var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/; <del> <del>var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/; <del> <del>var isoDates = [ <del> ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], <del> ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], <del> ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], <del> ['GGGG-[W]WW', /\d{4}-W\d\d/, false], <del> ['YYYY-DDD', /\d{4}-\d{3}/], <del> ['YYYY-MM', /\d{4}-\d\d/, false], <del> ['YYYYYYMMDD', /[+-]\d{10}/], <del> ['YYYYMMDD', /\d{8}/], <del> ['GGGG[W]WWE', /\d{4}W\d{3}/], <del> ['GGGG[W]WW', /\d{4}W\d{2}/, false], <del> ['YYYYDDD', /\d{7}/], <del> ['YYYYMM', /\d{6}/, false], <del> ['YYYY', /\d{4}/, false] <del>]; <del> <del>// iso time formats and regexes <del>var isoTimes = [ <del> ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], <del> ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], <del> ['HH:mm:ss', /\d\d:\d\d:\d\d/], <del> ['HH:mm', /\d\d:\d\d/], <del> ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], <del> ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], <del> ['HHmmss', /\d\d\d\d\d\d/], <del> ['HHmm', /\d\d\d\d/], <del> ['HH', /\d\d/] <del>]; <del> <del>var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i; <add>var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, <add> basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, <add> <add> tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, <add> <add> isoDates = [ <add> ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], <add> ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], <add> ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], <add> ['GGGG-[W]WW', /\d{4}-W\d\d/, false], <add> ['YYYY-DDD', /\d{4}-\d{3}/], <add> ['YYYY-MM', /\d{4}-\d\d/, false], <add> ['YYYYYYMMDD', /[+-]\d{10}/], <add> ['YYYYMMDD', /\d{8}/], <add> ['GGGG[W]WWE', /\d{4}W\d{3}/], <add> ['GGGG[W]WW', /\d{4}W\d{2}/, false], <add> ['YYYYDDD', /\d{7}/], <add> ['YYYYMM', /\d{6}/, false], <add> ['YYYY', /\d{4}/, false] <add> ], <add> <add> // iso time formats and regexes <add> isoTimes = [ <add> ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], <add> ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], <add> ['HH:mm:ss', /\d\d:\d\d:\d\d/], <add> ['HH:mm', /\d\d:\d\d/], <add> ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], <add> ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], <add> ['HHmmss', /\d\d\d\d\d\d/], <add> ['HHmm', /\d\d\d\d/], <add> ['HH', /\d\d/] <add> ], <add> <add> aspNetJsonRegex = /^\/?Date\((-?\d+)/i, <add> // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 <add> rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, <add> obsOffsets = { <add> UT: 0, <add> GMT: 0, <add> EDT: -4 * 60, <add> EST: -5 * 60, <add> CDT: -5 * 60, <add> CST: -6 * 60, <add> MDT: -6 * 60, <add> MST: -7 * 60, <add> PDT: -7 * 60, <add> PST: -8 * 60 <add> }; <add> <ide> <ide> // date from iso format <ide> export function configFromISO(config) { <ide> export function configFromISO(config) { <ide> } <ide> } <ide> <del>// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 <del>var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/; <ide> <ide> function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) { <ide> var result = [ <ide> function checkWeekday(weekdayStr, parsedInput, config) { <ide> return true; <ide> } <ide> <del>var obsOffsets = { <del> UT: 0, <del> GMT: 0, <del> EDT: -4 * 60, <del> EST: -5 * 60, <del> CDT: -5 * 60, <del> CST: -6 * 60, <del> MDT: -6 * 60, <del> MST: -7 * 60, <del> PDT: -7 * 60, <del> PST: -8 * 60 <del>}; <del> <ide> function calculateOffset(obsOffset, militaryOffset, numOffset) { <ide> if (obsOffset) { <ide> return obsOffsets[obsOffset]; <ide> } else if (militaryOffset) { <ide> // the only allowed military tz is Z <ide> return 0; <ide> } else { <del> var hm = parseInt(numOffset, 10); <del> var m = hm % 100, h = (hm - m) / 100; <add> var hm = parseInt(numOffset, 10), <add> m = hm % 100, h = (hm - m) / 100; <ide> return h * 60 + m; <ide> } <ide> } <ide> <ide> // date and time from ref 2822 format <ide> export function configFromRFC2822(config) { <del> var match = rfc2822.exec(preprocessRFC2822(config._i)); <add> var match = rfc2822.exec(preprocessRFC2822(config._i)), parsedArray; <ide> if (match) { <del> var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]); <add> parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]); <ide> if (!checkWeekday(match[1], parsedArray, config)) { <ide> return; <ide> } <ide><path>src/lib/create/valid.js <ide> import some from '../utils/some'; <ide> <ide> export function isValid(m) { <ide> if (m._isValid == null) { <del> var flags = getParsingFlags(m); <del> var parsedParts = some.call(flags.parsedDateParts, function (i) { <add> var flags = getParsingFlags(m), <add> parsedParts = some.call(flags.parsedDateParts, function (i) { <ide> return i != null; <del> }); <del> var isNowValid = !isNaN(m._d.getTime()) && <add> }), <add> isNowValid = !isNaN(m._d.getTime()) && <ide> flags.overflow < 0 && <ide> !flags.empty && <ide> !flags.invalidMonth && <ide><path>src/lib/duration/as.js <ide> export function as (units) { <ide> if (!this.isValid()) { <ide> return NaN; <ide> } <del> var days; <del> var months; <del> var milliseconds = this._milliseconds; <add> var days, <add> months, <add> milliseconds = this._milliseconds; <ide> <ide> units = normalizeUnits(units); <ide> <ide> function makeAs (alias) { <ide> }; <ide> } <ide> <del>export var asMilliseconds = makeAs('ms'); <del>export var asSeconds = makeAs('s'); <del>export var asMinutes = makeAs('m'); <del>export var asHours = makeAs('h'); <del>export var asDays = makeAs('d'); <del>export var asWeeks = makeAs('w'); <del>export var asMonths = makeAs('M'); <del>export var asQuarters = makeAs('Q'); <del>export var asYears = makeAs('y'); <add>var asMilliseconds = makeAs('ms'), <add> asSeconds = makeAs('s'), <add> asMinutes = makeAs('m'), <add> asHours = makeAs('h'), <add> asDays = makeAs('d'), <add> asWeeks = makeAs('w'), <add> asMonths = makeAs('M'), <add> asQuarters = makeAs('Q'), <add> asYears = makeAs('y'); <add> <add>export { <add> asMilliseconds, <add> asSeconds, <add> asMinutes, <add> asHours, <add> asDays, <add> asWeeks, <add> asMonths, <add> asQuarters, <add> asYears <add>} <ide><path>src/lib/duration/bubble.js <ide> import absFloor from '../utils/abs-floor'; <ide> import absCeil from '../utils/abs-ceil'; <ide> <ide> export function bubble () { <del> var milliseconds = this._milliseconds; <del> var days = this._days; <del> var months = this._months; <del> var data = this._data; <del> var seconds, minutes, hours, years, monthsFromDays; <add> var milliseconds = this._milliseconds, <add> days = this._days, <add> months = this._months, <add> data = this._data, <add> seconds, minutes, hours, years, monthsFromDays; <ide> <ide> // if we have a mix of positive and negative values, bubble down first <ide> // check: https://github.com/moment/moment/issues/2166 <ide><path>src/lib/duration/create.js <ide> import { createLocal } from '../create/local'; <ide> import { createInvalid as invalid } from './valid'; <ide> <ide> // ASP.NET json date format regex <del>var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; <add>var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, <ide> <ide> // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html <ide> // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere <ide> // and further modified to allow for strings containing both week and day <del>var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; <add> isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; <ide> <ide> export function createDuration (input, key) { <ide> var duration = input, <ide> export function createDuration (input, key) { <ide> } else { <ide> duration.milliseconds = +input; <ide> } <del> } else if (!!(match = aspNetRegex.exec(input))) { <add> } else if ((match = aspNetRegex.exec(input))) { <ide> sign = (match[1] === '-') ? -1 : 1; <ide> duration = { <ide> y : 0, <ide> export function createDuration (input, key) { <ide> s : toInt(match[SECOND]) * sign, <ide> ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match <ide> }; <del> } else if (!!(match = isoRegex.exec(input))) { <add> } else if ((match = isoRegex.exec(input))) { <ide> sign = (match[1] === '-') ? -1 : 1; <ide> duration = { <ide> y : parseIso(match[2], sign), <ide><path>src/lib/duration/get.js <ide> function makeGetter(name) { <ide> }; <ide> } <ide> <del>export var milliseconds = makeGetter('milliseconds'); <del>export var seconds = makeGetter('seconds'); <del>export var minutes = makeGetter('minutes'); <del>export var hours = makeGetter('hours'); <del>export var days = makeGetter('days'); <del>export var months = makeGetter('months'); <del>export var years = makeGetter('years'); <add>var milliseconds = makeGetter('milliseconds'), <add> seconds = makeGetter('seconds'), <add> minutes = makeGetter('minutes'), <add> hours = makeGetter('hours'), <add> days = makeGetter('days'), <add> months = makeGetter('months'), <add> years = makeGetter('years'); <add> <add>export { <add> milliseconds, <add> seconds, <add> minutes, <add> hours, <add> days, <add> months, <add> years <add>} <ide> <ide> export function weeks () { <ide> return absFloor(this.days() / 7); <ide><path>src/lib/duration/humanize.js <ide> import { createDuration } from './create'; <ide> <del>var round = Math.round; <del>var thresholds = { <add>var round = Math.round, <add> thresholds = { <ide> ss: 44, // a few seconds to seconds <ide> s : 45, // seconds to minute <ide> m : 45, // minutes to hour <ide> function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { <ide> } <ide> <ide> function relativeTime (posNegDuration, withoutSuffix, thresholds, locale) { <del> var duration = createDuration(posNegDuration).abs(); <del> var seconds = round(duration.as('s')); <del> var minutes = round(duration.as('m')); <del> var hours = round(duration.as('h')); <del> var days = round(duration.as('d')); <del> var months = round(duration.as('M')); <del> var weeks = round(duration.as('w')); <del> var years = round(duration.as('y')); <add> var duration = createDuration(posNegDuration).abs(), <add> seconds = round(duration.as('s')), <add> minutes = round(duration.as('m')), <add> hours = round(duration.as('h')), <add> days = round(duration.as('d')), <add> months = round(duration.as('M')), <add> weeks = round(duration.as('w')), <add> years = round(duration.as('y')), <ide> <del> var a = seconds <= thresholds.ss && ['s', seconds] || <add> a = seconds <= thresholds.ss && ['s', seconds] || <ide> seconds < thresholds.s && ['ss', seconds] || <ide> minutes <= 1 && ['m'] || <ide> minutes < thresholds.m && ['mm', minutes] || <ide> export function humanize (withSuffixOrOptions) { <ide> return this.localeData().invalidDate(); <ide> } <ide> <del> var withSuffix = false; <del> var th = thresholds; <add> var withSuffix = false, <add> th = thresholds, <add> ws, t, locale, output; <ide> <ide> if (typeof withSuffixOrOptions === 'boolean') { <ide> withSuffix = withSuffixOrOptions; <ide> } <ide> else if (typeof withSuffixOrOptions === 'object') { <del> var ws = withSuffixOrOptions.withSuffix; <add> ws = withSuffixOrOptions.withSuffix; <ide> if (typeof ws === 'boolean') { <ide> withSuffix = ws; <ide> } <ide> <del> var t = withSuffixOrOptions.thresholds; <add> t = withSuffixOrOptions.thresholds; <ide> if (typeof t === 'object') { <ide> // Fill in missing keys with the current values <ide> th = Object.assign({}, thresholds, t); <ide> export function humanize (withSuffixOrOptions) { <ide> } <ide> } <ide> <del> var locale = this.localeData(); <del> var output = relativeTime(this, !withSuffix, th, locale); <add> locale = this.localeData(); <add> output = relativeTime(this, !withSuffix, th, locale); <ide> <ide> if (withSuffix) { <ide> output = locale.pastFuture(+this, output); <ide><path>src/lib/duration/iso-string.js <ide> export function toISOString() { <ide> return this.localeData().invalidDate(); <ide> } <ide> <del> var seconds = abs(this._milliseconds) / 1000; <del> var days = abs(this._days); <del> var months = abs(this._months); <del> var minutes, hours, years; <add> var seconds = abs(this._milliseconds) / 1000, <add> days = abs(this._days), <add> months = abs(this._months), <add> minutes, hours, years, s, total = this.asSeconds(), <add> totalSign, ymSign, daysSign, hmsSign; <add> <add> if (!total) { <add> // this is the same as C#'s (Noda) and python (isodate)... <add> // but not other JS (goog.date) <add> return 'P0D'; <add> } <ide> <ide> // 3600 seconds -> 60 minutes -> 1 hour <ide> minutes = absFloor(seconds / 60); <ide> export function toISOString() { <ide> <ide> <ide> // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js <del> var Y = years; <del> var M = months; <del> var D = days; <del> var h = hours; <del> var m = minutes; <del> var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; <del> var total = this.asSeconds(); <del> <del> if (!total) { <del> // this is the same as C#'s (Noda) and python (isodate)... <del> // but not other JS (goog.date) <del> return 'P0D'; <del> } <add> s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; <ide> <del> var totalSign = total < 0 ? '-' : ''; <del> var ymSign = sign(this._months) !== sign(total) ? '-' : ''; <del> var daysSign = sign(this._days) !== sign(total) ? '-' : ''; <del> var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; <add> totalSign = total < 0 ? '-' : ''; <add> ymSign = sign(this._months) !== sign(total) ? '-' : ''; <add> daysSign = sign(this._days) !== sign(total) ? '-' : ''; <add> hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; <ide> <ide> return totalSign + 'P' + <del> (Y ? ymSign + Y + 'Y' : '') + <del> (M ? ymSign + M + 'M' : '') + <del> (D ? daysSign + D + 'D' : '') + <del> ((h || m || s) ? 'T' : '') + <del> (h ? hmsSign + h + 'H' : '') + <del> (m ? hmsSign + m + 'M' : '') + <del> (s ? hmsSign + s + 'S' : ''); <add> (years ? ymSign + years + 'Y' : '') + <add> (months ? ymSign + months + 'M' : '') + <add> (days ? daysSign + days + 'D' : '') + <add> ((hours || minutes || seconds) ? 'T' : '') + <add> (hours ? hmsSign + hours + 'H' : '') + <add> (minutes ? hmsSign + minutes + 'M' : '') + <add> (seconds ? hmsSign + s + 'S' : ''); <ide> } <ide><path>src/lib/duration/valid.js <ide> import hasOwnProp from '../utils/has-own-prop'; <ide> import toInt from '../utils/to-int'; <ide> import indexOf from '../utils/index-of'; <del>import {Duration} from './constructor'; <ide> import {createDuration} from './create'; <ide> <ide> var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond']; <ide> <ide> export default function isDurationValid(m) { <del> for (var key in m) { <add> var key, unitHasDecimal = false, i; <add> for (key in m) { <ide> if (hasOwnProp(m, key) && !(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) { <ide> return false; <ide> } <ide> } <ide> <del> var unitHasDecimal = false; <del> for (var i = 0; i < ordering.length; ++i) { <add> for (i = 0; i < ordering.length; ++i) { <ide> if (m[ordering[i]]) { <ide> if (unitHasDecimal) { <ide> return false; // only allow non-integers for smallest unit <ide><path>src/lib/format/format.js <ide> import zeroFill from '../utils/zero-fill'; <ide> import isFunction from '../utils/is-function'; <ide> <del>export var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g; <del> <del>var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g; <del> <del>var formatFunctions = {}; <del> <del>export var formatTokenFunctions = {}; <add>var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, <add> localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, <add> formatFunctions = {}, <add> formatTokenFunctions = {}; <add> <add>export { <add> formattingTokens, <add> formatTokenFunctions <add>} <ide> <ide> // token: 'M' <ide> // padded: ['MM', 2] <ide><path>src/lib/locale/lists.js <ide> import { getLocale } from './locales'; <ide> import { createUTC } from '../create/utc'; <ide> <ide> function get (format, index, field, setter) { <del> var locale = getLocale(); <del> var utc = createUTC().set(setter, index); <add> var locale = getLocale(), <add> utc = createUTC().set(setter, index); <ide> return locale[field](utc, format); <ide> } <ide> <ide> function listMonthsImpl (format, index, field) { <ide> return get(format, index, field, 'month'); <ide> } <ide> <del> var i; <del> var out = []; <add> var i, <add> out = []; <ide> for (i = 0; i < 12; i++) { <ide> out[i] = get(format, i, field, 'month'); <ide> } <ide> function listWeekdaysImpl (localeSorted, format, index, field) { <ide> } <ide> <ide> var locale = getLocale(), <del> shift = localeSorted ? locale._week.dow : 0; <add> shift = localeSorted ? locale._week.dow : 0, <add> i, out = []; <ide> <ide> if (index != null) { <ide> return get(format, (index + shift) % 7, field, 'day'); <ide> } <ide> <del> var i; <del> var out = []; <ide> for (i = 0; i < 7; i++) { <ide> out[i] = get(format, (i + shift) % 7, field, 'day'); <ide> } <ide><path>src/lib/locale/locales.js <ide> import keys from '../utils/keys'; <ide> import { baseConfig } from './base-config'; <ide> <ide> // internal storage for locale config files <del>var locales = {}; <del>var localeFamilies = {}; <del>var globalLocale; <add>var locales = {}, <add> localeFamilies = {}, <add> globalLocale; <ide> <ide> function commonPrefix(arr1, arr2) { <ide> var i, minl = Math.min(arr1.length, arr2.length); <ide> function chooseLocale(names) { <ide> } <ide> <ide> function loadLocale(name) { <del> var oldLocale = null; <add> var oldLocale = null, aliasedRequire; <ide> // TODO: Find a better way to register and load all the locales in Node <ide> if (locales[name] === undefined && (typeof module !== 'undefined') && <ide> module && module.exports) { <ide> try { <ide> oldLocale = globalLocale._abbr; <del> var aliasedRequire = require; <add> aliasedRequire = require; <ide> aliasedRequire((typeof __dirname !== undefined ? __dirname : '.') + '/locale/' + name); <ide> getSetGlobalLocale(oldLocale); <ide> } catch (e) { <ide><path>src/lib/locale/ordinal.js <del>export var defaultOrdinal = '%d'; <del>export var defaultDayOfMonthOrdinalParse = /\d{1,2}/; <add>var defaultOrdinal = '%d', <add> defaultDayOfMonthOrdinalParse = /\d{1,2}/; <add> <add>export { <add> defaultOrdinal, <add> defaultDayOfMonthOrdinalParse <add>} <ide> <ide> export function ordinal (number) { <ide> return this._ordinal.replace('%d', number); <ide><path>src/lib/moment/add-subtract.js <ide> export function addSubtract (mom, duration, isAdding, updateOffset) { <ide> } <ide> } <ide> <del>export var add = createAdder(1, 'add'); <del>export var subtract = createAdder(-1, 'subtract'); <add>export var add = createAdder(1, 'add'), <add> subtract = createAdder(-1, 'subtract'); <ide> <ide><path>src/lib/moment/calendar.js <ide> export function calendar (time, formats) { <ide> // Getting start-of-today depends on whether we're local/utc/offset or not. <ide> var now = time || createLocal(), <ide> sod = cloneWithOffset(now, this).startOf('day'), <del> format = hooks.calendarFormat(this, sod) || 'sameElse'; <add> format = hooks.calendarFormat(this, sod) || 'sameElse', <ide> <del> var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]); <add> output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]); <ide> <ide> return this.format(output || this.localeData().calendar(format, this, createLocal(now))); <ide> } <ide><path>src/lib/moment/constructor.js <ide> import getParsingFlags from '../create/parsing-flags'; <ide> <ide> // Plugins that add properties should also add the key here (null value), <ide> // so we can properly clone ourselves. <del>var momentProperties = hooks.momentProperties = []; <add>var momentProperties = hooks.momentProperties = [], <add> updateInProgress = false; <ide> <ide> export function copyConfig(to, from) { <ide> var i, prop, val; <ide> export function copyConfig(to, from) { <ide> return to; <ide> } <ide> <del>var updateInProgress = false; <del> <ide> // Moment prototype object <ide> export function Moment(config) { <ide> copyConfig(this, config); <ide><path>src/lib/moment/diff.js <ide> import { normalizeUnits } from '../units/aliases'; <ide> export function diff (input, units, asFloat) { <ide> var that, <ide> zoneDelta, <del> delta, output; <add> output; <ide> <ide> if (!this.isValid()) { <ide> return NaN; <ide><path>src/lib/moment/format.js <ide> export function toISOString(keepOffset) { <ide> if (!this.isValid()) { <ide> return null; <ide> } <del> var utc = keepOffset !== true; <del> var m = utc ? this.clone().utc() : this; <add> var utc = keepOffset !== true, <add> m = utc ? this.clone().utc() : this; <ide> if (m.year() < 0 || m.year() > 9999) { <ide> return formatMoment(m, utc ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ'); <ide> } <ide> export function inspect () { <ide> if (!this.isValid()) { <ide> return 'moment.invalid(/* ' + this._i + ' */)'; <ide> } <del> var func = 'moment'; <del> var zone = ''; <add> var func = 'moment', <add> zone = '', prefix, year, datetime, suffix; <ide> if (!this.isLocal()) { <ide> func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; <ide> zone = 'Z'; <ide> } <del> var prefix = '[' + func + '("]'; <del> var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY'; <del> var datetime = '-MM-DD[T]HH:mm:ss.SSS'; <del> var suffix = zone + '[")]'; <add> prefix = '[' + func + '("]'; <add> year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY'; <add> datetime = '-MM-DD[T]HH:mm:ss.SSS'; <add> suffix = zone + '[")]'; <ide> <ide> return this.format(prefix + year + datetime + suffix); <ide> } <ide><path>src/lib/moment/get-set.js <ide> export function stringGet (units) { <ide> export function stringSet (units, value) { <ide> if (typeof units === 'object') { <ide> units = normalizeObjectUnits(units); <del> var prioritized = getPrioritizedUnits(units); <del> for (var i = 0; i < prioritized.length; i++) { <add> var prioritized = getPrioritizedUnits(units), i; <add> for (i = 0; i < prioritized.length; i++) { <ide> this[prioritized[i].unit](units[prioritized[i].unit]); <ide> } <ide> } else { <ide><path>src/lib/moment/min-max.js <ide> export var prototypeMin = deprecate( <ide> return createInvalid(); <ide> } <ide> } <del>); <del> <del>export var prototypeMax = deprecate( <del> 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', <del> function () { <del> var other = createLocal.apply(null, arguments); <del> if (this.isValid() && other.isValid()) { <del> return other > this ? this : other; <del> } else { <del> return createInvalid(); <add>), <add> prototypeMax = deprecate( <add> 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', <add> function () { <add> var other = createLocal.apply(null, arguments); <add> if (this.isValid() && other.isValid()) { <add> return other > this ? this : other; <add> } else { <add> return createInvalid(); <add> } <ide> } <del> } <del>); <add> ); <ide> <ide> // Pick a moment m from moments so that m[fn](other) is true for all <ide> // other. This relies on the function fn to be transitive. <ide><path>src/lib/moment/prototype.js <ide> import { Moment } from './constructor'; <ide> var proto = Moment.prototype; <ide> <ide> import { add, subtract } from './add-subtract'; <del>import { calendar, getCalendarFormat } from './calendar'; <add>import { calendar } from './calendar'; <ide> import { clone } from './clone'; <ide> import { isBefore, isBetween, isSame, isAfter, isSameOrAfter, isSameOrBefore } from './compare'; <ide> import { diff } from './diff'; <ide><path>src/lib/moment/start-end-of.js <ide> import { normalizeUnits } from '../units/aliases'; <ide> import { hooks } from '../utils/hooks'; <ide> <del>var MS_PER_SECOND = 1000; <del>var MS_PER_MINUTE = 60 * MS_PER_SECOND; <del>var MS_PER_HOUR = 60 * MS_PER_MINUTE; <del>var MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; <add>var MS_PER_SECOND = 1000, <add> MS_PER_MINUTE = 60 * MS_PER_SECOND, <add> MS_PER_HOUR = 60 * MS_PER_MINUTE, <add> MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; <ide> <ide> // actual modulo - handles negative numbers (for dates before 1970): <ide> function mod(dividend, divisor) { <ide> function utcStartOfDate(y, m, d) { <ide> } <ide> <ide> export function startOf (units) { <del> var time; <add> var time, startOfDate; <ide> units = normalizeUnits(units); <ide> if (units === undefined || units === 'millisecond' || !this.isValid()) { <ide> return this; <ide> } <ide> <del> var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; <add> startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; <ide> <ide> switch (units) { <ide> case 'year': <ide> export function startOf (units) { <ide> } <ide> <ide> export function endOf (units) { <del> var time; <add> var time, startOfDate; <ide> units = normalizeUnits(units); <ide> if (units === undefined || units === 'millisecond' || !this.isValid()) { <ide> return this; <ide> } <ide> <del> var startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; <add> startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; <ide> <ide> switch (units) { <ide> case 'year': <ide><path>src/lib/parse/regex.js <del>export var match1 = /\d/; // 0 - 9 <del>export var match2 = /\d\d/; // 00 - 99 <del>export var match3 = /\d{3}/; // 000 - 999 <del>export var match4 = /\d{4}/; // 0000 - 9999 <del>export var match6 = /[+-]?\d{6}/; // -999999 - 999999 <del>export var match1to2 = /\d\d?/; // 0 - 99 <del>export var match3to4 = /\d\d\d\d?/; // 999 - 9999 <del>export var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999 <del>export var match1to3 = /\d{1,3}/; // 0 - 999 <del>export var match1to4 = /\d{1,4}/; // 0 - 9999 <del>export var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999 <del> <del>export var matchUnsigned = /\d+/; // 0 - inf <del>export var matchSigned = /[+-]?\d+/; // -inf - inf <del> <del>export var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z <del>export var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z <del> <del>export var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123 <del> <del>// any word (or two) characters or numbers including two/three word month in arabic. <del>// includes scottish gaelic two word and hyphenated months <del>export var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i; <del> <add>var match1 = /\d/, // 0 - 9 <add> match2 = /\d\d/, // 00 - 99 <add> match3 = /\d{3}/, // 000 - 999 <add> match4 = /\d{4}/, // 0000 - 9999 <add> match6 = /[+-]?\d{6}/, // -999999 - 999999 <add> match1to2 = /\d\d?/, // 0 - 99 <add> match3to4 = /\d\d\d\d?/, // 999 - 9999 <add> match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999 <add> match1to3 = /\d{1,3}/, // 0 - 999 <add> match1to4 = /\d{1,4}/, // 0 - 9999 <add> match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999 <add> <add> matchUnsigned = /\d+/, // 0 - inf <add> matchSigned = /[+-]?\d+/, // -inf - inf <add> <add> matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z <add> matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z <add> <add> matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 <add> <add> // any word (or two) characters or numbers including two/three word month in arabic. <add> // includes scottish gaelic two word and hyphenated months <add> matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, <add> regexes <add> <add>export { <add> match1, match2, match3, match4, match6, match1to2, match3to4, match5to6, <add> match1to3, match1to4, match1to6, matchUnsigned, matchSigned, matchOffset, <add> matchShortOffset, matchTimestamp, matchWord <add>} <ide> <ide> import hasOwnProp from '../utils/has-own-prop'; <ide> import isFunction from '../utils/is-function'; <ide> <del>var regexes = {}; <add>regexes = {}; <ide> <ide> export function addRegexToken (token, regex, strictRegex) { <ide> regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) { <ide><path>src/lib/units/constants.js <del>export var YEAR = 0; <del>export var MONTH = 1; <del>export var DATE = 2; <del>export var HOUR = 3; <del>export var MINUTE = 4; <del>export var SECOND = 5; <del>export var MILLISECOND = 6; <del>export var WEEK = 7; <del>export var WEEKDAY = 8; <add>export var YEAR = 0, <add> MONTH = 1, <add> DATE = 2, <add> HOUR = 3, <add> MINUTE = 4, <add> SECOND = 5, <add> MILLISECOND = 6, <add> WEEK = 7, <add> WEEKDAY = 8; <ide><path>src/lib/units/day-of-week.js <ide> function shiftWeekdays (ws, n) { <ide> return ws.slice(n, 7).concat(ws.slice(0, n)); <ide> } <ide> <del>export var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'); <add>var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), <add> defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), <add> defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), <add> defaultWeekdaysRegex = matchWord, <add> defaultWeekdaysShortRegex = matchWord, <add> defaultWeekdaysMinRegex = matchWord; <add> <add>export { <add> defaultLocaleWeekdays, <add> defaultLocaleWeekdaysShort, <add> defaultLocaleWeekdaysMin <add>} <add> <ide> export function localeWeekdays (m, format) { <ide> var weekdays = isArray(this._weekdays) ? this._weekdays : <ide> this._weekdays[(m && m !== true && this._weekdays.isFormat.test(format)) ? 'format' : 'standalone']; <ide> return (m === true) ? shiftWeekdays(weekdays, this._week.dow) <ide> : (m) ? weekdays[m.day()] : weekdays; <ide> } <ide> <del>export var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'); <ide> export function localeWeekdaysShort (m) { <ide> return (m === true) ? shiftWeekdays(this._weekdaysShort, this._week.dow) <ide> : (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort; <ide> } <ide> <del>export var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'); <ide> export function localeWeekdaysMin (m) { <ide> return (m === true) ? shiftWeekdays(this._weekdaysMin, this._week.dow) <ide> : (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin; <ide> export function getSetISODayOfWeek (input) { <ide> } <ide> } <ide> <del>var defaultWeekdaysRegex = matchWord; <ide> export function weekdaysRegex (isStrict) { <ide> if (this._weekdaysParseExact) { <ide> if (!hasOwnProp(this, '_weekdaysRegex')) { <ide> export function weekdaysRegex (isStrict) { <ide> } <ide> } <ide> <del>var defaultWeekdaysShortRegex = matchWord; <ide> export function weekdaysShortRegex (isStrict) { <ide> if (this._weekdaysParseExact) { <ide> if (!hasOwnProp(this, '_weekdaysRegex')) { <ide> export function weekdaysShortRegex (isStrict) { <ide> } <ide> } <ide> <del>var defaultWeekdaysMinRegex = matchWord; <ide> export function weekdaysMinRegex (isStrict) { <ide> if (this._weekdaysParseExact) { <ide> if (!hasOwnProp(this, '_weekdaysRegex')) { <ide><path>src/lib/units/hour.js <ide> addParseToken('hmm', function (input, array, config) { <ide> getParsingFlags(config).bigHour = true; <ide> }); <ide> addParseToken('hmmss', function (input, array, config) { <del> var pos1 = input.length - 4; <del> var pos2 = input.length - 2; <add> var pos1 = input.length - 4, <add> pos2 = input.length - 2; <ide> array[HOUR] = toInt(input.substr(0, pos1)); <ide> array[MINUTE] = toInt(input.substr(pos1, 2)); <ide> array[SECOND] = toInt(input.substr(pos2)); <ide> addParseToken('Hmm', function (input, array, config) { <ide> array[MINUTE] = toInt(input.substr(pos)); <ide> }); <ide> addParseToken('Hmmss', function (input, array, config) { <del> var pos1 = input.length - 4; <del> var pos2 = input.length - 2; <add> var pos1 = input.length - 4, <add> pos2 = input.length - 2; <ide> array[HOUR] = toInt(input.substr(0, pos1)); <ide> array[MINUTE] = toInt(input.substr(pos1, 2)); <ide> array[SECOND] = toInt(input.substr(pos2)); <ide> export function localeIsPM (input) { <ide> return ((input + '').toLowerCase().charAt(0) === 'p'); <ide> } <ide> <del>export var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i; <add>export var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, <add> // Setting the hour should keep the time, because the user explicitly <add> // specified which hour they want. So trying to maintain the same hour (in <add> // a new timezone) makes sense. Adding/subtracting hours does not follow <add> // this rule. <add> getSetHour = makeGetSet('Hours', true); <add> <ide> export function localeMeridiem (hours, minutes, isLower) { <ide> if (hours > 11) { <ide> return isLower ? 'pm' : 'PM'; <ide> } else { <ide> return isLower ? 'am' : 'AM'; <ide> } <ide> } <del> <del> <del>// MOMENTS <del> <del>// Setting the hour should keep the time, because the user explicitly <del>// specified which hour they want. So trying to maintain the same hour (in <del>// a new timezone) makes sense. Adding/subtracting hours does not follow <del>// this rule. <del>export var getSetHour = makeGetSet('Hours', true); <ide><path>src/lib/units/millisecond.js <ide> addRegexToken('S', match1to3, match1); <ide> addRegexToken('SS', match1to3, match2); <ide> addRegexToken('SSS', match1to3, match3); <ide> <del>var token; <add>var token, getSetMillisecond; <ide> for (token = 'SSSS'; token.length <= 9; token += 'S') { <ide> addRegexToken(token, matchUnsigned); <ide> } <ide> function parseMs(input, array) { <ide> for (token = 'S'; token.length <= 9; token += 'S') { <ide> addParseToken(token, parseMs); <ide> } <del>// MOMENTS <ide> <del>export var getSetMillisecond = makeGetSet('Milliseconds', false); <add>getSetMillisecond = makeGetSet('Milliseconds', false); <add> <add>export { <add> getSetMillisecond <add>} <ide><path>src/lib/units/month.js <ide> addParseToken(['MMM', 'MMMM'], function (input, array, config, token) { <ide> <ide> // LOCALES <ide> <del>var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/; <del>export var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'); <add>var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), <add> defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'), <add> MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, <add> defaultMonthsShortRegex = matchWord, <add> defaultMonthsRegex = matchWord; <add> <add>export { <add> defaultLocaleMonths, <add> defaultLocaleMonthsShort <add>} <add> <ide> export function localeMonths (m, format) { <ide> if (!m) { <ide> return isArray(this._months) ? this._months : <ide> export function localeMonths (m, format) { <ide> this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()]; <ide> } <ide> <del>export var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'); <ide> export function localeMonthsShort (m, format) { <ide> if (!m) { <ide> return isArray(this._monthsShort) ? this._monthsShort : <ide> export function getDaysInMonth () { <ide> return daysInMonth(this.year(), this.month()); <ide> } <ide> <del>var defaultMonthsShortRegex = matchWord; <ide> export function monthsShortRegex (isStrict) { <ide> if (this._monthsParseExact) { <ide> if (!hasOwnProp(this, '_monthsRegex')) { <ide> export function monthsShortRegex (isStrict) { <ide> } <ide> } <ide> <del>var defaultMonthsRegex = matchWord; <ide> export function monthsRegex (isStrict) { <ide> if (this._monthsParseExact) { <ide> if (!hasOwnProp(this, '_monthsRegex')) { <ide><path>src/lib/units/offset.js <ide> import { hooks } from '../utils/hooks'; <ide> <ide> function offset (token, separator) { <ide> addFormatToken(token, 0, 0, function () { <del> var offset = this.utcOffset(); <del> var sign = '+'; <add> var offset = this.utcOffset(), <add> sign = '+'; <ide> if (offset < 0) { <ide> offset = -offset; <ide> sign = '-'; <ide> addParseToken(['Z', 'ZZ'], function (input, array, config) { <ide> var chunkOffset = /([\+\-]|\d\d)/gi; <ide> <ide> function offsetFromString(matcher, string) { <del> var matches = (string || '').match(matcher); <add> var matches = (string || '').match(matcher), chunk, parts, minutes; <ide> <ide> if (matches === null) { <ide> return null; <ide> } <ide> <del> var chunk = matches[matches.length - 1] || []; <del> var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; <del> var minutes = +(parts[1] * 60) + toInt(parts[2]); <add> chunk = matches[matches.length - 1] || []; <add> parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; <add> minutes = +(parts[1] * 60) + toInt(parts[2]); <ide> <ide> return minutes === 0 ? <del> 0 : <del> parts[0] === '+' ? minutes : -minutes; <add> 0 : <add> parts[0] === '+' ? minutes : -minutes; <ide> } <ide> <ide> // Return a moment from input, that is local/utc/zone equivalent to model. <ide> export function isDaylightSavingTimeShifted () { <ide> return this._isDSTShifted; <ide> } <ide> <del> var c = {}; <add> var c = {}, other; <ide> <ide> copyConfig(c, this); <ide> c = prepareConfig(c); <ide> <ide> if (c._a) { <del> var other = c._isUTC ? createUTC(c._a) : createLocal(c._a); <add> other = c._isUTC ? createUTC(c._a) : createLocal(c._a); <ide> this._isDSTShifted = this.isValid() && <ide> compareArrays(c._a, other.toArray()) > 0; <ide> } else { <ide><path>src/lib/units/priorities.js <ide> export function addUnitPriority(unit, priority) { <ide> } <ide> <ide> export function getPrioritizedUnits(unitsObj) { <del> var units = []; <del> for (var u in unitsObj) { <add> var units = [], u; <add> for (u in unitsObj) { <ide> if (hasOwnProp(unitsObj, u)) { <ide> units.push({unit: u, priority: priorities[u]}); <ide> } <ide><path>src/lib/utils/deprecate.js <ide> export function deprecate(msg, fn) { <ide> hooks.deprecationHandler(null, msg); <ide> } <ide> if (firstTime) { <del> var args = []; <del> var arg; <del> for (var i = 0; i < arguments.length; i++) { <add> var args = [], <add> arg, i, key; <add> for (i = 0; i < arguments.length; i++) { <ide> arg = ''; <ide> if (typeof arguments[i] === 'object') { <ide> arg += '\n[' + i + '] '; <del> for (var key in arguments[0]) { <add> for (key in arguments[0]) { <ide> if (hasOwnProp(arguments[0], key)) { <ide> arg += key + ': ' + arguments[0][key] + ', '; <ide> } <ide><path>src/lib/utils/is-calendar-spec.js <ide> import hasOwnProp from './has-own-prop'; <ide> import isObject from './is-object'; <ide> <ide> export default function isCalendarSpec(input) { <del> var objectTest = isObject(input) && !isObjectEmpty(input); <add> var objectTest = isObject(input) && !isObjectEmpty(input), <ide> <del> var propertyTest = false, <add> propertyTest = false, <ide> properties = [ <ide> 'sameDay', <ide> 'nextDay', <ide> 'lastDay', <ide> 'nextWeek', <ide> 'lastWeek', <ide> 'sameElse' <del> ]; <add> ], <add> property; <ide> <del> for (var property of properties) { <add> <add> for (property of properties) { <ide> propertyTest = propertyTest || hasOwnProp(input, property); <ide> } <ide> <ide><path>src/lib/utils/is-moment-input.js <ide> export function isMomentInput(input) { <ide> } <ide> <ide> export function isMomentInputObject(input) { <del> var objectTest = isObject(input) && !isObjectEmpty(input); <add> var objectTest = isObject(input) && !isObjectEmpty(input), <ide> <del> var propertyTest = false, <add> propertyTest = false, <ide> properties = [ <ide> 'years', <ide> 'year', <ide> export function isMomentInputObject(input) { <ide> 'milliseconds', <ide> 'millisecond', <ide> 'ms' <del> ]; <add> ], <add> property; <ide> <del> for (var property of properties) { <add> for (property of properties) { <ide> propertyTest = propertyTest || hasOwnProp(input, property); <ide> } <ide> <ide><path>src/lib/utils/is-object-empty.js <add>import hasOwnProp from './has-own-prop'; <add> <ide> export default function isObjectEmpty(obj) { <ide> if (Object.getOwnPropertyNames) { <ide> return (Object.getOwnPropertyNames(obj).length === 0); <ide> } else { <ide> var k; <ide> for (k in obj) { <del> if (obj.hasOwnProperty(k)) { <add> if (hasOwnProp(obj, k)) { <ide> return false; <ide> } <ide> } <ide><path>src/lib/utils/some.js <ide> if (Array.prototype.some) { <ide> some = Array.prototype.some; <ide> } else { <ide> some = function (fun) { <del> var t = Object(this); <del> var len = t.length >>> 0; <add> var t = Object(this), <add> len = t.length >>> 0, <add> i; <ide> <del> for (var i = 0; i < len; i++) { <add> for (i = 0; i < len; i++) { <ide> if (i in t && fun.call(this, t[i], i, t)) { <ide> return true; <ide> } <ide><path>src/locale/cs.js <ide> import moment from '../moment'; <ide> <ide> var months = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_'), <del> monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_'); <add> monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_'), <ide> <del>var monthsParse = [/^led/i, /^úno/i, /^bře/i, /^dub/i, /^kvě/i, /^(čvn|červen$|června)/i, /^(čvc|červenec|července)/i, /^srp/i, /^zář/i, /^říj/i, /^lis/i, /^pro/i]; <add> monthsParse = [/^led/i, /^úno/i, /^bře/i, /^dub/i, /^kvě/i, /^(čvn|červen$|června)/i, /^(čvc|červenec|července)/i, /^srp/i, /^zář/i, /^říj/i, /^lis/i, /^pro/i], <ide> // NOTE: 'červen' is substring of 'červenec'; therefore 'červenec' must precede 'červen' in the regex to be fully matched. <ide> // Otherwise parser matches '1. červenec' as '1. červen' + 'ec'. <del>var monthsRegex = /^(leden|únor|březen|duben|květen|červenec|července|červen|června|srpen|září|říjen|listopad|prosinec|led|úno|bře|dub|kvě|čvn|čvc|srp|zář|říj|lis|pro)/i; <add> monthsRegex = /^(leden|únor|březen|duben|květen|červenec|července|červen|června|srpen|září|říjen|listopad|prosinec|led|úno|bře|dub|kvě|čvn|čvc|srp|zář|říj|lis|pro)/i; <ide> <ide> function plural(n) { <ide> return (n > 1) && (n < 5) && (~~(n / 10) !== 1); <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'sekundami'; <ide> } <del> break; <ide> case 'm': // a minute / in a minute / a minute ago <ide> return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou'); <ide> case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'minutami'; <ide> } <del> break; <ide> case 'h': // an hour / in an hour / an hour ago <ide> return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou'); <ide> case 'hh': // 9 hours / in 9 hours / 9 hours ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'hodinami'; <ide> } <del> break; <ide> case 'd': // a day / in a day / a day ago <ide> return (withoutSuffix || isFuture) ? 'den' : 'dnem'; <ide> case 'dd': // 9 days / in 9 days / 9 days ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'dny'; <ide> } <del> break; <ide> case 'M': // a month / in a month / a month ago <ide> return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem'; <ide> case 'MM': // 9 months / in 9 months / 9 months ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'měsíci'; <ide> } <del> break; <ide> case 'y': // a year / in a year / a year ago <ide> return (withoutSuffix || isFuture) ? 'rok' : 'rokem'; <ide> case 'yy': // 9 years / in 9 years / 9 years ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'lety'; <ide> } <del> break; <ide> } <ide> } <ide> <ide><path>src/locale/es-do.js <ide> import moment from '../moment'; <ide> <ide> var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'), <del> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); <add> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), <ide> <del>var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; <del>var monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <add> monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i], <add> monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <ide> <ide> export default moment.defineLocale('es-do', { <ide> months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), <ide><path>src/locale/es-us.js <ide> import moment from '../moment'; <ide> <ide> var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'), <del> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); <add> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), <ide> <del>var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; <del>var monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <add> monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i], <add> monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <ide> <ide> export default moment.defineLocale('es-us', { <ide> months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), <ide><path>src/locale/es.js <ide> import moment from '../moment'; <ide> <ide> var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'), <del> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'); <add> monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_'), <ide> <del>var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i]; <del>var monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <add> monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i], <add> monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i; <ide> <ide> export default moment.defineLocale('es', { <ide> months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'), <ide><path>src/locale/ga.js <ide> import moment from '../moment'; <ide> <ide> var months = [ <ide> 'Eanáir', 'Feabhra', 'Márta', 'Aibreán', 'Bealtaine', 'Meitheamh', 'Iúil', 'Lúnasa', 'Meán Fómhair', 'Deireadh Fómhair', 'Samhain', 'Nollaig' <del>]; <del>var monthsShort = ['Ean', 'Feabh', 'Márt', 'Aib', 'Beal', 'Meith', 'Iúil', 'Lún', 'M.F.', 'D.F.', 'Samh', 'Noll']; <del>var weekdays = ['Dé Domhnaigh', 'Dé Luain', 'Dé Máirt', 'Dé Céadaoin', 'Déardaoin', 'Dé hAoine', 'Dé Sathairn']; <del>var weekdaysShort = ['Domh', 'Luan', 'Máirt', 'Céad', 'Déar', 'Aoine', 'Sath']; <del>var weekdaysMin = ['Do', 'Lu', 'Má', 'Cé', 'Dé', 'A', 'Sa']; <add>], <add> monthsShort = ['Ean', 'Feabh', 'Márt', 'Aib', 'Beal', 'Meith', 'Iúil', 'Lún', 'M.F.', 'D.F.', 'Samh', 'Noll'], <add> weekdays = ['Dé Domhnaigh', 'Dé Luain', 'Dé Máirt', 'Dé Céadaoin', 'Déardaoin', 'Dé hAoine', 'Dé Sathairn'], <add> weekdaysShort = ['Domh', 'Luan', 'Máirt', 'Céad', 'Déar', 'Aoine', 'Sath'], <add> weekdaysMin = ['Do', 'Lu', 'Má', 'Cé', 'Dé', 'A', 'Sa']; <ide> <ide> export default moment.defineLocale('ga', { <ide> months: months, <ide><path>src/locale/gd.js <ide> import moment from '../moment'; <ide> <ide> var months = [ <ide> 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd' <del>]; <add>], <ide> <del>var monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh']; <add> monthsShort = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'], <ide> <del>var weekdays = ['Didòmhnaich', 'Diluain', 'Dimàirt', 'Diciadain', 'Diardaoin', 'Dihaoine', 'Disathairne']; <add> weekdays = ['Didòmhnaich', 'Diluain', 'Dimàirt', 'Diciadain', 'Diardaoin', 'Dihaoine', 'Disathairne'], <ide> <del>var weekdaysShort = ['Did', 'Dil', 'Dim', 'Dic', 'Dia', 'Dih', 'Dis']; <add> weekdaysShort = ['Did', 'Dil', 'Dim', 'Dic', 'Dia', 'Dih', 'Dis'], <ide> <del>var weekdaysMin = ['Dò', 'Lu', 'Mà', 'Ci', 'Ar', 'Ha', 'Sa']; <add> weekdaysMin = ['Dò', 'Lu', 'Mà', 'Ci', 'Ar', 'Ha', 'Sa']; <ide> <ide> export default moment.defineLocale('gd', { <ide> months : months, <ide><path>src/locale/hu.js <ide> import moment from '../moment'; <ide> <ide> var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' '); <ide> function translate(number, withoutSuffix, key, isFuture) { <del> var num = number, <del> suffix; <add> var num = number; <ide> switch (key) { <ide> case 's': <ide> return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce'; <ide><path>src/locale/nl-be.js <ide> import moment from '../moment'; <ide> <ide> var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'), <del> monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'); <add> monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'), <ide> <del>var monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i]; <del>var monthsRegex = /^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; <add> monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i], <add> monthsRegex = /^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; <ide> <ide> export default moment.defineLocale('nl-be', { <ide> months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), <ide><path>src/locale/nl.js <ide> import moment from '../moment'; <ide> <ide> var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_'), <del> monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'); <add> monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_'), <ide> <del>var monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i]; <del>var monthsRegex = /^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; <add> monthsParse = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i], <add> monthsRegex = /^(januari|februari|maart|april|mei|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i; <ide> <ide> export default moment.defineLocale('nl', { <ide> months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'), <ide><path>src/locale/sd.js <ide> var months = [ <ide> 'آڪٽوبر', <ide> 'نومبر', <ide> 'ڊسمبر' <del>]; <del>var days = [ <add>], <add> days = [ <ide> 'آچر', <ide> 'سومر', <ide> 'اڱارو', <ide><path>src/locale/sk.js <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'sekundami'; <ide> } <del> break; <ide> case 'm': // a minute / in a minute / a minute ago <ide> return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou'); <ide> case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'minútami'; <ide> } <del> break; <ide> case 'h': // an hour / in an hour / an hour ago <ide> return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou'); <ide> case 'hh': // 9 hours / in 9 hours / 9 hours ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'hodinami'; <ide> } <del> break; <ide> case 'd': // a day / in a day / a day ago <ide> return (withoutSuffix || isFuture) ? 'deň' : 'dňom'; <ide> case 'dd': // 9 days / in 9 days / 9 days ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'dňami'; <ide> } <del> break; <ide> case 'M': // a month / in a month / a month ago <ide> return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom'; <ide> case 'MM': // 9 months / in 9 months / 9 months ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'mesiacmi'; <ide> } <del> break; <ide> case 'y': // a year / in a year / a year ago <ide> return (withoutSuffix || isFuture) ? 'rok' : 'rokom'; <ide> case 'yy': // 9 years / in 9 years / 9 years ago <ide> function translate(number, withoutSuffix, key, isFuture) { <ide> } else { <ide> return result + 'rokmi'; <ide> } <del> break; <ide> } <ide> } <ide> <ide><path>src/locale/uk.js <ide> function weekdaysCaseReplace(m, format) { <ide> 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'), <ide> 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'), <ide> 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_') <del> }; <add> }, nounCase; <ide> <ide> if (m === true) { <ide> return weekdays['nominative'].slice(1, 7).concat(weekdays['nominative'].slice(0, 1)); <ide> function weekdaysCaseReplace(m, format) { <ide> return weekdays['nominative']; <ide> } <ide> <del> var nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ? <add> nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ? <ide> 'accusative' : <ide> ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ? <ide> 'genitive' : <ide><path>src/locale/ur.js <ide> var months = [ <ide> 'اکتوبر', <ide> 'نومبر', <ide> 'دسمبر' <del>]; <del>var days = [ <add>], <add> days = [ <ide> 'اتوار', <ide> 'پیر', <ide> 'منگل', <ide><path>src/test/helpers/common-locale.js <ide> export function defineCommonLocaleTests(locale, options) { <ide> }); <ide> <ide> test('localeData weekdays can localeSort', function (assert) { <del> var weekdays = moment().localeData().weekdays(); <del> var weekdaysShort = moment().localeData().weekdaysShort(); <del> var weekdaysMin = moment().localeData().weekdaysMin(); <del> var shift = moment().localeData()._week.dow; <add> var weekdays = moment().localeData().weekdays(), <add> weekdaysShort = moment().localeData().weekdaysShort(), <add> weekdaysMin = moment().localeData().weekdaysMin(), <add> shift = moment().localeData()._week.dow; <ide> assert.deepEqual( <ide> moment().localeData().weekdays(true), <ide> weekdays.slice(shift, 7).concat(weekdays.slice(0, shift)), <ide><path>src/test/helpers/has-own-prop.js <add>export default function hasOwnProp(a, b) { <add> return Object.prototype.hasOwnProperty.call(a, b); <add>} <ide><path>src/test/helpers/object-keys.js <add>import hasOwnProp from './has-own-prop'; <add> <ide> export default function objectKeys(obj) { <ide> if (Object.keys) { <ide> return Object.keys(obj); <ide> } else { <ide> // IE8 <ide> var res = [], i; <ide> for (i in obj) { <del> if (obj.hasOwnProperty(i)) { <add> if (hasOwnProp(obj, i)) { <ide> res.push(i); <ide> } <ide> } <ide><path>src/test/locale/en.js <ide> test('weeks year starting sunday format', function (assert) { <ide> <ide> test('weekdays strict parsing', function (assert) { <ide> var m = moment('2015-01-01T12', moment.ISO_8601, true), <del> enLocale = moment.localeData('en'); <add> enLocale = moment.localeData('en'), i; <ide> <del> for (var i = 0; i < 7; ++i) { <add> for (i = 0; i < 7; ++i) { <ide> assert.equal(moment(enLocale.weekdays(m.day(i), ''), 'dddd', true).isValid(), true, 'parse weekday ' + i); <ide> assert.equal(moment(enLocale.weekdaysShort(m.day(i), ''), 'ddd', true).isValid(), true, 'parse short weekday ' + i); <ide> assert.equal(moment(enLocale.weekdaysMin(m.day(i), ''), 'dd', true).isValid(), true, 'parse min weekday ' + i); <ide><path>src/test/locale/fa.js <ide> test('format week', function (assert) { <ide> }); <ide> <ide> test('from', function (assert) { <del> var start = moment([2007, 1, 28]); <add> var start = moment([2007, 1, 28]), s, ss; <ide> assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), 'چند ثانیه', '44 seconds = a few seconds'); <ide> assert.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), 'یک دقیقه', '45 seconds = a minute'); <ide> assert.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), 'یک دقیقه', '89 seconds = a minute'); <ide> test('from', function (assert) { <ide> assert.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), '۲ سال', '548 days = 2 years'); <ide> assert.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), 'یک سال', '1 year = a year'); <ide> assert.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), '۵ سال', '5 years = 5 years'); <del> var s = moment.relativeTimeThreshold('s'); <del> var ss = moment.relativeTimeThreshold('ss'); <add> <add> s = moment.relativeTimeThreshold('s'); <add> ss = moment.relativeTimeThreshold('ss'); <add> <ide> moment.relativeTimeThreshold('s', 60); <ide> moment.relativeTimeThreshold('ss', 0); <ide> assert.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), '۴۴ ثانیه', '44 seconds = 44 seconds'); <ide><path>src/test/locale/ga.js <ide> test('parse', function (assert) { <ide> assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + (monthNum + 1)); <ide> } <ide> <del> for (var i = 0; i < 12; i++) { <del> var testMonth = months[i].split(','); <add> var i, testMonth; <add> for (i = 0; i < 12; i++) { <add> testMonth = months[i].split(','); <add> <ide> equalTest(testMonth[0], 'MMM', i); <ide> equalTest(testMonth[1], 'MMM', i); <ide> equalTest(testMonth[0], 'MMMM', i); <ide> test('format ordinal', function (assert) { <ide> }); <ide> <ide> test('format month', function (assert) { <del> var expected = months; <del> for (var i = 0; i < expected.length; i++) { <add> var expected = months, i; <add> for (i = 0; i < expected.length; i++) { <ide> assert.equal(moment([2011, i, 1]).format('MMMM,MMM'), expected[i], expected[i]); <ide> } <ide> }); <ide> <ide> test('format week', function (assert) { <del> var expected = ['Dé Domhnaigh Domh Do', 'Dé Luain Luan Lu', 'Dé Máirt Máirt Má', 'Dé Céadaoin Céad Cé', 'Déardaoin Déar Dé', 'Dé hAoine Aoine A', 'Dé Sathairn Sath Sa']; <del> for (var i = 0; i < expected.length; i++) { <add> var expected = ['Dé Domhnaigh Domh Do', 'Dé Luain Luan Lu', 'Dé Máirt Máirt Má', 'Dé Céadaoin Céad Cé', 'Déardaoin Déar Dé', 'Dé hAoine Aoine A', 'Dé Sathairn Sath Sa'], <add> i; <add> for (i = 0; i < expected.length; i++) { <ide> assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); <ide> } <ide> }); <ide><path>src/test/locale/gd.js <ide> test('parse', function (assert) { <ide> assert.equal(moment(monthName, monthFormat).month(), monthNum, monthName + ' should be month ' + (monthNum + 1)); <ide> } <ide> <del> for (var i = 0; i < 12; i++) { <del> var testMonth = months[i].split(','); <add> var i, testMonth; <add> for (i = 0; i < 12; i++) { <add> testMonth = months[i].split(','); <add> <ide> equalTest(testMonth[0], 'MMM', i); <ide> equalTest(testMonth[1], 'MMM', i); <ide> equalTest(testMonth[0], 'MMMM', i); <ide> test('format ordinal', function (assert) { <ide> }); <ide> <ide> test('format month', function (assert) { <del> var expected = months; <del> for (var i = 0; i < expected.length; i++) { <add> var expected = months, i; <add> for (i = 0; i < expected.length; i++) { <ide> assert.equal(moment([2011, i, 1]).format('MMMM,MMM'), expected[i], expected[i]); <ide> } <ide> }); <ide> <ide> test('format week', function (assert) { <del> var expected = ['Didòmhnaich Did Dò', 'Diluain Dil Lu', 'Dimàirt Dim Mà', 'Diciadain Dic Ci', 'Diardaoin Dia Ar', 'Dihaoine Dih Ha', 'Disathairne Dis Sa']; <del> for (var i = 0; i < expected.length; i++) { <add> var expected = ['Didòmhnaich Did Dò', 'Diluain Dil Lu', 'Dimàirt Dim Mà', 'Diciadain Dic Ci', 'Diardaoin Dia Ar', 'Dihaoine Dih Ha', 'Disathairne Dis Sa'], <add> i; <add> for (i = 0; i < expected.length; i++) { <ide> assert.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]); <ide> } <ide> }); <ide><path>src/test/locale/ja.js <ide> test('calendar day', function (assert) { <ide> }); <ide> <ide> test('calendar next week', function (assert) { <del> var i, m; <del> var dow = moment().day(); <add> var i, m, <add> dow = moment().day(); <ide> for (i = 2; i < 7; i++) { <ide> m = moment().add({d: i}); <ide> if (dow + i < 7) { <ide> test('calendar next week', function (assert) { <ide> }); <ide> <ide> test('calendar last week', function (assert) { <del> var i, m; <del> var dow = moment().day(); <add> var i, m, <add> dow = moment().day(); <ide> for (i = 2; i < 7; i++) { <ide> m = moment().subtract({d: i}); <ide> if (dow < i) { <ide><path>src/test/locale/sd.js <ide> var months = [ <ide> 'آڪٽوبر', <ide> 'نومبر', <ide> 'ڊسمبر' <del>]; <del>var days = [ <add>], <add> days = [ <ide> 'آچر', <ide> 'سومر', <ide> 'اڱارو', <ide><path>src/test/locale/ur.js <ide> var months = [ <ide> 'اکتوبر', <ide> 'نومبر', <ide> 'دسمبر' <del>]; <del>var days = [ <add>], <add> days = [ <ide> 'اتوار', <ide> 'پیر', <ide> 'منگل', <ide><path>src/test/moment/calendar.js <ide> test('passing a function', function (assert) { <ide> }); <ide> <ide> test('extending calendar options', function (assert) { <del> var calendarFormat = moment.calendarFormat; <add> var calendarFormat = moment.calendarFormat, a, b; <ide> <ide> moment.calendarFormat = function (myMoment, now) { <del> var diff = myMoment.diff(now, 'days', true); <del> var nextMonth = now.clone().add(1, 'month'); <add> var diff = myMoment.diff(now, 'days', true), <add> nextMonth = now.clone().add(1, 'month'), <ide> <del> var retVal = diff < -6 ? 'sameElse' : <add> retVal = diff < -6 ? 'sameElse' : <ide> diff < -1 ? 'lastWeek' : <ide> diff < 0 ? 'lastDay' : <ide> diff < 1 ? 'sameDay' : <ide> test('extending calendar options', function (assert) { <ide> sameElse : 'L' <ide> } <ide> }); <del> var a = moment('2016-01-01').add(28, 'days'); <del> var b = moment('2016-01-01').add(1, 'month'); <add> <add> a = moment('2016-01-01').add(28, 'days'); <add> b = moment('2016-01-01').add(1, 'month'); <add> <ide> try { <ide> assert.equal(a.calendar('2016-01-01'), 'This month on the 29th', 'Ad hoc calendar format for this month'); <ide> assert.equal(b.calendar('2016-01-01'), 'Next month on the 1st', 'Ad hoc calendar format for next month'); <ide> test('extending calendar options', function (assert) { <ide> }); <ide> <ide> test('calendar overload time - passing one parameter - a Moment', function (assert) { <del> var a = moment().hours(13).minutes(23).seconds(45); <del> var b = moment().add(1, 'd'); <add> var a = moment().hours(13).minutes(23).seconds(45), <add> b = moment().add(1, 'd'); <ide> assert.equal( <ide> a.calendar(b), <ide> 'Yesterday at 1:23 PM', <ide> test('calendar overload time - passing one parameter - a Moment', function (asse <ide> }); <ide> <ide> test('calendar overload time - passing one parameter - a Date', function (assert) { <del> var a = moment().hours(13).minutes(23).seconds(45).subtract(1, 'd'); <del> var d = new Date(); <add> var a = moment().hours(13).minutes(23).seconds(45).subtract(1, 'd'), <add> d = new Date(); <ide> assert.equal( <ide> a.calendar(d), <ide> 'Yesterday at 1:23 PM', <ide> test('calendar overload time - passing one parameter - an array of strings', fun <ide> }); <ide> <ide> test('calendar overload time - passing one parameter - a moment input object', function (assert) { <del> var a = moment(); <add> var a = moment(), <ide> <del> var todayTime = new Date(), <add> todayTime = new Date(), <ide> month = todayTime.getMonth() + 1, <ide> day = todayTime.getDate(), <del> year = todayTime.getFullYear(); <add> year = todayTime.getFullYear(), expectedString; <ide> <ide> month = month < 10 ? '0' + month.toString() : month; <ide> day = day < 10 ? '0' + day.toString() : day; <ide> <del> var expectedString = month + '/' + day + '/' + year; <add> expectedString = month + '/' + day + '/' + year; <ide> <ide> assert.equal( <ide> a.calendar({ <ide><path>src/test/moment/create.js <ide> import { module, test } from '../qunit'; <ide> import eachOwnProp from '../helpers/each-own-prop'; <add>import hasOwnProp from '../helpers/has-own-prop'; <ide> import moment from '../../moment'; <ide> <ide> module('create'); <ide> test('moment', function (assert) { <ide> }); <ide> <ide> test('cloning moment should only copy own properties', function (assert) { <del> assert.ok(!moment().clone().hasOwnProperty('month'), 'Should not clone prototype methods'); <add> assert.ok(!hasOwnProp(moment().clone(), 'month'), 'Should not clone prototype methods'); <ide> }); <ide> <ide> test('cloning moment works with weird clones', function (assert) { <ide> function getVerifier(test) { <ide> } <ide> <ide> test('parsing week and weekday information', function (assert) { <del> var ver = getVerifier(assert); <del> var currentWeekOfYear = moment().weeks(); <del> var expectedDate2012 = moment([2012, 0, 1]) <add> var ver = getVerifier(assert), <add> currentWeekOfYear = moment().weeks(), <add> expectedDate2012 = moment([2012, 0, 1]) <ide> .day(0) <ide> .add((currentWeekOfYear - 1), 'weeks') <del> .format('YYYY MM DD'); <del> var expectedDate1999 = moment([1999, 0, 1]) <add> .format('YYYY MM DD'), <add> expectedDate1999 = moment([1999, 0, 1]) <ide> .day(0) <ide> .add((currentWeekOfYear - 1), 'weeks') <ide> .format('YYYY MM DD'); <ide> test('Y token', function (assert) { <ide> }); <ide> <ide> test('parsing flags retain parsed date parts', function (assert) { <del> var a = moment('10 p', 'hh:mm a'); <add> var a = moment('10 p', 'hh:mm a'), b; <ide> assert.equal(a.parsingFlags().parsedDateParts[3], 10, 'parsed 10 as the hour'); <ide> assert.equal(a.parsingFlags().parsedDateParts[0], undefined, 'year was not parsed'); <ide> assert.equal(a.parsingFlags().meridiem, 'p', 'meridiem flag was added'); <del> var b = moment('10:30', ['MMDDYY', 'HH:mm']); <add> b = moment('10:30', ['MMDDYY', 'HH:mm']); <ide> assert.equal(b.parsingFlags().parsedDateParts[3], 10, 'multiple format parshing matched hour'); <ide> assert.equal(b.parsingFlags().parsedDateParts[0], undefined, 'array is properly copied, no residual data from first token parse'); <ide> }); <ide> test('invalid dates return invalid for methods that access the _d prop', functio <ide> }); <ide> <ide> test('k, kk', function (assert) { <del> for (var i = -1; i <= 24; i++) { <del> var kVal = i + ':15:59'; <del> var kkVal = (i < 10 ? '0' : '') + i + ':15:59'; <add> var i, kVal, kkVal; <add> for (i = -1; i <= 24; i++) { <add> kVal = i + ':15:59'; <add> kkVal = (i < 10 ? '0' : '') + i + ':15:59'; <ide> if (i !== 24) { <ide> assert.ok(moment(kVal, 'k:mm:ss').isSame(moment(kVal, 'H:mm:ss')), kVal + ' k parsing'); <ide> assert.ok(moment(kkVal, 'kk:mm:ss').isSame(moment(kkVal, 'HH:mm:ss')), kkVal + ' kk parsing'); <ide><path>src/test/moment/creation-data.js <ide> import moment from '../../moment'; <ide> module('creation data'); <ide> <ide> test('valid date', function (assert) { <del> var dat = moment('1992-10-22'); <del> var orig = dat.creationData(); <add> var dat = moment('1992-10-22'), <add> orig = dat.creationData(); <ide> <ide> assert.equal(dat.isValid(), true, '1992-10-22 is valid'); <ide> assert.equal(orig.input, '1992-10-22', 'original input is not correct.'); <ide> test('valid date', function (assert) { <ide> }); <ide> <ide> test('valid date at fr locale', function (assert) { <del> var dat = moment('1992-10-22', 'YYYY-MM-DD', 'fr'); <del> var orig = dat.creationData(); <add> var dat = moment('1992-10-22', 'YYYY-MM-DD', 'fr'), <add> orig = dat.creationData(); <ide> <ide> assert.equal(orig.locale._abbr, 'fr', 'locale is fr'); <ide> }); <ide> <ide> test('valid date with formats', function (assert) { <del> var dat = moment('29-06-1995', ['MM-DD-YYYY', 'DD-MM', 'DD-MM-YYYY']); <del> var orig = dat.creationData(); <add> var dat = moment('29-06-1995', ['MM-DD-YYYY', 'DD-MM', 'DD-MM-YYYY']), <add> orig = dat.creationData(); <ide> <ide> assert.equal(orig.format, 'DD-MM-YYYY', 'DD-MM-YYYY format is defined.'); <ide> }); <ide><path>src/test/moment/deprecate.js <ide> import { module, test } from '../qunit'; <ide> import { deprecate } from '../../lib/utils/deprecate'; <del>import moment from '../../moment'; <ide> <ide> module('deprecate'); <ide> <ide> test('deprecate', function (assert) { <ide> // NOTE: hooks inside deprecate.js and moment are different, so this is can <ide> // not be test.expectedDeprecations(...) <del> var fn = function () {}; <del> var deprecatedFn = deprecate('testing deprecation', fn); <add> var fn = function () {}, <add> deprecatedFn = deprecate('testing deprecation', fn); <ide> deprecatedFn(); <ide> <ide> assert.expect(0); <ide><path>src/test/moment/diff.js <ide> test('diff month', function (assert) { <ide> }); <ide> <ide> test('diff across DST', function (assert) { <del> var dst = dstForYear(2012), a, b, daysInMonth; <add> var dst = dstForYear(2012), a, b; <ide> if (!dst) { <ide> assert.equal(42, 42, 'at least one assertion'); <ide> return; <ide> } <ide> <ide> a = dst.moment; <ide> b = a.clone().utc().add(12, 'hours').local(); <del> daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2; <ide> assert.equal(b.diff(a, 'milliseconds', true), 12 * 60 * 60 * 1000, <ide> 'ms diff across DST'); <ide> assert.equal(b.diff(a, 'seconds', true), 12 * 60 * 60, <ide> test('diff across DST', function (assert) { <ide> <ide> a = dst.moment; <ide> b = a.clone().utc().add(12 + dst.diff, 'hours').local(); <del> daysInMonth = (a.daysInMonth() + b.daysInMonth()) / 2; <ide> <ide> assert.equal(b.diff(a, 'milliseconds', true), <ide> (12 + dst.diff) * 60 * 60 * 1000, <ide><path>src/test/moment/duration.js <ide> test('instantiation from another duration', function (assert) { <ide> }); <ide> <ide> test('explicit cloning', function (assert) { <del> var durationA = moment.duration(5, 'milliseconds'); <del> var durationB = durationA.clone(); <add> var durationA = moment.duration(5, 'milliseconds'), <add> durationB = durationA.clone(); <ide> durationA.add(5, 'milliseconds'); <ide> assert.notEqual(durationA.milliseconds(), durationB.milliseconds(), 'Calling duration.clone() on a duration will create a clone'); <ide> }); <ide> test('add', function (assert) { <ide> }); <ide> <ide> test('add to moment', function (assert) { <del> var d = moment.duration({months: 1, seconds: -1}); <del> var m = moment('2017-03-01').add(d); <add> var d = moment.duration({months: 1, seconds: -1}), <add> m = moment('2017-03-01').add(d); <ide> assert.equal(m.month(), 2, 'Adds months before time'); <ide> assert.equal(m.date(), 31, 'Adds time after months'); <ide> }); <ide><path>src/test/moment/duration_invalid.js <ide> test('invalid duration operations', function (assert) { <ide> moment.duration.invalid() <ide> ], <ide> i, <del> invalid, <del> valid = moment.duration(); <add> invalid; <ide> <ide> for (i = 0; i < invalids.length; ++i) { <ide> invalid = invalids[i]; <ide><path>src/test/moment/format.js <ide> import { module, test } from '../qunit'; <del>import each from '../helpers/each'; <ide> import eachOwnProp from '../helpers/each-own-prop'; <ide> import moment from '../../moment'; <ide> <ide><path>src/test/moment/getters_setters.js <ide> test('chaining setters', function (assert) { <ide> }); <ide> <ide> test('setter with multiple unit values', function (assert) { <del> var a = moment(); <add> var a = moment(), c; <ide> a.set({ <ide> year: 2011, <ide> month: 9, <ide> test('setter with multiple unit values', function (assert) { <ide> assert.equal(a.seconds(), 8, 'second'); <ide> assert.equal(a.milliseconds(), 9, 'milliseconds'); <ide> <del> var c = moment([2016,0,1]); <add> c = moment([2016,0,1]); <ide> assert.equal(c.set({weekYear: 2016}).weekYear(), 2016, 'week year correctly sets with object syntax'); <ide> assert.equal(c.set({quarter: 3}).quarter(), 3, 'quarter sets correctly with object syntax'); <ide> }); <ide> test('day setter', function (assert) { <ide> }); <ide> <ide> test('year setter', function (assert) { <del> var a = moment([2015, 3, 15]); <add> var a = moment([2015, 3, 15]), b, c, d, e; <ide> assert.equal(moment(a).year(2016).format('YYYY-MM-DD'), '2016-04-15', 'set from 2015 to 2016'); <ide> assert.equal(moment(a).year(2011).format('YYYY-MM-DD'), '2011-04-15', 'set from 2015 to 2011'); <ide> <del> var b = moment([2012, 1, 29]); <add> b = moment([2012, 1, 29]); <ide> assert.equal(moment(b).year(2017).format('YYYY-MM-DD'), '2017-02-28', 'set from last day of february on a leap year to a non leap year'); <ide> assert.equal(moment(b).year(2004).format('YYYY-MM-DD'), '2004-02-29', 'set from last day of february on a leap year to a leap year'); <ide> <del> var c = moment([2012, 9, 4]); <add> c = moment([2012, 9, 4]); <ide> assert.equal(moment(c).year(2017).format('YYYY-MM-DD'), '2017-10-04', 'set from a random day on a leap year to a non leap year'); <ide> assert.equal(moment(c).year(2004).format('YYYY-MM-DD'), '2004-10-04', 'set from a random day on a leap year to a leap year'); <ide> <del> var d = moment([2020, 1, 29]); <add> d = moment([2020, 1, 29]); <ide> assert.equal(moment(d).year('2020').format('YYYY-MM-DD'), '2020-02-29', 'set from last day of february in 2020 to the same year, provided as string'); <ide> <del> var e = moment([2012, 1, 29]); <add> e = moment([2012, 1, 29]); <ide> assert.equal(moment(e).year('2020').format('YYYY-MM-DD'), '2020-02-29', 'set from last day of february on a leap year to 2020, provided as string'); <ide> }); <ide> <ide> test('object set ordering', function (assert) { <del> var a = moment([2016,3,30]); <add> var a = moment([2016,3,30]), b, c; <ide> assert.equal(a.set({date:31, month:4}).date(), 31, 'setter order automatically arranged by size'); <del> var b = moment([2015,1,28]); <add> b = moment([2015,1,28]); <ide> assert.equal(b.set({date:29, year: 2016}).format('YYYY-MM-DD'), '2016-02-29', 'year is prioritized over date'); <ide> //check a nonexistent time in US isn't set <del> var c = moment([2016,2,13]); <add> c = moment([2016,2,13]); <ide> c.set({ <ide> hour:2, <ide> minutes:30, <ide><path>src/test/moment/instanceof.js <ide> import moment from '../../moment'; <ide> module('instanceof'); <ide> <ide> test('instanceof', function (assert) { <del> var mm = moment([2010, 0, 1]); <del> <ide> var extend = function (a, b) { <ide> var i; <ide> for (i in b) { <ide><path>src/test/moment/is_array.js <del>import { module, test } from '../qunit'; <add>import { test } from '../qunit'; <ide> import isArray from '../../lib/utils/is-array.js'; <ide> <ide> <ide><path>src/test/moment/is_between.js <ide> test('is between without units', function (assert) { <ide> }); <ide> <ide> test('is between without units inclusivity', function (assert) { <del> var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m); <add> var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)); <ide> assert.equal(m.isBetween( <ide> moment(new Date(2011, 3, 2, 3, 4, 5, 10)), <ide> moment(new Date(2012, 3, 2, 3, 4, 5, 10)), null, '()'), false, 'start and end are excluded, start is equal to moment'); <ide> test('is between without units inclusivity', function (assert) { <ide> }); <ide> <ide> test('is between milliseconds inclusivity', function (assert) { <del> var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)), mCopy = moment(m); <add> var m = moment(new Date(2011, 3, 2, 3, 4, 5, 10)); <ide> assert.equal(m.isBetween( <ide> moment(new Date(2010, 3, 2, 3, 4, 5, 10)), <ide> moment(new Date(2012, 3, 2, 3, 4, 5, 10)), 'milliseconds'), true, 'options, no inclusive'); <ide><path>src/test/moment/is_number.js <del>import { module, test } from '../qunit'; <add>import { test } from '../qunit'; <ide> import isNumber from '../../lib/utils/is-number.js'; <ide> <ide> <ide><path>src/test/moment/is_valid.js <ide> test('valid string iso 8601 - not strict', function (assert) { <ide> '20100130T235959,999-0700', <ide> '20100130T000000,000+0700', <ide> '20100130 000000,000Z' <del> ]; <add> ], i; <ide> <del> for (var i = 0; i < tests.length; i++) { <add> for (i = 0; i < tests.length; i++) { <ide> assert.equal(moment(tests[i]).isValid(), true, tests[i] + ' should be valid in normal'); <ide> assert.equal(moment.utc(tests[i]).isValid(), true, tests[i] + ' should be valid in normal'); <ide> } <ide><path>src/test/moment/listers.js <ide> test('with locale data', function (assert) { <ide> weekdays = 'one_two_three_four_five_six_seven'.split('_'), <ide> weekdaysShort = 'on_tw_th_fo_fi_si_se'.split('_'), <ide> weekdaysMin = '1_2_3_4_5_6_7'.split('_'), <del> weekdaysLocale = 'four_five_six_seven_one_two_three'.split('_'), <del> weekdaysShortLocale = 'fo_fi_si_se_on_tw_th'.split('_'), <del> weekdaysMinLocale = '4_5_6_7_1_2_3'.split('_'), <del> week = { <del> dow : 3, <del> doy : 6 <del> }; <ide> <del> var customLocale = moment.localeData('numerologists'); <add> customLocale = moment.localeData('numerologists'); <ide> <ide> assert.deepEqual(customLocale.months(), months); <ide> assert.deepEqual(customLocale.monthsShort(), monthsShort); <ide><path>src/test/moment/locale.js <ide> test('instance locale persists with cloning', function (assert) { <ide> moment.locale('en'); <ide> <ide> var a = moment([2012, 5, 6]).locale('es'), <del> b = a.clone(), <del> c = moment(a); <add> b = a.clone(); <ide> <ide> assert.equal(b.format('MMMM'), 'junio', 'using moment.fn.clone()'); <ide> assert.equal(b.format('MMMM'), 'junio', 'using moment()'); <ide><path>src/test/moment/normalize_units.js <ide> test('normalize units', function (assert) { <ide> fullKeyCaps, <ide> fullKeyPlural, <ide> fullKeyCapsPlural, <del> fullKeyLower, <ide> alias, <ide> index; <ide> <ide> for (index = 0; index < length; index += 1) { <ide> fullKey = fullKeys[index]; <ide> fullKeyCaps = fullKey.toUpperCase(); <del> fullKeyLower = fullKey.toLowerCase(); <ide> fullKeyPlural = fullKey + 's'; <ide> fullKeyCapsPlural = fullKeyCaps + 's'; <ide> alias = aliases[index]; <ide><path>src/test/moment/now.js <ide> test('now', function (assert) { <ide> }); <ide> <ide> test('now - Date mocked', function (assert) { <del> // We need to test mocking the global Date object, so disable 'Read Only' jshint check <del> /* jshint -W020 */ <ide> var RealDate = Date, <ide> customTimeMs = moment('2015-01-01T01:30:00.000Z').valueOf(); <ide> <ide> test('now - Date mocked', function (assert) { <ide> <ide> MockDate.prototype = RealDate.prototype; <ide> <add> // eslint-disable-next-line <ide> Date = MockDate; <ide> <ide> try { <ide> assert.equal(moment().valueOf(), customTimeMs, 'moment now() time should use the global Date object'); <ide> } finally { <add> // eslint-disable-next-line <ide> Date = RealDate; <ide> } <ide> }); <ide><path>src/test/moment/relative_time.js <ide> test('custom thresholds', function (assert) { <ide> }); <ide> <ide> test('custom rounding', function (assert) { <del> var roundingDefault = moment.relativeTimeRounding(); <add> var roundingDefault = moment.relativeTimeRounding(), a, retainValue; <ide> <ide> // Round relative time evaluation down <ide> moment.relativeTimeRounding(Math.floor); <ide> test('custom rounding', function (assert) { <ide> moment.relativeTimeThreshold('d', 27); <ide> moment.relativeTimeThreshold('M', 12); <ide> <del> var a = moment.utc(); <add> a = moment.utc(); <ide> a.subtract({minutes: 59, seconds: 59}); <ide> assert.equal(a.toNow(), 'in 59 minutes', 'Round down towards the nearest minute'); <ide> <ide> test('custom rounding', function (assert) { <ide> assert.equal(a.toNow(), 'in a year', 'Round down towards the nearest year'); <ide> <ide> // Do not round relative time evaluation <del> var retainValue = function (value) { <add> retainValue = function (value) { <ide> return value.toFixed(3); <ide> }; <ide> moment.relativeTimeRounding(retainValue); <ide><path>src/test/moment/to_type.js <ide> test('toArray', function (assert) { <ide> }); <ide> <ide> test('toDate returns a copy of the internal date', function (assert) { <del> var m = moment(); <del> var d = m.toDate(); <add> var m = moment(), <add> d = m.toDate(); <ide> m.year(0); <ide> assert.notEqual(d, m.toDate()); <ide> }); <ide> test('toJSON', function (assert) { <ide> <ide> test('toJSON works when moment is frozen', function (assert) { <ide> if (Date.prototype.toISOString) { <del> var expected = new Date().toISOString(); <del> var m = moment(expected); <add> var expected = new Date().toISOString(), <add> m = moment(expected); <ide> if (Object.freeze != null) { <ide> Object.freeze(m); <ide> } <ide><path>src/test/moment/zones.js <ide> test('timezone format', function (assert) { <ide> <ide> test('parse zone without a timezone', function (assert) { <ide> test.expectedDeprecations(); <del> var m1 = moment.parseZone('2016-02-01T00:00:00'); <del> var m2 = moment.parseZone('2016-02-01T00:00:00Z'); <del> var m3 = moment.parseZone('2016-02-01T00:00:00+00:00'); //Someone might argue this is not necessary, you could even argue that is wrong being here. <del> var m4 = moment.parseZone('2016-02-01T00:00:00+0000'); //Someone might argue this is not necessary, you could even argue that is wrong being here. <add> var m1 = moment.parseZone('2016-02-01T00:00:00'), <add> m2 = moment.parseZone('2016-02-01T00:00:00Z'), <add> m3 = moment.parseZone('2016-02-01T00:00:00+00:00'), //Someone might argue this is not necessary, you could even argue that is wrong being here. <add> m4 = moment.parseZone('2016-02-01T00:00:00+0000'); //Someone might argue this is not necessary, you could even argue that is wrong being here. <ide> assert.equal( <ide> m1.format('M D YYYY HH:mm:ss ZZ'), <ide> '2 1 2016 00:00:00 +0000', <ide> test('parse zone without a timezone', function (assert) { <ide> test('parse zone with a minutes unit abs less than 16 should retain minutes', function (assert) { <ide> //ensure when minutes are explicitly parsed, they are retained <ide> //instead of converted to hours, even if less than 16 <del> var n = moment.parseZone('2013-01-01T00:00:00-00:15'); <add> var n = moment.parseZone('2013-01-01T00:00:00-00:15'), o; <ide> assert.equal(n.utcOffset(), -15); <ide> assert.equal(n.zone(), 15); <ide> assert.equal(n.hour(), 0); <del> var o = moment.parseZone('2013-01-01T00:00:00+00:15'); <add> <add> o = moment.parseZone('2013-01-01T00:00:00+00:15'); <ide> assert.equal(o.utcOffset(), 15); <ide> assert.equal(o.zone(), -15); <ide> assert.equal(o.hour(), 0); <ide><path>src/test/qunit.js <ide> import moment from '../moment'; <ide> import { setupDeprecationHandler, teardownDeprecationHandler } from './helpers/deprecation-handler'; <ide> <del>export var test = QUnit.test; <del>export var only = QUnit.only; <add>export var test = QUnit.test, <add> only = QUnit.only; <ide> <ide> export function module (name, lifecycle) { <ide> QUnit.module(name, { <ide><path>tasks/qtest.js <ide> module.exports = function (grunt) { <ide> grunt.task.registerTask('qtest', 'run tests locally', function () { <del> var done = this.async(); <add> var done = this.async(), testrunner, tests; <ide> <del> var testrunner = require('node-qunit'); <add> testrunner = require('node-qunit'); <ide> testrunner.options.log.assertions = false; <ide> testrunner.options.log.tests = false; <ide> testrunner.options.log.summary = false; <ide> testrunner.options.log.testing = false; <ide> testrunner.options.maxBlockDuration = 600000; <ide> <del> var tests; <del> <ide> if (grunt.option('only') != null) { <ide> tests = grunt.file.expand.apply(null, grunt.option('only').split(',').map(function (file) { <ide> if (file === 'moment') { <ide><path>tasks/transpile.js <ide> module.exports = function (grunt) { <ide> // var esperanto = require('esperanto'); <ide> var rollup = require('rollup').rollup; <ide> // var babel = require('rollup-plugin-babel'); <del> var path = require('path'); <del> var Promise = require('es6-promise').Promise; <del> var TMP_DIR = 'build/tmp'; <add> var path = require('path'), <add> Promise = require('es6-promise').Promise, <add> TMP_DIR = 'build/tmp', <add> headerCache = {}; <ide> <ide> function moveComments(code, moveType) { <ide> var comments = [], rest = [], skipId = -1; <ide> module.exports = function (grunt) { <ide> return comments.concat([''], rest).join('\n'); <ide> } <ide> <del> var headerCache = {}; <ide> function getHeaderByFile(headerFile) { <ide> if (headerFile === 'none') { <ide> return ''; <ide> module.exports = function (grunt) { <ide> grunt.task.registerTask('transpile-custom-raw', <ide> 'build just custom language bundles', <ide> function (locales) { <del> var done = this.async(); <add> var done = this.async(), <ide> <del> var localeFiles = locales.split(',').map(function (locale) { <add> localeFiles = locales.split(',').map(function (locale) { <ide> var file = grunt.file.expand({cwd: 'src'}, 'locale/' + locale + '.js'); <ide> if (file.length !== 1) { <ide> // we failed to find a locale
86
PHP
PHP
fix lengthawarepaginator docblocks
5f40dc6e547043d5fd9b8f7d1baaaeec4d953c53
<ide><path>src/Illuminate/Pagination/LengthAwarePaginator.php <ide> protected function setCurrentPage($currentPage, $pageName) <ide> * <ide> * @param string $view <ide> * @param array $data <del> * @return string <add> * @return \Illuminate\Support\HtmlString <ide> */ <ide> public function links($view = null, $data = []) <ide> { <ide> public function links($view = null, $data = []) <ide> * <ide> * @param string $view <ide> * @param array $data <del> * @return string <add> * @return \Illuminate\Support\HtmlString <ide> */ <ide> public function render($view = null, $data = []) <ide> {
1
Text
Text
use dfn instead of code tag
bfa5c2628832edd6bb2711b7785ede8aa188a070
<ide><path>curriculum/challenges/english/01-responsive-web-design/applied-visual-design/change-an-elements-relative-position.english.md <ide> forumTopicId: 301044 <ide> <ide> ## Description <ide> <section id='description'> <del>CSS treats each HTML element as its own box, which is usually referred to as the <code>CSS Box Model</code>. Block-level items automatically start on a new line (think headings, paragraphs, and divs) while inline items sit within surrounding content (like images or spans). The default layout of elements in this way is called the <code>normal flow</code> of a document, but CSS offers the position property to override it. <add>CSS treats each HTML element as its own box, which is usually referred to as the <dfn>CSS Box Model</dfn>. Block-level items automatically start on a new line (think headings, paragraphs, and divs) while inline items sit within surrounding content (like images or spans). The default layout of elements in this way is called the <dfn>normal flow</dfn> of a document, but CSS offers the position property to override it. <ide> When the position of an element is set to <code>relative</code>, it allows you to specify how CSS should move it <i>relative</i> to its current position in the normal flow of the page. It pairs with the CSS offset properties of <code>left</code> or <code>right</code>, and <code>top</code> or <code>bottom</code>. These say how many pixels, percentages, or ems to move the item <i>away</i> from where it is normally positioned. The following example moves the paragraph 10 pixels away from the bottom: <ide> <ide> ```css <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/create-a-custom-css-variable.english.md <ide> forumTopicId: 301086 <ide> <ide> ## Description <ide> <section id='description'> <del>To create a CSS variable, you just need to give it a <code>name</code> with <code>two dashes</code> in front of it and assign it a <code>value</code> like this: <add>To create a CSS variable, you just need to give it a name with two dashes in front of it and assign it a value like this: <ide> <ide> ```css <ide> --penguin-skin: gray; <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/override-class-declarations-with-inline-styles.english.md <ide> There are other ways that you can override CSS. Do you remember inline styles? <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use an <code>inline style</code> to try to make our <code>h1</code> element white. Remember, in line styles look like this: <add>Use an inline style to try to make our <code>h1</code> element white. Remember, in line styles look like this: <ide> <code>&#60;h1 style="color: green;"&#62;</code> <ide> Leave the <code>blue-text</code> and <code>pink-text</code> classes on your <code>h1</code> element. <ide> </section> <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/use-clockwise-notation-to-specify-the-margin-of-an-element.english.md <ide> These four values work like a clock: top, right, bottom, left, and will produce <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use <code>Clockwise Notation</code> to give the element with the <code>blue-box</code> class a margin of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side. <add>Use Clockwise Notation to give the element with the <code>blue-box</code> class a margin of <code>40px</code> on its top and left side, but only <code>20px</code> on its bottom and right side. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/use-css-selectors-to-style-elements.english.md <ide> forumTopicId: 18349 <ide> <ide> ## Description <ide> <section id='description'> <del>With CSS, there are hundreds of CSS <code>properties</code> that you can use to change the way an element looks on your page. <del>When you entered <code>&#60;h2 style="color: red;"&#62;CatPhotoApp&#60;/h2&#62;</code>, you were styling that individual <code>h2</code> element with <code>inline CSS</code>, which stands for <code>Cascading Style Sheets</code>. <del>That's one way to specify the style of an element, but there's a better way to apply <code>CSS</code>. <add>With CSS, there are hundreds of CSS properties that you can use to change the way an element looks on your page. <add>When you entered <code>&#60;h2 style="color: red;"&#62;CatPhotoApp&#60;/h2&#62;</code>, you were styling that individual <code>h2</code> element with inline CSS, which stands for Cascading Style Sheets. <add>That's one way to specify the style of an element, but there's a better way to apply CSS. <ide> At the top of your code, create a <code>style</code> block like this: <ide> <ide> ```html <ide> <style> <ide> </style> <ide> ``` <ide> <del>Inside that style block, you can create a <code>CSS selector</code> for all <code>h2</code> elements. For example, if you wanted all <code>h2</code> elements to be red, you would add a style rule that looks like this: <add>Inside that style block, you can create a <dfn>CSS selector</dfn> for all <code>h2</code> elements. For example, if you wanted all <code>h2</code> elements to be red, you would add a style rule that looks like this: <ide> <ide> ```html <ide> <style> <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-css/use-hex-code-for-specific-colors.english.md <ide> forumTopicId: 18350 <ide> <ide> ## Description <ide> <section id='description'> <del>Did you know there are other ways to represent colors in CSS? One of these ways is called hexadecimal code, or <code>hex code</code> for short. <del>We usually use <code>decimals</code>, or base 10 numbers, which use the symbols 0 to 9 for each digit. <code>Hexadecimals</code> (or <code>hex</code>) are base 16 numbers. This means it uses sixteen distinct symbols. Like decimals, the symbols 0-9 represent the values zero to nine. Then A,B,C,D,E,F represent the values ten to fifteen. Altogether, 0 to F can represent a digit in <code>hexadecimal</code>, giving us 16 total possible values. You can find more information about <a target='_blank' href='https://en.wikipedia.org/wiki/Hexadecimal'>hexadecimal numbers here</a>. <add>Did you know there are other ways to represent colors in CSS? One of these ways is called hexadecimal code, or hex code for short. <add>We usually use <dfn>decimals</dfn>, or base 10 numbers, which use the symbols 0 to 9 for each digit. <dfn>Hexadecimals</dfn> (or <dfn>hex</dfn>) are base 16 numbers. This means it uses sixteen distinct symbols. Like decimals, the symbols 0-9 represent the values zero to nine. Then A,B,C,D,E,F represent the values ten to fifteen. Altogether, 0 to F can represent a digit in hexadecimal, giving us 16 total possible values. You can find more information about <a target='_blank' href='https://en.wikipedia.org/wiki/Hexadecimal'>hexadecimal numbers here</a>. <ide> In CSS, we can use 6 hexadecimal digits to represent colors, two each for the red (R), green (G), and blue (B) components. For example, <code>#000000</code> is black and is also the lowest possible value. You can find more information about the <a target='_blank' href='https://en.wikipedia.org/wiki/RGB_color_model'>RGB color system here</a>. <ide> <ide> ```css <ide> body { <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Replace the word <code>black</code> in our <code>body</code> element's background-color with its <code>hex code</code> representation, <code>#000000</code>. <add>Replace the word <code>black</code> in our <code>body</code> element's background-color with its hex code representation, <code>#000000</code>. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/check-radio-buttons-and-checkboxes-by-default.english.md <ide> To do this, just add the word "checked" to the inside of an input element. For e <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Set the first of your <code>radio button</code>s and the first of your <code>checkbox</code>es to both be checked by default. <add>Set the first of your radio buttons and the first of your checkboxes to both be checked by default. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/create-a-bulleted-unordered-list.english.md <ide> forumTopicId: 16814 <ide> <ide> ## Description <ide> <section id='description'> <del>HTML has a special element for creating <code>unordered lists</code>, or bullet point style lists. <add>HTML has a special element for creating <dfn>unordered lists</dfn>, or bullet point style lists. <ide> Unordered lists start with an opening <code>&#60;ul&#62;</code> element, followed by any number of <code>&#60;li&#62;</code> elements. Finally, unordered lists close with a <code>&#60;/ul&#62;</code> <ide> For example: <ide> <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/create-a-set-of-checkboxes.english.md <ide> forumTopicId: 16821 <ide> <ide> ## Description <ide> <section id='description'> <del>Forms commonly use <code>checkboxes</code> for questions that may have more than one answer. <add>Forms commonly use <dfn>checkboxes</dfn> for questions that may have more than one answer. <ide> Checkboxes are a type of <code>input</code>. <ide> Each of your checkboxes can be nested within its own <code>label</code> element. By wrapping an <code>input</code> element inside of a <code>label</code> element it will automatically associate the checkbox input with the label element surrounding it. <ide> All related checkbox inputs should have the same <code>name</code> attribute. <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/create-a-set-of-radio-buttons.english.md <ide> forumTopicId: 16822 <ide> <ide> ## Description <ide> <section id='description'> <del>You can use <code>radio button</code>s for questions where you want the user to only give you one answer out of multiple options. <add>You can use <dfn>radio buttons</dfn> for questions where you want the user to only give you one answer out of multiple options. <ide> Radio buttons are a type of <code>input</code>. <ide> Each of your radio buttons can be nested within its own <code>label</code> element. By wrapping an <code>input</code> element inside of a <code>label</code> element it will automatically associate the radio button input with the label element surrounding it. <ide> All related radio buttons should have the same <code>name</code> attribute to create a radio button group. By creating a radio group, selecting any single radio button will automatically deselect the other buttons within the same group ensuring only one answer is provided by the user. <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/create-an-ordered-list.english.md <ide> forumTopicId: 16824 <ide> <ide> ## Description <ide> <section id='description'> <del>HTML has another special element for creating <code>ordered lists</code>, or numbered lists. <add>HTML has another special element for creating <dfn>ordered lists</dfn>, or numbered lists. <ide> Ordered lists start with an opening <code>&#60;ol&#62;</code> element, followed by any number of <code>&#60;li&#62;</code> elements. Finally, ordered lists are closed with the <code>&#60;/ol&#62;</code> tag. <ide> <ide> For example: <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/fill-in-the-blank-with-placeholder-text.english.md <ide> forumTopicId: 18178 <ide> <ide> ## Description <ide> <section id='description'> <del>Web developers traditionally use <code>lorem ipsum text</code> as placeholder text. The 'lorem ipsum' text is randomly scraped from a famous passage by Cicero of Ancient Rome. <add>Web developers traditionally use <dfn>lorem ipsum text</dfn> as placeholder text. The lorem ipsum text is randomly scraped from a famous passage by Cicero of Ancient Rome. <ide> Lorem ipsum text has been used as placeholder text by typesetters since the 16th century, and this tradition continues on the web. <del>Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called <code>kitty ipsum text</code>. <add>Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called "kitty ipsum text". <ide> </section> <ide> <ide> ## Instructions <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/headline-with-the-h2-element.english.md <ide> This element tells the browser about the structure of your website. <code>h1</co <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add an <code>h2</code> tag that says "CatPhotoApp" to create a second HTML <code>element</code> below your "Hello World" <code>h1</code> element. <add>Add an <code>h2</code> tag that says "CatPhotoApp" to create a second HTML element below your "Hello World" <code>h1</code> element. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/link-to-external-pages-with-anchor-elements.english.md <ide> Then your browser will display the text <strong>"this links to freecodecamp.org" <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create an <code>a</code> element that links to <code>http://freecatphotoapp.com</code> and has "cat photos" as its <code>anchor text</code>. <add>Create an <code>a</code> element that links to <code>http://freecatphotoapp.com</code> and has "cat photos" as its anchor text. <ide> </section> <ide> <ide> ## Tests <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: Your <code>a</code> element should have the <code>anchor text</code> of "cat photos". <add> - text: Your <code>a</code> element should have the anchor text of "cat photos". <ide> testString: assert((/cat photos/gi).test($("a").text())); <ide> - text: You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code> <ide> testString: assert(/http:\/\/(www\.)?freecatphotoapp\.com/gi.test($("a").attr("href"))); <ide><path>curriculum/challenges/english/01-responsive-web-design/basic-html-and-html5/say-hello-to-html-elements.english.md <ide> forumTopicId: 18276 <ide> ## Description <ide> <section id='description'> <ide> Welcome to freeCodeCamp's HTML coding challenges. These will walk you through web development step-by-step. <del>First, you'll start by building a simple web page using HTML. You can edit <code>code</code> in your <code>code editor</code>, which is embedded into this web page. <del>Do you see the code in your code editor that says <code>&#60;h1&#62;Hello&#60;/h1&#62;</code>? That's an HTML <code>element</code>. <del>Most HTML elements have an <code>opening tag</code> and a <code>closing tag</code>. <add>First, you'll start by building a simple web page using HTML. You can edit code in your code editor, which is embedded into this web page. <add>Do you see the code in your code editor that says <code>&#60;h1&#62;Hello&#60;/h1&#62;</code>? That's an HTML element. <add>Most HTML elements have an opening tag and a closing tag. <ide> Opening tags look like this: <ide> <code>&#60;h1&#62;</code> <ide> Closing tags look like this: <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.english.md <ide> forumTopicId: 16158 <ide> <ide> ## Description <ide> <section id='description'> <del>We can access the data inside arrays using <code>indexes</code>. <add>We can access the data inside arrays using <dfn>indexes</dfn>. <ide> Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array. Like strings, arrays use <dfn>zero-based</dfn> indexing, so the first element in an array is element <code>0</code>. <ide> <br /> <ide> <strong>Example</strong> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator.english.md <ide> forumTopicId: 16784 <ide> <ide> ## Description <ide> <section id='description'> <del>There are many <dfn>Comparison Operators</dfn> in JavaScript. All of these operators return a boolean <code>true</code> or <code>false</code> value. <del>The most basic operator is the equality operator <code>==</code>. The equality operator compares two values and returns <code>true</code> if they're equivalent or <code>false</code> if they are not. Note that equality is different from assignment (<code>=</code>), which assigns the value at the right of the operator to a variable on the left. <add>There are many <dfn>comparison operators</dfn> in JavaScript. All of these operators return a boolean <code>true</code> or <code>false</code> value. <add>The most basic operator is the equality operator <code>==</code>. The equality operator compares two values and returns <code>true</code> if they're equivalent or <code>false</code> if they are not. Note that equality is different from assignment (<code>=</code>), which assigns the value at the right of the operator to a variable in the left. <ide> <ide> ```js <ide> function equalityTest(myVal) { <ide> function equalityTest(myVal) { <ide> ``` <ide> <ide> If <code>myVal</code> is equal to <code>10</code>, the equality operator returns <code>true</code>, so the code in the curly braces will execute, and the function will return <code>"Equal"</code>. Otherwise, the function will return <code>"Not Equal"</code>. <del>In order for JavaScript to compare two different <code>data types</code> (for example, <code>numbers</code> and <code>strings</code>), it must convert one type to another. This is known as "Type Coercion". Once it does, however, it can compare terms as follows: <add>In order for JavaScript to compare two different <dfn>data types</dfn> (for example, <code>numbers</code> and <code>strings</code>), it must convert one type to another. This is known as "Type Coercion". Once it does, however, it can compare terms as follows: <ide> <ide> ```js <ide> 1 == 1 // true <ide> In order for JavaScript to compare two different <code>data types</code> (for ex <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>equality operator</code> to the indicated line so that the function will return "Equal" when <code>val</code> is equivalent to <code>12</code>. <add>Add the equality operator to the indicated line so that the function will return "Equal" when <code>val</code> is equivalent to <code>12</code>. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-operator.english.md <ide> Like the equality operator, greater than operator will convert data types of val <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>greater than</code> operator to the indicated lines so that the return statements make sense. <add>Add the greater than operator to the indicated lines so that the return statements make sense. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-greater-than-or-equal-to-operator.english.md <ide> forumTopicId: 16785 <ide> <ide> ## Description <ide> <section id='description'> <del>The <code>greater than or equal to</code> operator (<code>&gt;=</code>) compares the values of two numbers. If the number to the left is greater than or equal to the number to the right, it returns <code>true</code>. Otherwise, it returns <code>false</code>. <add>The greater than or equal to operator (<code>&gt;=</code>) compares the values of two numbers. If the number to the left is greater than or equal to the number to the right, it returns <code>true</code>. Otherwise, it returns <code>false</code>. <ide> Like the equality operator, <code>greater than or equal to</code> operator will convert data types while comparing. <ide> <strong>Examples</strong> <ide> <ide> Like the equality operator, <code>greater than or equal to</code> operator will <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>greater than or equal to</code> operator to the indicated lines so that the return statements make sense. <add>Add the greater than or equal to operator to the indicated lines so that the return statements make sense. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-operator.english.md <ide> The <dfn>less than</dfn> operator (<code>&lt;</code>) compares the values of two <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>less than</code> operator to the indicated lines so that the return statements make sense. <add>Add the less than operator to the indicated lines so that the return statements make sense. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-less-than-or-equal-to-operator.english.md <ide> forumTopicId: 16788 <ide> <ide> ## Description <ide> <section id='description'> <del>The <code>less than or equal to</code> operator (<code>&lt;=</code>) compares the values of two numbers. If the number to the left is less than or equal to the number to the right, it returns <code>true</code>. If the number on the left is greater than the number on the right, it returns <code>false</code>. Like the equality operator, <code>less than or equal to</code> converts data types. <add>The less than or equal to operator (<code>&lt;=</code>) compares the values of two numbers. If the number to the left is less than or equal to the number to the right, it returns <code>true</code>. If the number on the left is greater than the number on the right, it returns <code>false</code>. Like the equality operator, <code>less than or equal to</code> converts data types. <ide> <strong>Examples</strong> <ide> <ide> ```js <ide> The <code>less than or equal to</code> operator (<code>&lt;=</code>) compares th <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>less than or equal to</code> operator to the indicated lines so that the return statements make sense. <add>Add the less than or equal to operator to the indicated lines so that the return statements make sense. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-strict-inequality-operator.english.md <ide> The strict inequality operator (<code>!==</code>) is the logical opposite of the <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Add the <code>strict inequality operator</code> to the <code>if</code> statement so the function will return "Not Equal" when <code>val</code> is not strictly equal to <code>17</code> <add>Add the strict inequality operator to the <code>if</code> statement so the function will return "Not Equal" when <code>val</code> is not strictly equal to <code>17</code> <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-for-loops.english.md <ide> forumTopicId: 18219 <ide> ## Description <ide> <section id='description'> <ide> You can run the same code multiple times by using a loop. <del>The most common type of JavaScript loop is called a <code>for loop</code> because it runs "for" a specific number of times. <add>The most common type of JavaScript loop is called a <code>for</code> loop because it runs "for" a specific number of times. <ide> For loops are declared with three optional expressions separated by semicolons: <ide> <code>for ([initialization]; [condition]; [final-expression])</code> <ide> The <code>initialization</code> statement is executed one time only before the loop starts. It is typically used to define and setup your loop variable. <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/nest-one-array-within-another-array.english.md <ide> forumTopicId: 18247 <ide> <ide> ## Description <ide> <section id='description'> <del>You can also nest arrays within other arrays, like this: <code>[["Bulls", 23], ["White Sox", 45]]</code>. This is also called a <dfn>Multi-dimensional Array<dfn>. <add>You can also nest arrays within other arrays, like this: <code>[["Bulls", 23], ["White Sox", 45]]</code>. This is also called a <dfn>multi-dimensional arrray<dfn>. <ide> </section> <ide> <ide> ## Instructions <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/practice-comparing-different-values.english.md <ide> typeof '3' // returns 'string' <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>The <code>compareEquality</code> function in the editor compares two values using the <code>equality operator</code>. Modify the function so that it returns "Equal" only when the values are strictly equal. <add>The <code>compareEquality</code> function in the editor compares two values using the equality operator. Modify the function so that it returns "Equal" only when the values are strictly equal. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-first-character-in-a-string.english.md <ide> forumTopicId: 18341 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Bracket notation</code> is a way to get a character at a specific <code>index</code> within a string. <add><dfn>Bracket notation</dfn> is a way to get a character at a specific <code>index</code> within a string. <ide> Most modern programming languages, like JavaScript, don't start counting at 1 like humans do. They start at 0. This is referred to as <dfn>Zero-based</dfn> indexing. <ide> For example, the character at index 0 in the word "Charles" is "C". So if <code>var firstName = "Charles"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use <dfn>bracket notation</dfn> to find the first character in the <code>lastName</code> variable and assign it to <code>firstLetterOfLastName</code>. <add>Use bracket notation to find the first character in the <code>lastName</code> variable and assign it to <code>firstLetterOfLastName</code>. <ide> <strong>Hint</strong><br>Try looking at the <code>firstLetterOfFirstName</code> variable declaration if you get stuck. <ide> </section> <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/use-multiple-conditional-ternary-operators.english.md <ide> forumTopicId: 301179 <ide> <ide> ## Description <ide> <section id='description'> <del>In the previous challenge, you used a single <code>conditional operator</code>. You can also chain them together to check for multiple conditions. <add>In the previous challenge, you used a single conditional operator. You can also chain them together to check for multiple conditions. <ide> The following function uses if, else if, and else statements to check multiple conditions: <ide> <ide> ```js <ide> function findGreaterOrEqual(a, b) { <ide> } <ide> ``` <ide> <del>The above function can be re-written using multiple <code>conditional operators</code>: <add>The above function can be re-written using multiple conditional operators: <ide> <ide> ```js <ide> function findGreaterOrEqual(a, b) { <ide> function findGreaterOrEqual(a, b) { <ide> } <ide> ``` <ide> <del>However, this should be used with care as using multiple <code>conditional operators</code> without proper indentation may make your code hard to read. For example: <add>However, this should be used with care as using multiple conditional operators without proper indentation may make your code hard to read. For example: <ide> <ide> ```js <ide> function findGreaterOrEqual(a, b) { <ide> function findGreaterOrEqual(a, b) { <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use multiple <code>conditional operators</code> in the <code>checkSign</code> function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero". <add>Use multiple conditional operators in the <code>checkSign</code> function to check if a number is positive, negative or zero. The function should return "positive", "negative" or "zero". <ide> </section> <ide> <ide> ## Tests <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: <code>checkSign</code> should use multiple <code>conditional operators</code> <add> - text: <code>checkSign</code> should use multiple conditional operators <ide> testString: assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code)); <ide> - text: <code>checkSign(10)</code> should return "positive". Note that capitalization matters <ide> testString: assert(checkSign(10) === 'positive'); <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/catch-off-by-one-errors-when-using-indexing.english.md <ide> forumTopicId: 301189 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Off by one errors</code> (sometimes called OBOE) crop up when you're trying to target a specific index of a string or array (to slice or access a segment), or when looping over the indices of them. JavaScript indexing starts at zero, not one, which means the last index is always one less than the length of the item. If you try to access an index equal to the length, the program may throw an "index out of range" reference error or print <code>undefined</code>. <add><dfn>Off by one errors</dfn> (sometimes called OBOE) crop up when you're trying to target a specific index of a string or array (to slice or access a segment), or when looping over the indices of them. JavaScript indexing starts at zero, not one, which means the last index is always one less than the length of the item. If you try to access an index equal to the length, the program may throw an "index out of range" reference error or print <code>undefined</code>. <ide> When you use string or array methods that take index ranges as arguments, it helps to read the documentation and understand if they are inclusive (the item at the given index is part of what's returned) or not. Here are some examples of off by one errors: <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/avoid-mutations-and-side-effects-using-functional-programming.english.md <ide> If you haven't already figured it out, the issue in the previous challenge was w <ide> This is a small example of a much larger pattern - you call a function on a variable, array, or an object, and the function changes the variable or something in the object. <ide> One of the core principles of functional programming is to not change things. Changes lead to bugs. It's easier to prevent bugs knowing that your functions don't change anything, including the function arguments or any global variable. <ide> The previous example didn't have any complicated operations but the <code>splice</code> method changed the original array, and resulted in a bug. <del>Recall that in functional programming, changing or altering things is called <code>mutation</code>, and the outcome is called a <code>side effect</code>. A function, ideally, should be a <code>pure function</code>, meaning that it does not cause any side effects. <add>Recall that in functional programming, changing or altering things is called <dfn>mutation</dfn>, and the outcome is called a <dfn>side effect</dfn>. A function, ideally, should be a <dfn>pure function</dfn>, meaning that it does not cause any side effects. <ide> Let's try to master this discipline and not alter any variable or object in our code. <ide> </section> <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/combine-two-arrays-using-the-concat-method.english.md <ide> forumTopicId: 301229 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Concatenation</code> means to join items end to end. JavaScript offers the <code>concat</code> method for both strings and arrays that work in the same way. For arrays, the method is called on one, then another array is provided as the argument to <code>concat</code>, which is added to the end of the first array. It returns a new array and does not mutate either of the original arrays. Here's an example: <add><dfn>Concatenation</dfn> means to join items end to end. JavaScript offers the <code>concat</code> method for both strings and arrays that work in the same way. For arrays, the method is called on one, then another array is provided as the argument to <code>concat</code>, which is added to the end of the first array. It returns a new array and does not mutate either of the original arrays. Here's an example: <ide> <ide> ```js <ide> [1, 2, 3].concat([4, 5, 6]); <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/introduction-to-currying-and-partial-application.english.md <ide> forumTopicId: 301232 <ide> <ide> ## Description <ide> <section id='description'> <del>The <code>arity</code> of a function is the number of arguments it requires. <code>Currying</code> a function means to convert a function of N <code>arity</code> into N functions of <code>arity</code> 1. <add>The <dfn>arity</dfn> of a function is the number of arguments it requires. <dfn>Currying</dfn> a function means to convert a function of N arity into N functions of arity 1. <ide> In other words, it restructures a function so it takes one argument, then returns another function that takes the next argument, and so on. <ide> Here's an example: <ide> <ide> const curried = x => y => x + y <ide> curried(1)(2) // Returns 3 <ide> ``` <ide> <del>This is useful in your program if you can't supply all the arguments to a function at one time. You can save each function call into a variable, which will hold the returned function reference that takes the next argument when it's available. Here's an example using the <code>curried</code> function in the example above: <add>This is useful in your program if you can't supply all the arguments to a function at one time. You can save each function call into a variable, which will hold the returned function reference that takes the next argument when it's available. Here's an example using the curried function in the example above: <ide> <ide> ```js <ide> // Call a curried function in parts: <ide> var funcForY = curried(1); <ide> console.log(funcForY(2)); // Prints 3 <ide> ``` <ide> <del>Similarly, <code>partial application</code> can be described as applying a few arguments to a function at a time and returning another function that is applied to more arguments. <add>Similarly, <dfn>partial application</dfn> can be described as applying a few arguments to a function at a time and returning another function that is applied to more arguments. <ide> Here's an example: <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/understand-functional-programming-terminology.english.md <ide> forumTopicId: 301240 <ide> The FCC Team had a mood swing and now wants two types of tea: green tea and black tea. General Fact: Client mood swings are pretty common. <ide> With that information, we'll need to revisit the <code>getTea</code> function from last challenge to handle various tea requests. We can modify <code>getTea</code> to accept a function as a parameter to be able to change the type of tea it prepares. This makes <code>getTea</code> more flexible, and gives the programmer more control when client requests change. <ide> But first, let's cover some functional terminology: <del><code>Callbacks</code> are the functions that are slipped or passed into another function to decide the invocation of that function. You may have seen them passed to other methods, for example in <code>filter</code>, the callback function tells JavaScript the criteria for how to filter an array. <del>Functions that can be assigned to a variable, passed into another function, or returned from another function just like any other normal value, are called <code>first class</code> functions. In JavaScript, all functions are <code>first class</code> functions. <del>The functions that take a function as an argument, or return a function as a return value are called <code>higher order</code> functions. <del>When the functions are passed in to another function or returned from another function, then those functions which gets passed in or returned can be called a <code>lambda</code>. <add><dfn>Callbacks</dfn> are the functions that are slipped or passed into another function to decide the invocation of that function. You may have seen them passed to other methods, for example in <code>filter</code>, the callback function tells JavaScript the criteria for how to filter an array. <add>Functions that can be assigned to a variable, passed into another function, or returned from another function just like any other normal value, are called <dfn>first class</dfn> functions. In JavaScript, all functions are first class functions. <add>The functions that take a function as an argument, or return a function as a return value are called <dfn>higher order</dfn> functions. <add>When the functions are passed in to another function or returned from another function, then those functions which gets passed in or returned can be called a <dfn>lambda</dfn>. <ide> </section> <ide> <ide> ## Instructions <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/functional-programming/use-the-map-method-to-extract-data-from-an-array.english.md <ide> forumTopicId: 18214 <ide> <section id='description'> <ide> So far we have learned to use pure functions to avoid side effects in a program. Also, we have seen the value in having a function only depend on its input arguments. <ide> This is only the beginning. As its name suggests, functional programming is centered around a theory of functions. <del>It would make sense to be able to pass them as arguments to other functions, and return a function from another function. Functions are considered <code>First Class Objects</code> in JavaScript, which means they can be used like any other object. They can be saved in variables, stored in an object, or passed as function arguments. <add>It would make sense to be able to pass them as arguments to other functions, and return a function from another function. Functions are considered <dfn>first class objects</dfn> in JavaScript, which means they can be used like any other object. They can be saved in variables, stored in an object, or passed as function arguments. <ide> Let's start with some simple array functions, which are methods on the array object prototype. In this exercise we are looking at <code>Array.prototype.map()</code>, or more simply <code>map</code>. <ide> Remember that the <code>map</code> method is a way to iterate over each item in an array. It creates a new array (without changing the original one) after applying a callback function to every element. <ide> </section> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher.english.md <ide> forumTopicId: 16003 <ide> <ide> ## Description <ide> <section id='description'> <del>One of the simplest and most widely known <dfn>ciphers</dfn> is a <code>Caesar cipher</code>, also known as a <code>shift cipher</code>. In a <code>shift cipher</code> the meanings of the letters are shifted by some set amount. <add>One of the simplest and most widely known <dfn>ciphers</dfn> is a <dfn>Caesar cipher</dfn>, also known as a <dfn>shift cipher</dfn>. In a shift cipher the meanings of the letters are shifted by some set amount. <ide> A common modern use is the <a href="https://en.wikipedia.org/wiki/ROT13" target='_blank'>ROT13</a> cipher, where the values of the letters are shifted by 13 places. Thus 'A' &harr; 'N', 'B' &harr; 'O' and so on. <ide> Write a function which takes a <a href="https://en.wikipedia.org/wiki/ROT13" target='_blank'>ROT13</a> encoded string as input and returns a decoded string. <ide> All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on. <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/add-methods-after-inheritance.english.md <ide> forumTopicId: 301315 <ide> <ide> ## Description <ide> <section id='description'> <del>A constructor function that inherits its <code>prototype</code> object from a <code>supertype</code> constructor function can still have its own methods in addition to inherited methods. <add>A constructor function that inherits its <code>prototype</code> object from a supertype constructor function can still have its own methods in addition to inherited methods. <ide> For example, <code>Bird</code> is a constructor that inherits its <code>prototype</code> from <code>Animal</code>: <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/create-a-basic-javascript-object.english.md <ide> forumTopicId: 301317 <ide> <ide> ## Description <ide> <section id='description'> <del>Think about things people see everyday, like cars, shops, and birds. These are all <code>objects</code>: tangible things people can observe and interact with. <del>What are some qualities of these <code>objects</code>? A car has wheels. Shops sell items. Birds have wings. <del>These qualities, or <code>properties</code>, define what makes up an <code>object</code>. Note that similar <code>objects</code> share the same <code>properties</code>, but may have different values for those <code>properties</code>. For example, all cars have wheels, but not all cars have the same number of wheels. <del><code>Objects</code> in JavaScript are used to model real-world objects, giving them <code>properties</code> and behavior just like their real-world counterparts. Here's an example using these concepts to create a <code>duck</code> <code>object</code>: <add>Think about things people see everyday, like cars, shops, and birds. These are all <dfn>objects</dfn>: tangible things people can observe and interact with. <add>What are some qualities of these objects? A car has wheels. Shops sell items. Birds have wings. <add>These qualities, or <dfn>properties</dfn>, define what makes up an object. Note that similar objects share the same properties, but may have different values for those properties. For example, all cars have wheels, but not all cars have the same number of wheels. <add>Objects in JavaScript are used to model real-world objects, giving them properties and behavior just like their real-world counterparts. Here's an example using these concepts to create a <code>duck</code> object: <ide> <ide> ```js <ide> let duck = { <ide> let duck = { <ide> }; <ide> ``` <ide> <del>This <code>duck</code> <code>object</code> has two property/value pairs: a <code>name</code> of "Aflac" and a <code>numLegs</code> of 2. <add>This <code>duck</code> object has two property/value pairs: a <code>name</code> of "Aflac" and a <code>numLegs</code> of 2. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create a <code>dog</code> <code>object</code> with <code>name</code> and <code>numLegs</code> properties, and set them to a string and a number, respectively. <add>Create a <code>dog</code> object with <code>name</code> and <code>numLegs</code> properties, and set them to a string and a number, respectively. <ide> </section> <ide> <ide> ## Tests <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: <code>dog</code> should be an <code>object</code>. <add> - text: <code>dog</code> should be an object. <ide> testString: assert(typeof(dog) === 'object'); <ide> - text: <code>dog</code> should have a <code>name</code> property set to a <code>string</code>. <ide> testString: assert(typeof(dog.name) === 'string'); <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/create-a-method-on-an-object.english.md <ide> forumTopicId: 301318 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Objects</code> can have a special type of <code>property</code>, called a <code>method</code>. <del><code>Methods</code> are <code>properties</code> that are functions. This adds different behavior to an <code>object</code>. Here is the <code>duck</code> example with a method: <add>Objects can have a special type of property, called a <dfn>method</dfn>. <add>Methods are properties that are functions. This adds different behavior to an object. Here is the <code>duck</code> example with a method: <ide> <ide> ```js <ide> let duck = { <ide> duck.sayName(); <ide> // Returns "The name of this duck is Aflac." <ide> ``` <ide> <del>The example adds the <code>sayName</code> <code>method</code>, which is a function that returns a sentence giving the name of the <code>duck</code>. <del>Notice that the <code>method</code> accessed the <code>name</code> property in the return statement using <code>duck.name</code>. The next challenge will cover another way to do this. <add>The example adds the <code>sayName</code> method, which is a function that returns a sentence giving the name of the <code>duck</code>. <add>Notice that the method accessed the <code>name</code> property in the return statement using <code>duck.name</code>. The next challenge will cover another way to do this. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Using the <code>dog</code> <code>object</code>, give it a method called <code>sayLegs</code>. The method should return the sentence "This dog has 4 legs." <add>Using the <code>dog</code> object, give it a method called <code>sayLegs</code>. The method should return the sentence "This dog has 4 legs." <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/define-a-constructor-function.english.md <ide> forumTopicId: 16804 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Constructors</code> are functions that create new objects. They define properties and behaviors that will belong to the new object. Think of them as a blueprint for the creation of new objects. <del>Here is an example of a <code>constructor</code>: <add><dfn>Constructors</dfn> are functions that create new objects. They define properties and behaviors that will belong to the new object. Think of them as a blueprint for the creation of new objects. <add>Here is an example of a constructor: <ide> <ide> ```js <ide> function Bird() { <ide> function Bird() { <ide> } <ide> ``` <ide> <del>This <code>constructor</code> defines a <code>Bird</code> object with properties <code>name</code>, <code>color</code>, and <code>numLegs</code> set to Albert, blue, and 2, respectively. <del><code>Constructors</code> follow a few conventions: <del><ul><li><code>Constructors</code> are defined with a capitalized name to distinguish them from other functions that are not <code>constructors</code>.</li><li><code>Constructors</code> use the keyword <code>this</code> to set properties of the object they will create. Inside the <code>constructor</code>, <code>this</code> refers to the new object it will create.</li><li><code>Constructors</code> define properties and behaviors instead of returning a value as other functions might.</li></ul> <add>This constructor defines a <code>Bird</code> object with properties <code>name</code>, <code>color</code>, and <code>numLegs</code> set to Albert, blue, and 2, respectively. <add>Constructors follow a few conventions: <add><ul><li>Constructors are defined with a capitalized name to distinguish them from other functions that are not <code>constructors</code>.</li><li>Constructors use the keyword <code>this</code> to set properties of the object they will create. Inside the constructor, <code>this</code> refers to the new object it will create.</li><li>Constructors define properties and behaviors instead of returning a value as other functions might.</li></ul> <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create a <code>constructor</code>, <code>Dog</code>, with properties <code>name</code>, <code>color</code>, and <code>numLegs</code> that are set to a string, a string, and a number, respectively. <add>Create a constructor, <code>Dog</code>, with properties <code>name</code>, <code>color</code>, and <code>numLegs</code> that are set to a string, a string, and a number, respectively. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/inherit-behaviors-from-a-supertype.english.md <ide> Animal.prototype.eat = function() { <ide> }; <ide> ``` <ide> <del>This and the next challenge will cover how to reuse <code>Animal's</code> methods inside <code>Bird</code> and <code>Dog</code> without defining them again. It uses a technique called <code>inheritance</code>. <add>This and the next challenge will cover how to reuse <code>Animal's</code> methods inside <code>Bird</code> and <code>Dog</code> without defining them again. It uses a technique called inheritance. <ide> This challenge covers the first step: make an instance of the <code>supertype</code> (or parent). <ide> You already know one way to create an instance of <code>Animal</code> using the <code>new</code> operator: <ide> <ide> ```js <ide> let animal = new Animal(); <ide> ``` <ide> <del>There are some disadvantages when using this syntax for <code>inheritance</code>, which are too complex for the scope of this challenge. Instead, here's an alternative approach without those disadvantages: <add>There are some disadvantages when using this syntax for inheritance, which are too complex for the scope of this challenge. Instead, here's an alternative approach without those disadvantages: <ide> <ide> ```js <ide> let animal = Object.create(Animal.prototype); <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/make-code-more-reusable-with-the-this-keyword.english.md <ide> forumTopicId: 301321 <ide> <ide> ## Description <ide> <section id='description'> <del>The last challenge introduced a <code>method</code> to the <code>duck</code> object. It used <code>duck.name</code> dot notation to access the value for the <code>name</code> property within the return statement: <add>The last challenge introduced a method to the <code>duck</code> object. It used <code>duck.name</code> dot notation to access the value for the <code>name</code> property within the return statement: <ide> <code>sayName: function() {return "The name of this duck is " + duck.name + ".";}</code> <ide> While this is a valid way to access the object's property, there is a pitfall here. If the variable name changes, any code referencing the original name would need to be updated as well. In a short object definition, it isn't a problem, but if an object has many references to its properties there is a greater chance for error. <ide> A way to avoid these issues is with the <code>this</code> keyword: <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/reset-an-inherited-constructor-property.english.md <ide> forumTopicId: 301324 <ide> <ide> ## Description <ide> <section id='description'> <del>When an object inherits its <code>prototype</code> from another object, it also inherits the <code>supertype</code>'s constructor property. <add>When an object inherits its <code>prototype</code> from another object, it also inherits the supertype's constructor property. <ide> Here's an example: <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/set-the-childs-prototype-to-an-instance-of-the-parent.english.md <ide> forumTopicId: 301325 <ide> <ide> ## Description <ide> <section id='description'> <del>In the previous challenge you saw the first step for inheriting behavior from the <code>supertype</code> (or parent) <code>Animal</code>: making a new instance of <code>Animal</code>. <del>This challenge covers the next step: set the <code>prototype</code> of the <code>subtype</code> (or child)&mdash;in this case, <code>Bird</code>&mdash;to be an instance of <code>Animal</code>. <add>In the previous challenge you saw the first step for inheriting behavior from the supertype (or parent) <code>Animal</code>: making a new instance of <code>Animal</code>. <add>This challenge covers the next step: set the <code>prototype</code> of the subtype (or child)&mdash;in this case, <code>Bird</code>&mdash;to be an instance of <code>Animal</code>. <ide> <ide> ```js <ide> Bird.prototype = Object.create(Animal.prototype); <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/understand-the-immediately-invoked-function-expression-iife.english.md <ide> A common pattern in JavaScript is to execute a function as soon as it is declare <ide> // Outputs "Chirp, chirp!" immediately <ide> ``` <ide> <del>Note that the function has no name and is not stored in a variable. The two parentheses () at the end of the function expression cause it to be immediately executed or invoked. This pattern is known as an <code>immediately invoked function expression</code> or <code>IIFE</code>. <add>Note that the function has no name and is not stored in a variable. The two parentheses () at the end of the function expression cause it to be immediately executed or invoked. This pattern is known as an <dfn>immediately invoked function expression</dfn> or <dfn>IIFE</dfn>. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Rewrite the function <code>makeNest</code> and remove its call so instead it's an anonymous <code>immediately invoked function expression</code> (<code>IIFE</code>). <add>Rewrite the function <code>makeNest</code> and remove its call so instead it's an anonymous immediately invoked function expression (IIFE). <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-constructor-to-create-objects.english.md <ide> function Bird() { <ide> let blueBird = new Bird(); <ide> ``` <ide> <del>Notice that the <code>new</code> operator is used when calling a constructor. This tells JavaScript to create a new <code>instance</code> of <code>Bird</code> called <code>blueBird</code>. Without the <code>new</code> operator, <code>this</code> inside the constructor would not point to the newly created object, giving unexpected results. <add>Notice that the <code>new</code> operator is used when calling a constructor. This tells JavaScript to create a new instance of <code>Bird</code> called <code>blueBird</code>. Without the <code>new</code> operator, <code>this</code> inside the constructor would not point to the newly created object, giving unexpected results. <ide> Now <code>blueBird</code> has all the properties defined inside the <code>Bird</code> constructor: <ide> <ide> ```js <ide> Use the <code>Dog</code> constructor from the last lesson to create a new instan <ide> tests: <ide> - text: <code>hound</code> should be created using the <code>Dog</code> constructor. <ide> testString: assert(hound instanceof Dog); <del> - text: Your code should use the <code>new</code> operator to create an <code>instance</code> of <code>Dog</code>. <add> - text: Your code should use the <code>new</code> operator to create an instance of <code>Dog</code>. <ide> testString: assert(code.match(/new/g)); <ide> <ide> ``` <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-a-mixin-to-add-common-behavior-between-unrelated-objects.english.md <ide> forumTopicId: 301331 <ide> ## Description <ide> <section id='description'> <ide> As you have seen, behavior is shared through inheritance. However, there are cases when inheritance is not the best solution. Inheritance does not work well for unrelated objects like <code>Bird</code> and <code>Airplane</code>. They can both fly, but a <code>Bird</code> is not a type of <code>Airplane</code> and vice versa. <del>For unrelated objects, it's better to use <code>mixins</code>. A <code>mixin</code> allows other objects to use a collection of functions. <add>For unrelated objects, it's better to use <dfn>mixins</dfn>. A mixin allows other objects to use a collection of functions. <ide> <ide> ```js <ide> let flyMixin = function(obj) { <ide> bird.fly(); // prints "Flying, wooosh!" <ide> plane.fly(); // prints "Flying, wooosh!" <ide> ``` <ide> <del>Note how the <code>mixin</code> allows for the same <code>fly</code> method to be reused by unrelated objects <code>bird</code> and <code>plane</code>. <add>Note how the mixin allows for the same <code>fly</code> method to be reused by unrelated objects <code>bird</code> and <code>plane</code>. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create a <code>mixin</code> named <code>glideMixin</code> that defines a method named <code>glide</code>. Then use the <code>glideMixin</code> to give both <code>bird</code> and <code>boat</code> the ability to glide. <add>Create a mixin named <code>glideMixin</code> that defines a method named <code>glide</code>. Then use the <code>glideMixin</code> to give both <code>bird</code> and <code>boat</code> the ability to glide. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-an-iife-to-create-a-module.english.md <ide> forumTopicId: 301332 <ide> <ide> ## Description <ide> <section id='description'> <del>An <code>immediately invoked function expression</code> (<code>IIFE</code>) is often used to group related functionality into a single object or <code>module</code>. For example, an earlier challenge defined two mixins: <add>An immediately invoked function expression (IIFE) is often used to group related functionality into a single object or <dfn>module</dfn>. For example, an earlier challenge defined two mixins: <ide> <ide> ```js <ide> function glideMixin(obj) { <ide> function flyMixin(obj) { <ide> } <ide> ``` <ide> <del>We can group these <code>mixins</code> into a module as follows: <add>We can group these mixins into a module as follows: <ide> <ide> ```js <ide> let motionModule = (function () { <ide> let motionModule = (function () { <ide> })(); // The two parentheses cause the function to be immediately invoked <ide> ``` <ide> <del>Note that you have an <code>immediately invoked function expression</code> (<code>IIFE</code>) that returns an object <code>motionModule</code>. This returned object contains all of the <code>mixin</code> behaviors as properties of the object. <del>The advantage of the <code>module</code> pattern is that all of the motion behaviors can be packaged into a single object that can then be used by other parts of your code. Here is an example using it: <add>Note that you have an immediately invoked function expression (IIFE) that returns an object <code>motionModule</code>. This returned object contains all of the mixin behaviors as properties of the object. <add>The advantage of the module pattern is that all of the motion behaviors can be packaged into a single object that can then be used by other parts of your code. Here is an example using it: <ide> <ide> ```js <ide> motionModule.glideMixin(duck); <ide> duck.glide(); <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create a <code>module</code> named <code>funModule</code> to wrap the two <code>mixins</code> <code>isCuteMixin</code> and <code>singMixin</code>. <code>funModule</code> should return an object. <add>Create a module named <code>funModule</code> to wrap the two mixins <code>isCuteMixin</code> and <code>singMixin</code>. <code>funModule</code> should return an object. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-dot-notation-to-access-the-properties-of-an-object.english.md <ide> forumTopicId: 301333 <ide> <ide> ## Description <ide> <section id='description'> <del>The last challenge created an <code>object</code> with various <code>properties</code>, now you'll see how to access the values of those <code>properties</code>. Here's an example: <add>The last challenge created an object with various properties, now you'll see how to access the values of those properties. Here's an example: <ide> <ide> ```js <ide> let duck = { <ide> console.log(duck.name); <ide> // This prints "Aflac" to the console <ide> ``` <ide> <del>Dot notation is used on the <code>object</code> name, <code>duck</code>, followed by the name of the <code>property</code>, <code>name</code>, to access the value of "Aflac". <add>Dot notation is used on the object name, <code>duck</code>, followed by the name of the property, <code>name</code>, to access the value of "Aflac". <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Print both <code>properties</code> of the <code>dog</code> object to your console. <add>Print both properties of the <code>dog</code> object to your console. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/use-inheritance-so-you-dont-repeat-yourself.english.md <ide> forumTopicId: 301334 <ide> <ide> ## Description <ide> <section id='description'> <del>There's a principle in programming called <code>Don't Repeat Yourself (DRY)</code>. The reason repeated code is a problem is because any change requires fixing code in multiple places. This usually means more work for programmers and more room for errors. <add>There's a principle in programming called <dfn>Don't Repeat Yourself (DRY)</dfn>. The reason repeated code is a problem is because any change requires fixing code in multiple places. This usually means more work for programmers and more room for errors. <ide> Notice in the example below that the <code>describe</code> method is shared by <code>Bird</code> and <code>Dog</code>: <ide> <ide> ```js <ide> Dog.prototype = { <ide> }; <ide> ``` <ide> <del>The <code>describe</code> method is repeated in two places. The code can be edited to follow the <code>DRY</code> principle by creating a <code>supertype</code> (or parent) called <code>Animal</code>: <add>The <code>describe</code> method is repeated in two places. The code can be edited to follow the DRY principle by creating a <code>supertype</code> (or parent) called <code>Animal</code>: <ide> <ide> ```js <ide> function Animal() { }; <ide> Dog.prototype = { <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>The <code>eat</code> method is repeated in both <code>Cat</code> and <code>Bear</code>. Edit the code in the spirit of <code>DRY</code> by moving the <code>eat</code> method to the <code>Animal</code> <code>supertype</code>. <add>The <code>eat</code> method is repeated in both <code>Cat</code> and <code>Bear</code>. Edit the code in the spirit of DRY by moving the <code>eat</code> method to the <code>Animal</code> <code>supertype</code>. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/object-oriented-programming/verify-an-objects-constructor-with-instanceof.english.md <ide> forumTopicId: 301337 <ide> <ide> ## Description <ide> <section id='description'> <del>Anytime a constructor function creates a new object, that object is said to be an <code>instance</code> of its constructor. JavaScript gives a convenient way to verify this with the <code>instanceof</code> operator. <code>instanceof</code> allows you to compare an object to a constructor, returning <code>true</code> or <code>false</code> based on whether or not that object was created with the constructor. Here's an example: <add>Anytime a constructor function creates a new object, that object is said to be an <dfn>instance</dfn> of its constructor. JavaScript gives a convenient way to verify this with the <code>instanceof</code> operator. <code>instanceof</code> allows you to compare an object to a constructor, returning <code>true</code> or <code>false</code> based on whether or not that object was created with the constructor. Here's an example: <ide> <ide> ```js <ide> let Bird = function(name, color) { <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/find-characters-with-lazy-matching.english.md <ide> forumTopicId: 301341 <ide> <ide> ## Description <ide> <section id='description'> <del>In regular expressions, a <code>greedy</code> match finds the longest possible part of a string that fits the regex pattern and returns it as a match. The alternative is called a <code>lazy</code> match, which finds the smallest possible part of the string that satisfies the regex pattern. <add>In regular expressions, a <dfn>greedy</dfn> match finds the longest possible part of a string that fits the regex pattern and returns it as a match. The alternative is called a <dfn>lazy</dfn> match, which finds the smallest possible part of the string that satisfies the regex pattern. <ide> You can apply the regex <code>/t[a-z]*i/</code> to the string <code>"titanic"</code>. This regex is basically a pattern that starts with <code>t</code>, ends with <code>i</code>, and has some letters in between. <del>Regular expressions are by default <code>greedy</code>, so the match would return <code>["titani"]</code>. It finds the largest sub-string possible to fit the pattern. <del>However, you can use the <code>?</code> character to change it to <code>lazy</code> matching. <code>"titanic"</code> matched against the adjusted regex of <code>/t[a-z]*?i/</code> returns <code>["ti"]</code>. <add>Regular expressions are by default greedy, so the match would return <code>["titani"]</code>. It finds the largest sub-string possible to fit the pattern. <add>However, you can use the <code>?</code> character to change it to lazy matching. <code>"titanic"</code> matched against the adjusted regex of <code>/t[a-z]*?i/</code> returns <code>["ti"]</code>. <ide> <strong>Note</strong><br>Parsing HTML with regular expressions should be avoided, but pattern matching an HTML string with regular expressions is completely fine. <ide> </section> <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/find-one-or-more-criminals-in-a-hunt.english.md <ide> But it does not find matches in the following strings since there are no letter <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Write a <code>greedy</code> regex that finds one or more criminals within a group of other people. A criminal is represented by the capital letter <code>C</code>. <add>Write a greedy regex that finds one or more criminals within a group of other people. A criminal is represented by the capital letter <code>C</code>. <ide> </section> <ide> <ide> ## Tests <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: Your regex should match <code>one</code> criminal (<code>C</code>) in <code>"C"</code> <add> - text: Your regex should match one criminal (<code>C</code>) in <code>"C"</code> <ide> testString: assert('C'.match(reCriminals) && 'C'.match(reCriminals)[0] == 'C'); <del> - text: Your regex should match <code>two</code> criminals (<code>CC</code>) in <code>"CC"</code> <add> - text: Your regex should match two criminals (<code>CC</code>) in <code>"CC"</code> <ide> testString: assert('CC'.match(reCriminals) && 'CC'.match(reCriminals)[0] == 'CC'); <del> - text: Your regex should match <code>three</code> criminals (<code>CCC</code>) in <code>"P1P5P4CCCP2P6P3"</code> <add> - text: Your regex should match three criminals (<code>CCC</code>) in <code>"P1P5P4CCCP2P6P3"</code> <ide> testString: assert('P1P5P4CCCP2P6P3'.match(reCriminals) && 'P1P5P4CCCP2P6P3'.match(reCriminals)[0] == 'CCC'); <del> - text: Your regex should match <code>five</code> criminals (<code>CCCCC</code>) in <code>"P6P2P7P4P5CCCCCP3P1"</code> <add> - text: Your regex should match five criminals (<code>CCCCC</code>) in <code>"P6P2P7P4P5CCCCCP3P1"</code> <ide> testString: assert('P6P2P7P4P5CCCCCP3P1'.match(reCriminals) && 'P6P2P7P4P5CCCCCP3P1'.match(reCriminals)[0] == 'CCCCC'); <ide> - text: Your regex should not match any criminals in <code>""</code> <ide> testString: assert(!reCriminals.test('')); <ide> - text: Your regex should not match any criminals in <code>"P1P2P3"</code> <ide> testString: assert(!reCriminals.test('P1P2P3')); <del> - text: Your regex should match <code>fifty</code> criminals (<code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>) in <code>"P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3"</code>. <add> - text: Your regex should match fifty criminals (<code>CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC</code>) in <code>"P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3"</code>. <ide> testString: assert('P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals) && 'P2P1P5P4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCP3'.match(reCriminals)[0] == "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"); <ide> <ide> ``` <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers.english.md <ide> longHand.test(varNames); // Returns true <ide> shortHand.test(varNames); // Returns true <ide> ``` <ide> <del>These shortcut character classes are also known as <code>shorthand character classes</code>. <add>These shortcut character classes are also known as <dfn>shorthand character classes</dfn>. <ide> </section> <ide> <ide> ## Instructions <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-beginning-string-patterns.english.md <ide> forumTopicId: 301349 <ide> ## Description <ide> <section id='description'> <ide> Prior challenges showed that regular expressions can be used to look for a number of matches. They are also used to search for patterns in specific positions in strings. <del>In an earlier challenge, you used the <code>caret</code> character (<code>^</code>) inside a <code>character set</code> to create a <code>negated character set</code> in the form <code>[^thingsThatWillNotBeMatched]</code>. Outside of a <code>character set</code>, the <code>caret</code> is used to search for patterns at the beginning of strings. <add>In an earlier challenge, you used the caret character (<code>^</code>) inside a character set to create a negated character set in the form <code>[^thingsThatWillNotBeMatched]</code>. Outside of a character set, the caret is used to search for patterns at the beginning of strings. <ide> <ide> ```js <ide> let firstString = "Ricky is first and can be found."; <ide> firstRegex.test(notFirst); <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use the <code>caret</code> character in a regex to find <code>"Cal"</code> only in the beginning of the string <code>rickyAndCal</code>. <add>Use the caret character in a regex to find <code>"Cal"</code> only in the beginning of the string <code>rickyAndCal</code>. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-characters-that-occur-zero-or-more-times.english.md <ide> forumTopicId: 301351 <ide> ## Description <ide> <section id='description'> <ide> The last challenge used the plus <code>+</code> sign to look for characters that occur one or more times. There's also an option that matches characters that occur zero or more times. <del>The character to do this is the <code>asterisk</code> or <code>star</code>: <code>*</code>. <add>The character to do this is the asterisk or star: <code>*</code>. <ide> <ide> ```js <ide> let soccerWord = "gooooooooal!"; <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-ending-string-patterns.english.md <ide> forumTopicId: 301352 <ide> <ide> ## Description <ide> <section id='description'> <del>In the last challenge, you learned to use the <code>caret</code> character to search for patterns at the beginning of strings. There is also a way to search for patterns at the end of strings. <del>You can search the end of strings using the <code>dollar sign</code> character <code>$</code> at the end of the regex. <add>In the last challenge, you learned to use the caret character to search for patterns at the beginning of strings. There is also a way to search for patterns at the end of strings. <add>You can search the end of strings using the dollar sign character <code>$</code> at the end of the regex. <ide> <ide> ```js <ide> let theEnding = "This is a never ending story"; <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-letters-of-the-alphabet.english.md <ide> forumTopicId: 301354 <ide> <ide> ## Description <ide> <section id='description'> <del>You saw how you can use <code>character sets</code> to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple. <del>Inside a <code>character set</code>, you can define a range of characters to match using a <code>hyphen</code> character: <code>-</code>. <add>You saw how you can use <dfn>character sets</dfn> to specify a group of characters to match, but that's a lot of typing when you need to match a large range of characters (for example, every letter in the alphabet). Fortunately, there is a built-in feature that makes this short and simple. <add>Inside a character set, you can define a range of characters to match using a hyphen character: <code>-</code>. <ide> For example, to match lowercase letters <code>a</code> through <code>e</code> you would use <code>[a-e]</code>. <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-single-character-with-multiple-possibilities.english.md <ide> forumTopicId: 301357 <ide> ## Description <ide> <section id='description'> <ide> You learned how to match literal patterns (<code>/literal/</code>) and wildcard character (<code>/./</code>). Those are the extremes of regular expressions, where one finds exact matches and the other matches everything. There are options that are a balance between the two extremes. <del>You can search for a literal pattern with some flexibility with <code>character classes</code>. Character classes allow you to define a group of characters you wish to match by placing them inside square (<code>[</code> and <code>]</code>) brackets. <add>You can search for a literal pattern with some flexibility with <dfn>character classes</dfn>. Character classes allow you to define a group of characters you wish to match by placing them inside square (<code>[</code> and <code>]</code>) brackets. <ide> For example, you want to match <code>"bag"</code>, <code>"big"</code>, and <code>"bug"</code> but not <code>"bog"</code>. You can create the regex <code>/b[aiu]g/</code> to do this. The <code>[aiu]</code> is the character class that will only match the characters <code>"a"</code>, <code>"i"</code>, or <code>"u"</code>. <ide> <ide> ```js <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/match-single-characters-not-specified.english.md <ide> forumTopicId: 301358 <ide> <ide> ## Description <ide> <section id='description'> <del>So far, you have created a set of characters that you want to match, but you could also create a set of characters that you do not want to match. These types of character sets are called <code>negated character sets</code>. <del>To create a <code>negated character set</code>, you place a <code>caret</code> character (<code>^</code>) after the opening bracket and before the characters you do not want to match. <add>So far, you have created a set of characters that you want to match, but you could also create a set of characters that you do not want to match. These types of character sets are called <dfn>negated character sets</dfn>. <add>To create a negated character set, you place a caret character (<code>^</code>) after the opening bracket and before the characters you do not want to match. <ide> For example, <code>/[^aeiou]/gi</code> matches all characters that are not a vowel. Note that characters like <code>.</code>, <code>!</code>, <code>[</code>, <code>@</code>, <code>/</code> and white space are matched - the negated vowel character set only excludes the vowel characters. <ide> </section> <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/positive-and-negative-lookahead.english.md <ide> forumTopicId: 301360 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Lookaheads</code> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string. <del>There are two kinds of <code>lookaheads</code>: <code>positive lookahead</code> and <code>negative lookahead</code>. <del>A <code>positive lookahead</code> will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as <code>(?=...)</code> where the <code>...</code> is the required part that is not matched. <del>On the other hand, a <code>negative lookahead</code> will look to make sure the element in the search pattern is not there. A negative lookahead is used as <code>(?!...)</code> where the <code>...</code> is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present. <add><dfn>Lookaheads</dfn> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string. <add>There are two kinds of lookaheads: <dfn>positive lookahead</dfn> and <dfn>negative lookahead</dfn>. <add>A positive lookahead will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as <code>(?=...)</code> where the <code>...</code> is the required part that is not matched. <add>On the other hand, a negative lookahead will look to make sure the element in the search pattern is not there. A negative lookahead is used as <code>(?!...)</code> where the <code>...</code> is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present. <ide> Lookaheads are a bit confusing but some examples will help. <ide> <ide> ```js <ide> quit.match(quRegex); // Returns ["q"] <ide> noquit.match(qRegex); // Returns ["q"] <ide> ``` <ide> <del>A more practical use of <code>lookaheads</code> is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number: <add>A more practical use of lookaheads is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number: <ide> <ide> ```js <ide> let password = "abc123"; <ide> checkPass.test(password); // Returns true <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use <code>lookaheads</code> in the <code>pwRegex</code> to match passwords that are greater than 5 characters long, do not begin with numbers, and have two consecutive digits. <add>Use lookaheads in the <code>pwRegex</code> to match passwords that are greater than 5 characters long, do not begin with numbers, and have two consecutive digits. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/reuse-patterns-using-capture-groups.english.md <ide> forumTopicId: 301364 <ide> ## Description <ide> <section id='description'> <ide> Some patterns you search for will occur multiple times in a string. It is wasteful to manually repeat that regex. There is a better way to specify when you have multiple repeat substrings in your string. <del>You can search for repeat substrings using <code>capture groups</code>. Parentheses, <code>(</code> and <code>)</code>, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses. <add>You can search for repeat substrings using <dfn>capture groups</dfn>. Parentheses, <code>(</code> and <code>)</code>, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses. <ide> To specify where that repeat string will appear, you use a backslash (<code>\</code>) and then a number. This number starts at 1 and increases with each additional capture group you use. An example would be <code>\1</code> to match the first group. <ide> The example below matches any word that occurs twice separated by a space: <ide> <ide> Using the <code>.match()</code> method on a string will return an array with the <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use <code>capture groups</code> in <code>reRegex</code> to match numbers that are repeated only three times in a string, each separated by a space. <add>Use capture groups in <code>reRegex</code> to match numbers that are repeated only three times in a string, each separated by a space. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-exact-number-of-matches.english.md <ide> forumTopicId: 301365 <ide> <ide> ## Description <ide> <section id='description'> <del>You can specify the lower and upper number of patterns with <code>quantity specifiers</code> using curly brackets. Sometimes you only want a specific number of matches. <add>You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want a specific number of matches. <ide> To specify a certain number of patterns, just have that one number between the curly brackets. <ide> For example, to match only the word <code>"hah"</code> with the letter <code>a</code> <code>3</code> times, your regex would be <code>/ha{3}h/</code>. <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-only-the-lower-number-of-matches.english.md <ide> forumTopicId: 301366 <ide> <ide> ## Description <ide> <section id='description'> <del>You can specify the lower and upper number of patterns with <code>quantity specifiers</code> using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit. <add>You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit. <ide> To only specify the lower number of patterns, keep the first number followed by a comma. <ide> For example, to match only the string <code>"hah"</code> with the letter <code>a</code> appearing at least <code>3</code> times, your regex would be <code>/ha{3,}h/</code>. <ide> <ide><path>curriculum/challenges/english/02-javascript-algorithms-and-data-structures/regular-expressions/specify-upper-and-lower-number-of-matches.english.md <ide> forumTopicId: 301367 <ide> ## Description <ide> <section id='description'> <ide> Recall that you use the plus sign <code>+</code> to look for one or more characters and the asterisk <code>*</code> to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns. <del>You can specify the lower and upper number of patterns with <code>quantity specifiers</code>. Quantity specifiers are used with curly brackets (<code>{</code> and <code>}</code>). You put two numbers between the curly brackets - for the lower and upper number of patterns. <add>You can specify the lower and upper number of patterns with <dfn>quantity specifiers</dfn>. Quantity specifiers are used with curly brackets (<code>{</code> and <code>}</code>). You put two numbers between the curly brackets - for the lower and upper number of patterns. <ide> For example, to match only the letter <code>a</code> appearing between <code>3</code> and <code>5</code> times in the string <code>"ah"</code>, your regex would be <code>/a{3,5}h/</code>. <ide> <ide> ```js <ide><path>curriculum/challenges/english/03-front-end-libraries/bootstrap/use-responsive-design-with-bootstrap-fluid-containers.english.md <ide> forumTopicId: 18362 <ide> ## Description <ide> <section id='description'> <ide> In the HTML5 and CSS section of freeCodeCamp we built a Cat Photo App. Now let's go back to it. This time, we'll style it using the popular Bootstrap responsive CSS framework. <del>Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name <code>Responsive Design</code>. <add>Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name <dfn>responsive design</dfn>. <ide> With responsive design, there is no need to design a mobile version of your website. It will look good on devices with screens of any width. <ide> You can add Bootstrap to any app by adding the following code to the top of your HTML: <ide> <code>&#60;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/&#62;</code> <ide><path>curriculum/challenges/english/03-front-end-libraries/jquery/clone-an-element-using-jquery.english.md <ide> In addition to moving elements, you can also copy them from one place to another <ide> jQuery has a function called <code>clone()</code> that makes a copy of an element. <ide> For example, if we wanted to copy <code>target2</code> from our <code>left-well</code> to our <code>right-well</code>, we would use: <ide> <code>$("#target2").clone().appendTo("#right-well");</code> <del>Did you notice this involves sticking two jQuery functions together? This is called <code>function chaining</code> and it's a convenient way to get things done with jQuery. <add>Did you notice this involves sticking two jQuery functions together? This is called <dfn>function chaining</dfn> and it's a convenient way to get things done with jQuery. <ide> Clone your <code>target5</code> element and append it to your <code>left-well</code>. <ide> </section> <ide> <ide><path>curriculum/challenges/english/03-front-end-libraries/jquery/target-html-elements-with-selectors-using-jquery.english.md <ide> forumTopicId: 18319 <ide> ## Description <ide> <section id='description'> <ide> Now we have a <code>document ready function</code>. <del>Now let's write our first jQuery statement. All jQuery functions start with a <code>$</code>, usually referred to as a <code>dollar sign operator</code>, or as <code>bling</code>. <del>jQuery often selects an HTML element with a <code>selector</code>, then does something to that element. <add>Now let's write our first jQuery statement. All jQuery functions start with a <code>$</code>, usually referred to as a dollar sign operator, or as bling. <add>jQuery often selects an HTML element with a <dfn>selector</dfn>, then does something to that element. <ide> For example, let's make all of your <code>button</code> elements bounce. Just add this code inside your document ready function: <ide> <code>$("button").addClass("animated bounce");</code> <ide> Note that we've already included both the jQuery library and the Animate.css library in the background so that you can use them in the editor. So you are using jQuery to apply the Animate.css <code>bounce</code> class to your <code>button</code> elements. <ide><path>curriculum/challenges/english/03-front-end-libraries/jquery/target-the-children-of-an-element-using-jquery.english.md <ide> forumTopicId: 18320 <ide> <ide> ## Description <ide> <section id='description'> <del>When HTML elements are placed one level below another they are called <code>children</code> of that element. For example, the button elements in this challenge with the text "#target1", "#target2", and "#target3" are all <code>children</code> of the <code>&#60;div class="well" id="left-well"&#62;</code> element. <add>When HTML elements are placed one level below another they are called <dfn>children</dfn> of that element. For example, the button elements in this challenge with the text "#target1", "#target2", and "#target3" are all children of the <code>&#60;div class="well" id="left-well"&#62;</code> element. <ide> jQuery has a function called <code>children()</code> that allows you to access the children of whichever element you've selected. <ide> Here's an example of how you would use the <code>children()</code> function to give the children of your <code>left-well</code> element the color <code>blue</code>: <ide> <code>$("#left-well").children().css("color", "blue")</code> <ide><path>curriculum/challenges/english/03-front-end-libraries/react/introducing-inline-styles.english.md <ide> forumTopicId: 301395 <ide> ## Description <ide> <section id='description'> <ide> There are other complex concepts that add powerful capabilities to your React code. But you may be wondering about the more simple problem of how to style those JSX elements you create in React. You likely know that it won't be exactly the same as working with HTML because of <a target="_blank" href="learn/front-end-libraries/react/define-an-html-class-in-jsx"> the way you apply classes to JSX elements</a>. <del>If you import styles from a stylesheet, it isn't much different at all. You apply a class to your JSX element using the <code>className</code> attribute, and apply styles to the class in your stylesheet. Another option is to apply <strong><em>inline</em></strong> styles, which are very common in ReactJS development. <add>If you import styles from a stylesheet, it isn't much different at all. You apply a class to your JSX element using the <code>className</code> attribute, and apply styles to the class in your stylesheet. Another option is to apply inline styles, which are very common in ReactJS development. <ide> You apply inline styles to JSX elements similar to how you do it in HTML, but with a few JSX differences. Here's an example of an inline style in HTML: <ide> <code>&lt;div style="color: yellow; font-size: 16px"&gt;Mellow Yellow&lt;/div&gt;</code> <ide> JSX elements use the <code>style</code> attribute, but because of the way JSX is transpiled, you can't set the value to a <code>string</code>. Instead, you set it equal to a JavaScript <code>object</code>. Here's an example: <ide><path>curriculum/challenges/english/03-front-end-libraries/react/use-a-ternary-expression-for-conditional-rendering.english.md <ide> forumTopicId: 301414 <ide> <ide> ## Description <ide> <section id='description'> <del>Before moving on to dynamic rendering techniques, there's one last way to use built-in JavaScript conditionals to render what you want: the <em><strong>ternary operator</strong></em>. The ternary operator is often utilized as a shortcut for <code>if/else</code> statements in JavaScript. They're not quite as robust as traditional <code>if/else</code> statements, but they are very popular among React developers. One reason for this is because of how JSX is compiled, <code>if/else</code> statements can't be inserted directly into JSX code. You might have noticed this a couple challenges ago &mdash; when an <code>if/else</code> statement was required, it was always <em>outside</em> the <code>return</code> statement. Ternary expressions can be an excellent alternative if you want to implement conditional logic within your JSX. Recall that a ternary operator has three parts, but you can combine several ternary expressions together. Here's the basic syntax: <add>Before moving on to dynamic rendering techniques, there's one last way to use built-in JavaScript conditionals to render what you want: the <dfn>ternary operator</dfn>. The ternary operator is often utilized as a shortcut for <code>if/else</code> statements in JavaScript. They're not quite as robust as traditional <code>if/else</code> statements, but they are very popular among React developers. One reason for this is because of how JSX is compiled, <code>if/else</code> statements can't be inserted directly into JSX code. You might have noticed this a couple challenges ago &mdash; when an <code>if/else</code> statement was required, it was always <em>outside</em> the <code>return</code> statement. Ternary expressions can be an excellent alternative if you want to implement conditional logic within your JSX. Recall that a ternary operator has three parts, but you can combine several ternary expressions together. Here's the basic syntax: <ide> <ide> ```js <ide> condition ? expressionIfTrue : expressionIfFalse <ide><path>curriculum/challenges/english/03-front-end-libraries/react/use-array.map-to-dynamically-render-elements.english.md <ide> forumTopicId: 301417 <ide> ## Description <ide> <section id='description'> <ide> Conditional rendering is useful, but you may need your components to render an unknown number of elements. Often in reactive programming, a programmer has no way to know what the state of an application is until runtime, because so much depends on a user's interaction with that program. Programmers need to write their code to correctly handle that unknown state ahead of time. Using <code>Array.map()</code> in React illustrates this concept. <del>For example, you create a simple "To Do List" app. As the programmer, you have no way of knowing how many items a user might have on their list. You need to set up your component to <em><strong>dynamically render</strong></em> the correct number of list elements long before someone using the program decides that today is laundry day. <add>For example, you create a simple "To Do List" app. As the programmer, you have no way of knowing how many items a user might have on their list. You need to set up your component to dynamically render the correct number of list elements long before someone using the program decides that today is laundry day. <ide> </section> <ide> <ide> ## Instructions <ide><path>curriculum/challenges/english/03-front-end-libraries/sass/create-reusable-css-with-mixins.english.md <ide> forumTopicId: 301455 <ide> <ide> ## Description <ide> <section id='description'> <del>In Sass, a <code>mixin</code> is a group of CSS declarations that can be reused throughout the style sheet. <add>In Sass, a <dfn>mixin</dfn> is a group of CSS declarations that can be reused throughout the style sheet. <ide> Newer CSS features take time before they are fully adopted and ready to use in all browsers. As features are added to browsers, CSS rules using them may need vendor prefixes. Consider "box-shadow": <ide> <ide> ```scss <ide> div { <ide> ``` <ide> <ide> It's a lot of typing to re-write this rule for all the elements that have a <code>box-shadow</code>, or to change each value to test different effects. <del><code>Mixins</code> are like functions for CSS. Here is how to write one: <add>Mixins are like functions for CSS. Here is how to write one: <ide> <ide> ```scss <ide> @mixin box-shadow($x, $y, $blur, $c){ <ide> It's a lot of typing to re-write this rule for all the elements that have a <cod <ide> ``` <ide> <ide> The definition starts with <code>@mixin</code> followed by a custom name. The parameters (the <code>$x</code>, <code>$y</code>, <code>$blur</code>, and <code>$c</code> in the example above) are optional. <del>Now any time a <code>box-shadow</code> rule is needed, only a single line calling the <code>mixin</code> replaces having to type all the vendor prefixes. A <code>mixin</code> is called with the <code>@include</code> directive: <add>Now any time a <code>box-shadow</code> rule is needed, only a single line calling the mixin replaces having to type all the vendor prefixes. A mixin is called with the <code>@include</code> directive: <ide> <ide> ```scss <ide> div { <ide> div { <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Write a <code>mixin</code> for <code>border-radius</code> and give it a <code>$radius</code> parameter. It should use all the vendor prefixes from the example. Then use the <code>border-radius</code> <code>mixin</code> to give the <code>#awesome</code> element a border radius of 15px. <add>Write a mixin for <code>border-radius</code> and give it a <code>$radius</code> parameter. It should use all the vendor prefixes from the example. Then use the <code>border-radius</code> mixin to give the <code>#awesome</code> element a border radius of 15px. <ide> </section> <ide> <ide> ## Tests <ide> <section id='tests'> <ide> <ide> ```yml <ide> tests: <del> - text: Your code should declare a <code>mixin</code> named <code>border-radius</code> which has a parameter named <code>$radius</code>. <add> - text: Your code should declare a mixin named <code>border-radius</code> which has a parameter named <code>$radius</code>. <ide> testString: assert(code.match(/@mixin\s+?border-radius\s*?\(\s*?\$radius\s*?\)\s*?{/gi)); <ide> - text: Your code should include the <code>-webkit-border-radius</code> vender prefix that uses the <code>$radius</code> parameter. <ide> testString: assert(code.match(/-webkit-border-radius:\s*?\$radius;/gi)); <ide><path>curriculum/challenges/english/03-front-end-libraries/sass/nest-css-with-sass.english.md <ide> forumTopicId: 301457 <ide> <ide> ## Description <ide> <section id='description'> <del>Sass allows <code>nesting</code> of CSS rules, which is a useful way of organizing a style sheet. <add>Sass allows nesting of CSS rules, which is a useful way of organizing a style sheet. <ide> Normally, each element is targeted on a different line to style it, like so: <ide> <ide> ```scss <ide> nav ul li { <ide> } <ide> ``` <ide> <del>For a large project, the CSS file will have many lines and rules. This is where <code>nesting</code> can help organize your code by placing child style rules within the respective parent elements: <add>For a large project, the CSS file will have many lines and rules. This is where nesting can help organize your code by placing child style rules within the respective parent elements: <ide> <ide> ```scss <ide> nav { <ide> nav { <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Use the <code>nesting</code> technique shown above to re-organize the CSS rules for both children of <code>.blog-post</code> element. For testing purposes, the <code>h1</code> should come before the <code>p</code> element. <add>Use the nesting technique shown above to re-organize the CSS rules for both children of <code>.blog-post</code> element. For testing purposes, the <code>h1</code> should come before the <code>p</code> element. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/03-front-end-libraries/sass/split-your-styles-into-smaller-chunks-with-partials.english.md <ide> forumTopicId: 301459 <ide> <ide> ## Description <ide> <section id='description'> <del><code>Partials</code> in Sass are separate files that hold segments of CSS code. These are imported and used in other Sass files. This is a great way to group similar code into a module to keep it organized. <del>Names for <code>partials</code> start with the underscore (<code>_</code>) character, which tells Sass it is a small segment of CSS and not to convert it into a CSS file. Also, Sass files end with the <code>.scss</code> file extension. To bring the code in the <code>partial</code> into another Sass file, use the <code>@import</code> directive. <del>For example, if all your <code>mixins</code> are saved in a <code>partial</code> named "_mixins.scss", and they are needed in the "main.scss" file, this is how to use them in the main file: <add><dfn>Partials</dfn> in Sass are separate files that hold segments of CSS code. These are imported and used in other Sass files. This is a great way to group similar code into a module to keep it organized. <add>Names for partials start with the underscore (<code>_</code>) character, which tells Sass it is a small segment of CSS and not to convert it into a CSS file. Also, Sass files end with the <code>.scss</code> file extension. To bring the code in the partial into another Sass file, use the <code>@import</code> directive. <add>For example, if all your mixins are saved in a partial named "_mixins.scss", and they are needed in the "main.scss" file, this is how to use them in the main file: <ide> <ide> ```scss <ide> // In the main.scss file <ide> <ide> @import 'mixins' <ide> ``` <ide> <del>Note that the underscore and file extension are not needed in the <code>import</code> statement - Sass understands it is a <code>partial</code>. Once a <code>partial</code> is imported into a file, all variables, <code>mixins</code>, and other code are available to use. <add>Note that the underscore and file extension are not needed in the <code>import</code> statement - Sass understands it is a partial. Once a partial is imported into a file, all variables, mixins, and other code are available to use. <ide> </section> <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Write an <code>@import</code> statement to import a <code>partial</code> named <code>_variables.scss</code> into the main.scss file. <add>Write an <code>@import</code> statement to import a partial named <code>_variables.scss</code> into the main.scss file. <ide> </section> <ide> <ide> ## Tests <ide><path>curriculum/challenges/english/03-front-end-libraries/sass/use-if-and-else-to-add-logic-to-your-styles.english.md <ide> And just like in JavaScript, <code>@else if</code> and <code>@else</code> test f <ide> <ide> ## Instructions <ide> <section id='instructions'> <del>Create a <code>mixin</code> called <code>border-stroke</code> that takes a parameter <code>$val</code>. The <code>mixin</code> should check for the following conditions using <code>@if</code>, <code>@else if</code>, and <code>@else</code>: <add>Create a mixin called <code>border-stroke</code> that takes a parameter <code>$val</code>. The mixin should check for the following conditions using <code>@if</code>, <code>@else if</code>, and <code>@else</code>: <ide> <ide> ```scss <ide> light - 1px solid black <ide> If <code>$val</code> is not <code>light</code>, <code>medium</code>, or <code>he <ide> <ide> ```yml <ide> tests: <del> - text: Your code should declare a <code>mixin</code> named <code>border-stroke</code> which has a parameter named <code>$val</code>. <add> - text: Your code should declare a mixin named <code>border-stroke</code> which has a parameter named <code>$val</code>. <ide> testString: assert(code.match(/@mixin\s+?border-stroke\s*?\(\s*?\$val\s*?\)\s*?{/gi)); <del> - text: Your <code>mixin</code> should have an <code>@if</code> statement to check if <code>$val</code> is light, and to set the <code>border</code> to 1px solid black. <add> - text: Your mixin should have an <code>@if</code> statement to check if <code>$val</code> is light, and to set the <code>border</code> to 1px solid black. <ide> testString: assert(code.match(/@if\s+?\$val\s*?===?\s*?light\s*?{\s*?border\s*?:\s*?1px\s+?solid\s+?black\s*?;\s*?}/gi)); <del> - text: Your <code>mixin</code> should have an <code>@else if</code> statement to check if <code>$val</code> is medium, and to set the <code>border</code> to 3px solid black. <add> - text: Your mixin should have an <code>@else if</code> statement to check if <code>$val</code> is medium, and to set the <code>border</code> to 3px solid black. <ide> testString: assert(code.match(/@else\s+?if\s+?\$val\s*?===?\s*?medium\s*?{\s*?border\s*?:\s*?3px\s+?solid\s+?black\s*?;\s*?}/gi)); <del> - text: Your <code>mixin</code> should have an <code>@else if</code> statement to check if <code>$val</code> is heavy, and to set the <code>border</code> to 6px solid black. <add> - text: Your mixin should have an <code>@else if</code> statement to check if <code>$val</code> is heavy, and to set the <code>border</code> to 6px solid black. <ide> testString: assert(code.match(/@else\s+?if\s+?\$val\s*?===?\s*?heavy\s*?{\s*?border\s*?:\s*?6px\s+?solid\s+?black\s*?;\s*?}/gi)); <del> - text: Your <code>mixin</code> should have an <code>@else</code> statement to set the <code>border</code> to none. <add> - text: Your mixin should have an <code>@else</code> statement to set the <code>border</code> to none. <ide> testString: assert(code.match(/@else\s*?{\s*?border\s*?:\s*?none\s*?;\s*?}/gi)); <ide> <ide> ``` <ide><path>curriculum/challenges/english/04-data-visualization/data-visualization-with-d3/learn-about-svg-in-d3.english.md <ide> forumTopicId: 301489 <ide> <ide> ## Description <ide> <section id='description'> <del>SVG stands for <code>Scalable Vector Graphics</code>. <add><dfn>SVG</dfn> stands for <dfn>Scalable Vector Graphics</dfn>. <ide> Here "scalable" means that, if you zoom in or out on an object, it would not appear pixelated. It scales with the display system, whether it's on a small mobile screen or a large TV monitor. <ide> SVG is used to make common geometric shapes. Since D3 maps data into a visual representation, it uses SVG to create the shapes for the visualization. SVG shapes for a web page must go within an HTML <code>svg</code> tag. <ide> CSS can be scalable when styles use relative units (such as <code>vh</code>, <code>vw</code>, or percentages), but using SVG is more flexible to build data visualizations.
75
Python
Python
improve history perf
bd6e682aa781ba934b28ddff76b3b6f1d7f2f516
<ide><path>glances/attribute.py <ide> def history_reset(self): <ide> def history_add(self, value): <ide> """Add a value in the history <ide> """ <del> if self._history_max_size is None or self.history_len() < self._history_max_size: <del> self._history.append(value) <del> else: <del> self._history = self._history[1:] + [value] <add> if not (self._history_max_size is None or self.history_len() < self._history_max_size): <add> #self._history = self._history[1:] + [value] <add> self._history.pop(0) <add> self._history.append(value) <ide> <ide> def history_size(self): <ide> """Return the history size (maximum nuber of value in the history)
1
PHP
PHP
add unit tests for droptimestamps() function
00f62c86e2d03e5ede76496780975c1c0f9163e8
<ide><path>tests/Database/DatabaseMySqlSchemaGrammarTest.php <ide> public function testDropForeign() <ide> } <ide> <ide> <add> public function testDropTimestamps() <add> { <add> $blueprint = new Blueprint('users'); <add> $blueprint->dropTimestamps(); <add> $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); <add> <add> $this->assertEquals(1, count($statements)); <add> $this->assertEquals('alter table `users` drop `created_at`, drop `updated_at`', $statements[0]); <add> } <add> <add> <ide> public function testRenameTable() <ide> { <ide> $blueprint = new Blueprint('users'); <ide><path>tests/Database/DatabasePostgresSchemaGrammarTest.php <ide> public function testDropForeign() <ide> } <ide> <ide> <add> public function testDropTimestamps() <add> { <add> $blueprint = new Blueprint('users'); <add> $blueprint->dropTimestamps(); <add> $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); <add> <add> $this->assertEquals(1, count($statements)); <add> $this->assertEquals('alter table "users" drop column "created_at", drop column "updated_at"', $statements[0]); <add> } <add> <add> <ide> public function testRenameTable() <ide> { <ide> $blueprint = new Blueprint('users'); <ide><path>tests/Database/DatabaseSqlServerSchemaGrammarTest.php <ide> public function testDropForeign() <ide> } <ide> <ide> <add> public function testDropTimestamps() <add> { <add> $blueprint = new Blueprint('users'); <add> $blueprint->dropTimestamps(); <add> $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); <add> <add> $this->assertEquals(1, count($statements)); <add> $this->assertEquals('alter table "users" drop "created_at", drop "updated_at"', $statements[0]); <add> } <add> <add> <ide> public function testRenameTable() <ide> { <ide> $blueprint = new Blueprint('users');
3
Text
Text
add changelog entry for 42c3537 [ci skip]
54c2c6de1769570ecc13ddfb733e80e1086a21ef
<ide><path>actionview/CHANGELOG.md <add>* Mark arrays of translations as trusted safe by using the `_html` suffix. Example: <add> <add> en: <add> foo_html: <add> - "One" <add> - "<strong>Two</strong>" <add> - "Three &#128075; &#128578;" <add> <add> *Juan Broullon* <add> <ide> * Add `year_format` option to date_select tag. This option makes it possible to customize year <ide> names. Lambda should be passed to use this option. <ide> <ide> Example: <ide> <ide> date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" }) <ide> <del> The HTML produced: <add> The HTML produced: <ide> <ide> <select id="user_birthday__1i" name="user_birthday[(1i)]"> <ide> <option value="1998">Heisei 10</option>
1
Javascript
Javascript
use spies instead of monkey patching
f2e2475c62bb442cecac4b453c75bdc4c7243511
<ide><path>spec/text-editor-component-spec.js <ide> describe('TextEditorComponent', () => { <ide> fakeWindow.appendChild(element) <ide> jasmine.attachToDOM(fakeWindow) <ide> <del> component.getWindowInnerWidth = () => fakeWindow.getBoundingClientRect().width <del> component.getWindowInnerHeight = () => fakeWindow.getBoundingClientRect().height <del> // spyOn(component, 'getWindowInnerWidth').andCallFake(() => fakeWindow.getBoundingClientRect().width) <del> // spyOn(component, 'getWindowInnerHeight').andCallFake(() => fakeWindow.getBoundingClientRect().height) <add> spyOn(component, 'getWindowInnerWidth').andCallFake(() => fakeWindow.getBoundingClientRect().width) <add> spyOn(component, 'getWindowInnerHeight').andCallFake(() => fakeWindow.getBoundingClientRect().height) <ide> await setScrollTop(component, 50) <ide> await setScrollLeft(component, 100) <ide>
1
Text
Text
remove some incorrect bash symbols
2d1d4684f0fc752aae7e41af03a0f1589f11ee00
<ide><path>docs/userguide/networking/get-started-overlay.md <ide> $ docker network create \ <ide> <ide> # Create an nginx service and extend the my-multi-host-network to nodes where <ide> # the service's tasks run. <del>$ $ docker service create --replicas 2 --network my-multi-host-network --name my-web nginx <add>$ docker service create --replicas 2 --network my-multi-host-network --name my-web nginx <ide> <ide> 716thylsndqma81j6kkkb5aus <ide> ``` <ide><path>docs/userguide/networking/index.md <ide> $ docker network create \ <ide> <ide> # Create an nginx service and extend the my-multi-host-network to nodes where <ide> # the service's tasks run. <del>$ $ docker service create --replicas 2 --network my-multi-host-network --name my-web nginx <add>$ docker service create --replicas 2 --network my-multi-host-network --name my-web nginx <ide> <ide> 716thylsndqma81j6kkkb5aus <ide> ```
2
Python
Python
add tests for caching of get/head requests using
44f280c3abf3832a4a43be4fc52dc807f4cb6a70
<ide><path>rest_framework/runtests/settings.py <ide> } <ide> } <ide> <add>CACHES = { <add> 'default': { <add> 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', <add> } <add>} <add> <ide> # Local time zone for this installation. Choices can be found here: <ide> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name <ide> # although not all choices may be available on all operating systems. <ide><path>rest_framework/tests/renderers.py <add>import pickle <ide> import re <ide> <ide> from django.conf.urls.defaults import patterns, url, include <add>from django.core.cache import cache <ide> from django.test import TestCase <ide> from django.test.client import RequestFactory <ide> <ide> def get(self, request, **kwargs): <ide> urlpatterns = patterns('', <ide> url(r'^.*\.(?P<format>.+)$', MockView.as_view(renderer_classes=[RendererA, RendererB])), <ide> url(r'^$', MockView.as_view(renderer_classes=[RendererA, RendererB])), <add> url(r'^cache$', MockGETView.as_view()), <ide> url(r'^jsonp/jsonrenderer$', MockGETView.as_view(renderer_classes=[JSONRenderer, JSONPRenderer])), <ide> url(r'^jsonp/nojsonrenderer$', MockGETView.as_view(renderer_classes=[JSONPRenderer])), <ide> url(r'^html$', HTMLView.as_view()), <ide> def assertXMLContains(self, xml, string): <ide> self.assertTrue(xml.startswith('<?xml version="1.0" encoding="utf-8"?>\n<root>')) <ide> self.assertTrue(xml.endswith('</root>')) <ide> self.assertTrue(string in xml, '%r not in %r' % (string, xml)) <add> <add> <add># Tests for caching issue, #346 <add>class CacheRenderTest(TestCase): <add> """ <add> Tests specific to caching responses <add> """ <add> <add> urls = 'rest_framework.tests.renderers' <add> <add> cache_key = 'just_a_cache_key' <add> <add> @classmethod <add> def _get_pickling_errors(cls, obj, seen=None): <add> """ Return any errors that would be raised if `obj' is pickled <add> Courtesy of koffie @ http://stackoverflow.com/a/7218986/109897 <add> """ <add> if seen == None: <add> seen = [] <add> try: <add> state = obj.__getstate__() <add> except AttributeError: <add> return <add> if state == None: <add> return <add> if isinstance(state,tuple): <add> if not isinstance(state[0],dict): <add> state=state[1] <add> else: <add> state=state[0].update(state[1]) <add> result = {} <add> for i in state: <add> try: <add> pickle.dumps(state[i],protocol=2) <add> except pickle.PicklingError: <add> if not state[i] in seen: <add> seen.append(state[i]) <add> result[i] = cls._get_pickling_errors(state[i],seen) <add> return result <add> <add> def http_resp(self, http_method, url): <add> """ <add> Simple wrapper for Client http requests <add> Removes the `client' attribute from the response as an instance <add> of `django.test.client.Client' is not pickable <add> """ <add> method = getattr(self.client, http_method) <add> resp = method(url) <add> del resp.client <add> return resp <add> <add> def test_obj_pickling(self): <add> """ <add> Test that responses are properly pickled <add> """ <add> resp = self.http_resp('get', '/cache') <add> <add> # Make sure that no pickling errors occurred <add> self.assertEqual(self._get_pickling_errors(resp), {}) <add> <add> # Unfortunately LocMem backend doesn't raise PickleErrors but returns <add> # None instead. <add> cache.set(self.cache_key, resp) <add> self.assertTrue(cache.get(self.cache_key) is not None) <add> <add> def test_head_caching(self): <add> """ <add> Test caching of HEAD requests <add> """ <add> resp = self.http_resp('head', '/cache') <add> cache.set(self.cache_key, resp) <add> <add> cached_resp = cache.get(self.cache_key) <add> self.assertIsInstance(cached_resp, Response) <add> <add> def test_get_caching(self): <add> """ <add> Test caching of GET requests <add> """ <add> resp = self.http_resp('get', '/cache') <add> cache.set(self.cache_key, resp) <add> <add> cached_resp = cache.get(self.cache_key) <add> self.assertIsInstance(cached_resp, Response) <add> self.assertEqual(cached_resp.content, resp.content)
2
Javascript
Javascript
add cases for unescape & unescapebuffer
02acea92d22217e11b9eb59abf9ff261a56d1a9e
<ide><path>test/parallel/test-querystring.js <ide> const qsNoMungeTestCases = [ <ide> ['trololol=yes&lololo=no', {'trololol': 'yes', 'lololo': 'no'}] <ide> ]; <ide> <add>const qsUnescapeTestCases = [ <add> ['there is nothing to unescape here', <add> 'there is nothing to unescape here'], <add> ['there%20are%20several%20spaces%20that%20need%20to%20be%20unescaped', <add> 'there are several spaces that need to be unescaped'], <add> ['there%2Qare%0-fake%escaped values in%%%%this%9Hstring', <add> 'there%2Qare%0-fake%escaped values in%%%%this%9Hstring'], <add> ['%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37', <add> ' !"#$%&\'()*+,-./01234567'] <add>]; <add> <ide> assert.strictEqual('918854443121279438895193', <ide> qs.parse('id=918854443121279438895193').id); <ide> <ide> function demoDecode(str) { <ide> check(qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }), <ide> { aa: 'aa', bb: 'bb', cc: 'cc' }); <ide> <add>// Test QueryString.unescape <add>function errDecode(str) { <add> throw new Error('To jump to the catch scope'); <add>} <add>check(qs.parse('a=a', null, null, { decodeURIComponent: errDecode }), <add> { a: 'a' }); <ide> <ide> // Test custom encode <ide> function demoEncode(str) { <ide> assert.strictEqual( <ide> qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }), <ide> 'a=a&b=b&c=c'); <ide> <add>// Test QueryString.unescapeBuffer <add>qsUnescapeTestCases.forEach(function(testCase) { <add> assert.strictEqual(qs.unescape(testCase[0]), testCase[1]); <add> assert.strictEqual(qs.unescapeBuffer(testCase[0]).toString(), testCase[1]); <add>}); <add> <ide> // test overriding .unescape <ide> const prevUnescape = qs.unescape; <ide> qs.unescape = function(str) {
1
Javascript
Javascript
add mdn link for iterator
0c712b67434b250f48460c06dce6877dd439a7eb
<ide><path>tools/doc/type-parser.js <ide> 'use strict'; <ide> const nodeDocUrl = ''; <del>const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' + <del> 'Reference/Global_Objects/'; <del>const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' + <del> 'JavaScript/Data_structures'; <add>const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/'; <add>const jsDocUrl = jsDocPrefix + 'Reference/Global_Objects/'; <add>const jsPrimitiveUrl = jsDocPrefix + 'Data_structures'; <ide> const jsPrimitives = { <ide> 'Integer': 'Number', // this is for extending <ide> 'Number': 'Number', <ide> const typeMap = { <ide> 'http.IncomingMessage': 'http.html#http_class_http_incomingmessage', <ide> 'http.Server': 'http.html#http_class_http_server', <ide> 'http.ServerResponse': 'http.html#http_class_http_serverresponse', <add> 'Iterator': jsDocPrefix + <add> 'Reference/Iteration_protocols#The_iterator_protocol' <ide> }; <ide> <ide> module.exports = {
1
Javascript
Javascript
fix handling of keywords in bind helpers
eb0fa874223641e8905077f2ab89e1676cea5117
<ide><path>packages/ember-handlebars/lib/helpers/binding.js <ide> function bind(property, options, preserveContext, shouldDisplay, valueNormalizer <ide> inverse = options.inverse, <ide> view = data.view, <ide> currentContext = this, <del> pathRoot, path, normalized, <del> observer, i; <add> normalized, observer, i; <ide> <ide> normalized = normalizePath(currentContext, property, data); <ide> <del> pathRoot = normalized.root; <del> path = normalized.path; <del> <ide> // Set up observers for observable objects <ide> if ('object' === typeof this) { <ide> if (data.insideGroup) { <ide> observer = function() { <ide> Ember.run.once(view, 'rerender'); <ide> }; <ide> <del> var template, context, result = handlebarsGet(pathRoot, path, options); <add> var template, context, result = handlebarsGet(currentContext, property, options); <ide> <ide> result = valueNormalizer(result); <ide> <ide> function bind(property, options, preserveContext, shouldDisplay, valueNormalizer <ide> valueNormalizerFunc: valueNormalizer, <ide> displayTemplate: fn, <ide> inverseTemplate: inverse, <del> path: path, <del> pathRoot: pathRoot, <add> path: property, <add> pathRoot: currentContext, <ide> previousContext: currentContext, <ide> isEscaped: !options.hash.unescaped, <ide> templateData: options.data <ide> function bind(property, options, preserveContext, shouldDisplay, valueNormalizer <ide> // tells the Ember._HandlebarsBoundView to re-render. If property <ide> // is an empty string, we are printing the current context <ide> // object ({{this}}) so updating it is not our responsibility. <del> if (path !== '') { <del> view.registerObserver(pathRoot, path, observer); <add> if (normalized.path !== '') { <add> view.registerObserver(normalized.root, normalized.path, observer); <ide> if (childProperties) { <ide> for (i=0; i<childProperties.length; i++) { <del> view.registerObserver(pathRoot, path+'.'+childProperties[i], observer); <add> view.registerObserver(normalized.root, normalized.path+'.'+childProperties[i], observer); <ide> } <ide> } <ide> } <ide> } else { <ide> // The object is not observable, so just render it out and <ide> // be done with it. <del> data.buffer.push(handlebarsGet(pathRoot, path, options)); <add> data.buffer.push(handlebarsGet(currentContext, property, options)); <ide> } <ide> } <ide> <ide> function simpleBind(property, options) { <ide> var data = options.data, <ide> view = data.view, <ide> currentContext = this, <del> pathRoot, path, normalized, <del> observer; <add> normalized, observer; <ide> <ide> normalized = normalizePath(currentContext, property, data); <ide> <del> pathRoot = normalized.root; <del> path = normalized.path; <del> <ide> // Set up observers for observable objects <ide> if ('object' === typeof this) { <ide> if (data.insideGroup) { <ide> observer = function() { <ide> Ember.run.once(view, 'rerender'); <ide> }; <ide> <del> var result = handlebarsGet(pathRoot, path, options); <add> var result = handlebarsGet(currentContext, property, options); <ide> if (result === null || result === undefined) { result = ""; } <ide> data.buffer.push(result); <ide> } else { <ide> var bindView = new Ember._SimpleHandlebarsView( <del> path, pathRoot, !options.hash.unescaped, options.data <add> property, currentContext, !options.hash.unescaped, options.data <ide> ); <ide> <ide> bindView._parentView = view; <ide> function simpleBind(property, options) { <ide> // tells the Ember._HandlebarsBoundView to re-render. If property <ide> // is an empty string, we are printing the current context <ide> // object ({{this}}) so updating it is not our responsibility. <del> if (path !== '') { <del> view.registerObserver(pathRoot, path, observer); <add> if (normalized.path !== '') { <add> view.registerObserver(normalized.root, normalized.path, observer); <ide> } <ide> } else { <ide> // The object is not observable, so just render it out and <ide> // be done with it. <del> data.buffer.push(handlebarsGet(pathRoot, path, options)); <add> data.buffer.push(handlebarsGet(currentContext, property, options)); <ide> } <ide> } <ide> <ide> EmberHandlebars.registerHelper('bindAttr', function(options) { <ide> // current value of the property as an attribute. <ide> forEach.call(attrKeys, function(attr) { <ide> var path = attrs[attr], <del> pathRoot, normalized; <add> normalized; <ide> <ide> Ember.assert(fmt("You must provide a String for a bound attribute, not %@", [path]), typeof path === 'string'); <ide> <ide> normalized = normalizePath(ctx, path, options.data); <ide> <del> pathRoot = normalized.root; <del> path = normalized.path; <del> <del> var value = (path === 'this') ? pathRoot : handlebarsGet(pathRoot, path, options), <add> var value = (path === 'this') ? normalized.root : handlebarsGet(ctx, path, options), <ide> type = Ember.typeOf(value); <ide> <ide> Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean'); <ide> <ide> var observer, invoker; <ide> <ide> observer = function observer() { <del> var result = handlebarsGet(pathRoot, path, options); <add> var result = handlebarsGet(ctx, path, options); <ide> <ide> Ember.assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean'); <ide> <ide> EmberHandlebars.registerHelper('bindAttr', function(options) { <ide> // In that case, we can assume the template has been re-rendered <ide> // and we need to clean up the observer. <ide> if (!elem || elem.length === 0) { <del> Ember.removeObserver(pathRoot, path, invoker); <add> Ember.removeObserver(normalized.root, normalized.path, invoker); <ide> return; <ide> } <ide> <ide> EmberHandlebars.registerHelper('bindAttr', function(options) { <ide> // When the observer fires, find the element using the <ide> // unique data id and update the attribute to the new value. <ide> if (path !== 'this') { <del> view.registerObserver(pathRoot, path, invoker); <add> view.registerObserver(normalized.root, normalized.path, invoker); <ide> } <ide> <ide> // if this changes, also change the logic in ember-views/lib/views/view.js <ide> EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, <ide> // class name. <ide> observer = function() { <ide> // Get the current value of the property <del> newClass = classStringForPath(pathRoot, parsedPath, options); <add> newClass = classStringForPath(context, parsedPath, options); <ide> elem = bindAttrId ? view.$("[data-bindattr-" + bindAttrId + "='" + bindAttrId + "']") : view.$(); <ide> <ide> // If we can't find the element anymore, a parent template has been <ide> EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, <ide> <ide> // We've already setup the observer; now we just need to figure out the <ide> // correct behavior right now on the first pass through. <del> value = classStringForPath(pathRoot, parsedPath, options); <add> value = classStringForPath(context, parsedPath, options); <ide> <ide> if (value) { <ide> ret.push(value); <ide><path>packages/ember-handlebars/tests/handlebars_test.js <ide> test("Ember.View should update when a property changes and the bind helper is us <ide> equal(view.$('#first').text(), "bazam", "view updates when a bound property changes"); <ide> }); <ide> <add>test("Ember.View should not use keyword incorrectly - Issue #1315", function() { <add> container.register('template', 'foo', Ember.Handlebars.compile('{{#each value in view.content}}{{value}}-{{#each option in view.options}}{{option.value}}:{{option.label}} {{/each}}{{/each}}')); <add> <add> view = Ember.View.create({ <add> container: container, <add> templateName: 'foo', <add> <add> content: Ember.A(['X', 'Y']), <add> options: Ember.A([ <add> { label: 'One', value: 1 }, <add> { label: 'Two', value: 2 } <add> ]) <add> }); <add> <add> Ember.run(function() { <add> view.appendTo('#qunit-fixture'); <add> }); <add> <add> equal(view.$().text(), 'X-1:One 2:Two Y-1:One 2:Two '); <add>}); <add> <ide> test("Ember.View should update when a property changes and no bind helper is used", function() { <ide> container.register('template', 'foo', Ember.Handlebars.compile('<h1 id="first">{{#with view.content}}{{wham}}{{/with}}</h1>')); <ide>
2
Text
Text
add player.dispose() api documentation to api.md
a726b075382ee628ae5d494ecf14d1609d0dabde
<ide><path>docs/api.md <ide> myPlayer.cancelFullScreen(); <ide> ``` <ide> <ide> <add>### dispose() ### <add>Destroys the video player and does any necessary cleanup. This is especially helpfull if you are dynamically adding and removing videos to/from the DOM. Use after removing videos from the DOM <add>```js <add>myPlayer.dispose(); <add>``` <add> <add> <add> <ide> Events <ide> ------ <ide> You can attach event listeners to the player similarly to how you would for a video element.
1
Python
Python
improve style of some comments
9adb43e44b46a287db94370d5081c542bf91f5db
<ide><path>keras/engine/training.py <ide> def _fit_loop(self, f, ins, out_labels=None, batch_size=32, <ide> batch_ids = index_array[batch_start:batch_end] <ide> try: <ide> if isinstance(ins[-1], float): <del> # do not slice the training phase flag <add> # Do not slice the training phase flag. <ide> ins_batch = _slice_arrays(ins[:-1], batch_ids) + [ins[-1]] <ide> else: <ide> ins_batch = _slice_arrays(ins, batch_ids) <ide> def _fit_loop(self, f, ins, out_labels=None, batch_size=32, <ide> <ide> callbacks.on_batch_end(batch_index, batch_logs) <ide> <del> if batch_index == len(batches) - 1: # last batch <del> # validation <add> if batch_index == len(batches) - 1: # Last batch. <ide> if do_validation: <del> # replace with self._evaluate <ide> val_outs = self._test_loop(val_f, val_ins, <ide> batch_size=batch_size, <ide> verbose=0) <ide> if not isinstance(val_outs, list): <ide> val_outs = [val_outs] <del> # same labels assumed <add> # Same labels assumed. <ide> for l, o in zip(out_labels, val_outs): <ide> epoch_logs['val_' + l] = o <ide> callbacks.on_epoch_end(epoch, epoch_logs) <ide> def _predict_loop(self, f, ins, batch_size=32, verbose=0): <ide> for batch_index, (batch_start, batch_end) in enumerate(batches): <ide> batch_ids = index_array[batch_start:batch_end] <ide> if ins and isinstance(ins[-1], float): <del> # do not slice the training phase flag <add> # Do not slice the training phase flag. <ide> ins_batch = _slice_arrays(ins[:-1], batch_ids) + [ins[-1]] <ide> else: <ide> ins_batch = _slice_arrays(ins, batch_ids) <ide> def _test_loop(self, f, ins, batch_size=32, verbose=0): <ide> for batch_index, (batch_start, batch_end) in enumerate(batches): <ide> batch_ids = index_array[batch_start:batch_end] <ide> if isinstance(ins[-1], float): <del> # do not slice the training phase flag <add> # Do not slice the training phase flag. <ide> ins_batch = _slice_arrays(ins[:-1], batch_ids) + [ins[-1]] <ide> else: <ide> ins_batch = _slice_arrays(ins, batch_ids) <ide> class indices (integers) to <ide> if kwargs: <ide> raise TypeError('Unrecognized keyword arguments: ' + str(kwargs)) <ide> <del> # validate user data <add> # Validate user data. <ide> x, y, sample_weights = self._standardize_user_data( <ide> x, y, <ide> sample_weight=sample_weight, <ide> class_weight=class_weight, <ide> check_batch_axis=False, <ide> batch_size=batch_size) <del> # prepare validation data <add> # Prepare validation data. <ide> if validation_data: <ide> do_validation = True <ide> if len(validation_data) == 2: <ide> class indices (integers) to <ide> val_f = None <ide> val_ins = None <ide> <del> # prepare input arrays and training function <add> # Prepare input arrays and training function. <ide> if self.uses_learning_phase and not isinstance(K.learning_phase(), int): <ide> ins = x + y + sample_weights + [1.] <ide> else: <ide> ins = x + y + sample_weights <ide> self._make_train_function() <ide> f = self.train_function <ide> <del> # prepare display labels <add> # Prepare display labels. <ide> out_labels = self.metrics_names <ide> <del> # rename duplicated metrics name <del> # (can happen with an output layer shared among multiple dataflows) <add> # Rename duplicated metrics name <add> # (can happen with an output layer shared among multiple dataflows). <ide> deduped_out_labels = [] <ide> for i, label in enumerate(out_labels): <ide> new_label = label <ide> class indices (integers) to <ide> else: <ide> callback_metrics = copy.copy(out_labels) <ide> <del> # delegate logic to _fit_loop <add> # Delegate logic to `_fit_loop`. <ide> return self._fit_loop(f, ins, out_labels=out_labels, <ide> batch_size=batch_size, epochs=epochs, <ide> verbose=verbose, callbacks=callbacks, <ide> def evaluate(self, x, y, batch_size=32, verbose=1, sample_weight=None): <ide> and/or metrics). The attribute `model.metrics_names` will give you <ide> the display labels for the scalar outputs. <ide> """ <del> # validate user data <add> # Validate user data. <ide> x, y, sample_weights = self._standardize_user_data( <ide> x, y, <ide> sample_weight=sample_weight, <ide> check_batch_axis=False, <ide> batch_size=batch_size) <del> # prepare inputs, delegate logic to _test_loop <add> # Prepare inputs, delegate logic to `_test_loop`. <ide> if self.uses_learning_phase and not isinstance(K.learning_phase(), int): <ide> ins = x + y + sample_weights + [0.] <ide> else: <ide> def predict(self, x, batch_size=32, verbose=0): <ide> or in case a stateful model receives a number of samples <ide> that is not a multiple of the batch size. <ide> """ <del> # validate user data <add> # Validate user data. <ide> x = _standardize_input_data(x, self._feed_input_names, <ide> self._feed_input_shapes, <ide> check_batch_axis=False) <ide> def predict(self, x, batch_size=32, verbose=0): <ide> str(x[0].shape[0]) + ' samples. ' <ide> 'Batch size: ' + str(batch_size) + '.') <ide> <del> # prepare inputs, delegate logic to _predict_loop <add> # Prepare inputs, delegate logic to `_predict_loop`. <ide> if self.uses_learning_phase and not isinstance(K.learning_phase(), int): <ide> ins = x + [0.] <ide> else:
1
Javascript
Javascript
handle ctrl/cmd+g for html findbar
a15d3d6622ec28fa4fbb710cbc3373ff68a79221
<ide><path>web/viewer.js <ide> window.addEventListener('keydown', function keydown(evt) { <ide> } <ide> } <ide> <add> // CTRL or META with or without SHIFT. <add> if (cmd == 1 || cmd == 8 || cmd == 5 || cmd == 12) { <add> switch (evt.keyCode) { <add> case 71: // g <add> if (!PDFView.supportsIntegratedFind) { <add> PDFFindBar.dispatchEvent('again', cmd == 5 || cmd == 12); <add> handled = true; <add> } <add> break; <add> } <add> } <add> <ide> if (handled) { <ide> evt.preventDefault(); <ide> return;
1
Javascript
Javascript
remove outdated unittest
fbd97de07bb063620185533e8967b94b474f3463
<ide><path>test/RecordIdsPlugin.test.js <del>/* globals describe, before, it */ <del>"use strict"; <del> <del>const should = require("should"); <del>const path = require("path"); <del> <del>const webpack = require("../lib/webpack"); <del>const identifierUtils = require("../lib/util/identifier"); <del> <del>describe("RecordIdsPlugin", () => { <del> <del> let compiler; <del> <del> before(() => { <del> compiler = webpack({ <del> entry: "./nodetest/entry", <del> context: path.join(__dirname, "fixtures"), <del> output: { <del> path: path.join(__dirname, "nodetest", "js"), <del> filename: "result1.js" <del> } <del> }); <del> <del> compiler.plugin("compilation", (compilation, callback) => { <del> compilation.plugin("should-record", () => true); <del> }); <del> }); <del> <del> it("should cache identifiers", (done) => { <del> compiler.compile((err, compilation) => { <del> if(err) done(err); <del> let pass = true; <del> for(let i = 0; i < compilation.modules.length; i++) { <del> try { <del> should.exist(compilation.modules[i].portableId); <del> compilation.modules[i].portableId.should.equal(identifierUtils.makePathsRelative(compiler.context, compilation.modules[i].identifier())); <del> } catch(e) { <del> done(e); <del> pass = false; <del> break; <del> } <del> } <del> if(pass) done(); <del> }); <del> }); <del>});
1
Ruby
Ruby
check undeclared dependencies for `--test`
080ddd8804be14f4b18f9558b58270456ff313c2
<ide><path>Library/Homebrew/dev-cmd/linkage.rb <ide> <ide> module Homebrew <ide> def linkage <del> found_broken_dylibs = false <ide> ARGV.kegs.each do |keg| <ide> ohai "Checking #{keg.name} linkage" if ARGV.kegs.size > 1 <ide> result = LinkageChecker.new(keg) <ide> if ARGV.include?("--test") <ide> result.display_test_output <add> if result.broken_dylibs? || result.undeclared_deps? <add> Homebrew.failed = true <add> end <ide> elsif ARGV.include?("--reverse") <ide> result.display_reverse_output <ide> else <ide> result.display_normal_output <ide> end <del> found_broken_dylibs = true unless result.broken_dylibs.empty? <del> end <del> if ARGV.include?("--test") && found_broken_dylibs <del> exit 1 <ide> end <ide> end <ide> <ide> class LinkageChecker <ide> attr_reader :keg <del> attr_reader :broken_dylibs <add> attr_reader :brewed_dylibs, :system_dylibs, :broken_dylibs, :variable_dylibs <add> attr_reader :undeclared_deps, :reverse_links <ide> <ide> def initialize(keg) <ide> @keg = keg <ide> @brewed_dylibs = Hash.new { |h, k| h[k] = Set.new } <ide> @system_dylibs = Set.new <ide> @broken_dylibs = Set.new <ide> @variable_dylibs = Set.new <add> @undeclared_deps = [] <ide> @reverse_links = Hash.new { |h, k| h[k] = Set.new } <ide> check_dylibs <ide> end <ide> def check_dylibs <ide> @undeclared_deps -= [f.name] <ide> rescue FormulaUnavailableError <ide> opoo "Formula unavailable: #{keg.name}" <del> @undeclared_deps = [] <ide> end <ide> end <ide> <ide> def display_reverse_output <ide> def display_test_output <ide> display_items "Missing libraries", @broken_dylibs <ide> puts "No broken dylib links" if @broken_dylibs.empty? <add> display_items "Possible undeclared dependencies", @undeclared_deps <add> puts "No undeclared dependencies" if @undeclared_deps.empty? <add> end <add> <add> def broken_dylibs? <add> !@broken_dylibs.empty? <add> end <add> <add> def undeclared_deps? <add> !@undeclared_deps.empty? <ide> end <ide> <ide> private
1
Java
Java
use assertthat from hamcrest instead of junit 4
c79fdfb66871a6bb2d643f0d4a0296bbb4c0bac0
<ide><path>spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java <ide> import org.springframework.util.ObjectUtils; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java <ide> import org.springframework.util.SerializationTestUtils; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.mockito.BDDMockito.*; <ide> <ide><path>spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java <ide> import static org.hamcrest.CoreMatchers.notNullValue; <ide> import static org.hamcrest.CoreMatchers.nullValue; <ide> import static org.hamcrest.Matchers.equalTo; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests for {@link ExtendedBeanInfoTests}. <ide><path>spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java <ide> <ide> import static org.hamcrest.CoreMatchers.equalTo; <ide> import static org.hamcrest.CoreMatchers.is; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java <ide> <ide> import org.junit.Test; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * Tests for {@link PropertyMatches}. <ide><path>spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * @author Chris Beams <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java <ide> import org.springframework.util.StringValueResolver; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.mockito.BDDMockito.*; <ide> <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java <ide> import org.springframework.core.io.ClassPathResource; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java <ide> import org.springframework.beans.factory.support.RootBeanDefinition; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; <ide> <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java <ide> import org.springframework.core.io.ByteArrayResource; <ide> import org.springframework.core.io.ClassPathResource; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> import static org.springframework.beans.factory.config.YamlProcessor.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java <ide> import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests for SPR-8954, in which a custom {@link InstantiationAwareBeanPostProcessor} <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java <ide> <ide> import static org.hamcrest.CoreMatchers.is; <ide> import static org.hamcrest.CoreMatchers.not; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.hasItems; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * Tests for propagating enclosing beans element defaults to nested beans elements. <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java <ide> import org.springframework.core.io.Resource; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests for new nested beans element support in Spring XML <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java <ide> import org.springframework.core.io.ClassPathResource; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests various combinations of profile declarations against various profile <ide><path>spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java <ide> import org.junit.Before; <ide> import org.junit.Rule; <ide> import org.junit.Test; <del>import org.junit.rules.ExpectedException; <ide> import org.junit.rules.TemporaryFolder; <ide> <ide> import org.springframework.context.index.sample.AbstractController; <ide> import org.springframework.stereotype.Component; <ide> import org.springframework.util.ClassUtils; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> import static org.springframework.context.index.processor.Metadata.*; <ide> <ide> /** <ide> public class CandidateComponentsIndexerTests { <ide> @Rule <ide> public TemporaryFolder temporaryFolder = new TemporaryFolder(); <ide> <del> @Rule <del> public ExpectedException thrown = ExpectedException.none(); <del> <ide> <ide> @Before <ide> public void createCompiler() throws IOException { <ide><path>spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java <ide> <ide> import org.junit.Test; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> import static org.springframework.context.index.processor.Metadata.*; <ide> <ide> /** <ide><path>spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java <ide> import org.springframework.cache.Cache; <ide> import org.springframework.cache.CacheManager; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java <ide> <ide> import static java.lang.annotation.ElementType.*; <ide> import static java.lang.annotation.RetentionPolicy.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.core.Is.*; <ide> import static org.hamcrest.core.StringContains.*; <ide> import static org.junit.Assert.*; <ide><path>spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java <ide> import org.springframework.validation.ObjectError; <ide> import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java <ide> import org.springframework.context.support.ClassPathXmlApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Integration test for Objenesis proxy creation. <ide><path>spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java <ide> import org.springframework.util.SerializationTestUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java <ide> import org.springframework.util.StopWatch; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java <ide> import org.junit.Test; <ide> import org.junit.rules.ExpectedException; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.core.Is.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java <ide> import org.springframework.core.annotation.AliasFor; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java <ide> import org.springframework.context.ConfigurableApplicationContext; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java <ide> import org.springframework.expression.spel.standard.SpelExpressionParser; <ide> import org.springframework.util.ReflectionUtils; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java <ide> <ide> import org.junit.Test; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * Tests for {@link SimpleKeyGenerator} and {@link SimpleKey}. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java <ide> import org.springframework.util.ObjectUtils; <ide> <ide> import static java.lang.String.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> import static org.springframework.util.StringUtils.*; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java <ide> import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; <ide> import org.springframework.beans.factory.config.BeanDefinition; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * @author Phillip Webb <ide><path>spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java <ide> import org.springframework.beans.factory.support.RootBeanDefinition; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java <ide> import org.springframework.stereotype.Service; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java <ide> import org.springframework.util.SerializationTestUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java <ide> import org.springframework.context.annotation.componentscan.level3.Level3Component; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests ensuring that configuration classes marked with @ComponentScan <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java <ide> import org.springframework.core.type.filter.TypeFilter; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests semantics of declaring {@link BeanFactoryPostProcessor}-returning @Bean <ide> public static TestBean testBean() { <ide> } <ide> } <ide> <del> <ide> } <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests cornering the issue reported in SPR-8080. If the product of a @Bean method <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java <ide> import org.springframework.stereotype.Component; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java <ide> import org.springframework.context.support.GenericXmlApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * @author Chris Beams <ide><path>spring-context/src/test/java/org/springframework/context/annotation/EnableAspectJAutoProxyTests.java <ide> import org.springframework.context.ConfigurableApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ImportAwareTests.java <ide> import org.springframework.util.Assert; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrarTests.java <ide> import org.springframework.core.type.AnnotationMetadata; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Integration tests for {@link ImportBeanDefinitionRegistrar}. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java <ide> import org.springframework.util.LinkedMultiValueMap; <ide> import org.springframework.util.MultiValueMap; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <del>import static org.mockito.Mockito.any; <ide> import static org.mockito.Mockito.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java <ide> import org.springframework.context.ApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests changes introduced for SPR-8874, allowing beans of primitive types to be looked <ide><path>spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java <ide> import org.springframework.util.ReflectionUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/RoleAndDescriptionAnnotationTests.java <ide> import org.springframework.context.annotation.role.ComponentWithoutRole; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests the use of the @Role and @Description annotation on @Bean methods and @Component classes. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java <ide> <ide> import org.springframework.beans.factory.BeanCreationException; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.core.Is.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * @author Stephane Nicoll <ide><path>spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java <ide> import org.springframework.context.support.ClassPathXmlApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests to verify that FactoryBean semantics are the same in Configuration <ide><path>spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java <ide> import org.springframework.beans.factory.support.RootBeanDefinition; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests for SPR-8954, in which a custom {@link InstantiationAwareBeanPostProcessor} <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationBeanNameTests.java <ide> import org.springframework.stereotype.Component; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests ensuring that configuration class bean names as expressed via @Configuration <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * System tests covering use of AspectJ {@link Aspect}s in conjunction with {@link Configuration} classes. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * A configuration class that registers a non-static placeholder configurer {@code @Bean} <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Ensures that @Configuration is supported properly as a meta-annotation. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests that @Import may be used both as a locally declared and meta-declared <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java <ide> import org.springframework.util.ClassUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/PackagePrivateBeanMethodInheritanceTests.java <ide> import org.springframework.context.annotation.Configuration; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Reproduces SPR-8756, which has been marked as "won't fix" for reasons <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java <ide> import org.springframework.context.annotation.Scope; <ide> import org.springframework.context.annotation.ScopedProxyMode; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * @author Phillip Webb <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java <ide> import org.springframework.util.ClassUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> public class Spr7167Tests { <add> <ide> @Test <ide> public void test() { <ide> ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(MyConfig.class); <ide> public void test() { <ide> MyConfig config = ctx.getBean(MyConfig.class); <ide> assertTrue("Config class was not enhanced", ClassUtils.isCglibProxy(config)); <ide> } <add> <ide> } <ide> <ide> @Configuration <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/spr9031/Spr9031Tests.java <ide> import org.springframework.context.annotation.configuration.spr9031.scanpackage.Spr9031Component; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests cornering bug SPR-9031. <ide><path>spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java <ide> import org.springframework.context.annotation.spr10546.scanpackage.AEnclosingConfig; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <del> * <ide> * @author Rob Winch <ide> */ <ide> public class Spr10546Tests { <ide> private void assertLoadsMyBean(Class<?>... annotatedClasses) { <ide> context = new AnnotationConfigApplicationContext(annotatedClasses); <ide> assertThat(context.getBean("myBean",String.class), equalTo("myBean")); <ide> } <add> <ide> } <ide><path>spring-context/src/test/java/org/springframework/context/annotation/spr8761/Spr8761Tests.java <ide> import org.springframework.stereotype.Component; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests cornering the regression reported in SPR-8761. <ide><path>spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java <ide> import org.springframework.validation.annotation.Validated; <ide> import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java <ide> import org.springframework.core.io.ClassPathResource; <ide> <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests for {@link CandidateComponentsIndexLoader}. <ide><path>spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java <ide> <ide> import org.junit.Test; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * Tests for {@link CandidateComponentsIndex}. <ide><path>spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java <ide> import org.springframework.lang.Nullable; <ide> import org.springframework.tests.sample.beans.ResourceTestBean; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java <ide> import org.springframework.core.env.Environment; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests covering the integration of the {@link Environment} into <ide><path>spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java <ide> <ide> import static java.lang.String.format; <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests integration between Environment and SecurityManagers. See SPR-9970. <ide><path>spring-context/src/test/java/org/springframework/context/support/GenericXmlApplicationContextTests.java <ide> import org.springframework.util.ClassUtils; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests for {@link GenericXmlApplicationContext}. <ide><path>spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java <ide> import org.springframework.tests.sample.beans.TestBean; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java <ide> import org.springframework.context.ConfigurableApplicationContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java <ide> <ide> import org.springframework.format.annotation.DateTimeFormat.ISO; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <ide> <ide> /** <ide> * Tests for {@link DateFormatter}. <ide><path>spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * @author Phillip Webb <ide><path>spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java <ide> <ide> import org.springframework.format.annotation.DateTimeFormat.ISO; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * @author Phillip Webb <ide><path>spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java <ide> <ide> import org.springframework.format.annotation.DateTimeFormat.ISO; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests for {@link JndiLocatorDelegate}. <ide><path>spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java <ide> import org.springframework.tests.mock.jndi.SimpleNamingContext; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java <ide> import org.junit.Test; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Unit tests for {@link AnnotationAsyncExecutionInterceptor}. <ide><path>spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java <ide> import java.util.concurrent.TimeUnit; <ide> <ide> import org.awaitility.Awaitility; <del>import org.junit.Assert; <ide> import org.junit.Test; <ide> import org.mockito.Mockito; <ide> <ide> import org.springframework.stereotype.Component; <ide> import org.springframework.util.ReflectionUtils; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide> public void findOnInterfaceWithCglibProxy() { <ide> } <ide> <ide> @Test <add> @SuppressWarnings("resource") <ide> public void exceptionThrownWithBeanNotOfRequiredTypeRootCause() { <ide> try { <ide> new AnnotationConfigApplicationContext(JdkProxyConfiguration.class); <ide> public void exceptionThrownWithBeanNotOfRequiredTypeRootCause() { <ide> while (ex.getCause() != null) { <ide> ex = ex.getCause(); <ide> } <del> Assert.assertThat(ex, instanceOf(BeanNotOfRequiredTypeException.class)); <add> assertThat(ex, instanceOf(BeanNotOfRequiredTypeException.class)); <ide> } <ide> } <ide> <ide><path>spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java <ide> import org.springframework.tests.Assume; <ide> import org.springframework.tests.TestGroup; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java <ide> import org.springframework.scheduling.support.ScheduledMethodRunnable; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java <ide> import org.springframework.validation.DefaultMessageCodesResolver.Format; <ide> <ide> import static org.hamcrest.Matchers.*; <del>import static org.junit.Assert.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> /** <ide> * Tests for {@link DefaultMessageCodesResolver}. <ide> public String format(String errorCode, String objectName, String field) { <ide> "CUSTOM-errorCode.objectName", <ide> "CUSTOM-errorCode" }))); <ide> } <add> <ide> } <ide><path>spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java <ide> <ide> import static java.lang.annotation.ElementType.*; <ide> import static java.lang.annotation.RetentionPolicy.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.core.Is.*; <ide> import static org.hamcrest.core.StringContains.*; <ide> import static org.junit.Assert.*; <ide><path>spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java <ide> import org.springframework.validation.FieldError; <ide> import org.springframework.validation.ObjectError; <ide> <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.hamcrest.Matchers.*; <ide> import static org.junit.Assert.*; <ide> <ide><path>src/test/java/com/foo/ComponentBeanDefinitionParserTests.java <ide> package com.foo; <ide> <ide> import static org.hamcrest.CoreMatchers.equalTo; <del>import static org.junit.Assert.assertThat; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> <ide> import java.util.List; <ide> <ide><path>src/test/java/org/springframework/cache/annotation/EnableCachingIntegrationTests.java <ide> import org.springframework.stereotype.Repository; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>src/test/java/org/springframework/core/env/EnvironmentSystemIntegrationTests.java <ide> import org.springframework.web.context.support.XmlWebApplicationContext; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; <ide> import static org.springframework.context.ConfigurableApplicationContext.*; <ide><path>src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java <ide> import org.springframework.transaction.annotation.Transactional; <ide> <ide> import static org.hamcrest.Matchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> import static org.mockito.BDDMockito.*; <ide> <ide><path>src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java <ide> import org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor; <ide> <ide> import static org.hamcrest.CoreMatchers.*; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.*; <ide> <ide> /** <ide><path>src/test/java/org/springframework/transaction/annotation/ProxyAnnotationDiscoveryTests.java <ide> <ide> import static org.hamcrest.CoreMatchers.instanceOf; <ide> import static org.hamcrest.CoreMatchers.not; <del>import static org.junit.Assert.assertThat; <add>import static org.hamcrest.MatcherAssert.assertThat; <ide> import static org.junit.Assert.assertTrue; <ide> <ide> import org.junit.Test;
102
PHP
PHP
improve doc block
8f0c385874d3baa35709be402ef40af339743f3d
<ide><path>src/ORM/Associations.php <ide> public function keys() { <ide> /** <ide> * Get an array of associations matching a specific type. <ide> * <del> * @param string $class <del> * @return array <add> * @param string $class The type of associations you want. For example 'BelongsTo' <add> * @return array An array of Association objects. <ide> */ <ide> public function type($class) { <ide> $out = array_filter($this->_items, function ($assoc) use ($class) {
1
Python
Python
add update stats time
877f31cbad9f6928e81a4737e2df5dc6f72f6d96
<ide><path>glances/__init__.py <ide> def start(config, args): <ide> <ide> # Start the main loop <ide> logger.debug("Glances started in {} seconds".format(start_duration.get())) <del> mode.serve_forever() <add> if args.stdout_issue: <add> # Serve once for issue/test mode <add> mode.serve_issue() <add> else: <add> # Serve forever <add> mode.serve_forever() <ide> <ide> # Shutdown <ide> mode.end() <ide><path>glances/outputs/glances_stdout_issue.py <ide> <ide> from glances.logger import logger <ide> from glances.compat import printandflush <add>from glances.timer import Counter <ide> <ide> try: <ide> TERMINAL_WIDTH = shutil.get_terminal_size(fallback=(79, 24)).columns <ide> except: <ide> TERMINAL_WIDTH = 79 <ide> <add> <ide> class colors: <ide> RED = '\033[91m' <ide> GREEN = '\033[92m' <ide> def disable(self): <ide> self.ORANGE = '' <ide> self.NO = '' <ide> <add> <ide> class GlancesStdoutIssue(object): <ide> <ide> """ <ide> def end(self): <ide> pass <ide> <ide> def print_issue(self, plugin, result, message): <del> sys.stdout.write('{}{}{}'.format(colors.BLUE + plugin, result, message)) <add> sys.stdout.write('{}{}{}'.format( <add> colors.BLUE + plugin, result, message)) <ide> sys.stdout.write(colors.NO + '\n') <ide> sys.stdout.flush() <ide> <ide> def update(self, <ide> duration=3): <ide> """Display issue <ide> """ <del> # printandflush(sorted(stats.getPluginsList())) <del> for plugin in sorted(stats.getPluginsList()): <add> for plugin in stats._plugins: <add> if stats._plugins[plugin].is_disable(): <add> # If current plugin is disable <add> # then continue to next plugin <add> result = colors.ORANGE + '[N/A]'.rjust(19 - len(plugin)) <add> message = colors.NO <add> self.print_issue(plugin, result, message) <add> continue <add> # Start the counter <add> counter = Counter() <add> counter.reset() <ide> stat = None <ide> stat_error = None <ide> try: <add> # Update the stats <add> stats._plugins[plugin].update() <add> # Get the stats <ide> stat = stats.get_plugin(plugin).get_export() <ide> except Exception as e: <ide> stat_error = e <ide> if stat_error is None: <del> result = colors.GREEN + '[OK] '.rjust(25 - len(plugin)) <del> message = colors.NO + str(stat)[0:TERMINAL_WIDTH-25] <add> result = (colors.GREEN + <add> '[OK] ' + <add> colors.BLUE + <add> ' {:.4f}s '.format(counter.get())).rjust(40 - len(plugin)) <add> message = colors.NO + str(stat)[0:TERMINAL_WIDTH-40] <ide> else: <del> result = colors.RED + '[ERROR] '.rjust(25 - len(plugin)) <del> message = colors.NO + str(stat_error)[0:TERMINAL_WIDTH-25] <add> result = (colors.RED + <add> '[ERROR]' + <add> colors.BLUE + <add> ' {:.4f}s '.format(counter.get())).rjust(40 - len(plugin)) <add> message = colors.NO + str(stat_error)[0:TERMINAL_WIDTH-40] <ide> self.print_issue(plugin, result, message) <ide> <ide> # Return True to exit directly (no refresh) <ide><path>glances/standalone.py <ide> def display_modules_list(self): <ide> print("Exporters list: {}".format( <ide> ', '.join(sorted(self.stats.getExportsList(enable=False))))) <ide> <del> def __serve_forever(self): <add> def serve_issue(self): <add> """Special mode for the --issue option <add> Update is done in the sceen.update function <add> """ <add> ret = not self.screen.update(self.stats) <add> self.end() <add> return ret <add> <add> def __serve_once(self): <ide> """Main loop for the CLI. <ide> <ide> return True if we should continue (no exit key has been pressed) <ide> def serve_forever(self): <ide> """Wrapper to the serve_forever function.""" <ide> loop = True <ide> while loop: <del> loop = self.__serve_forever() <add> loop = self.__serve_once() <ide> self.end() <ide> <ide> def end(self):
3
PHP
PHP
fix coding standards in config/
b06e15ce6f3c045d9a7e431aadbaac66a84e1a3a
<ide><path>lib/Cake/Config/routes.php <ide> * <ide> * You can disable the connection of default routes by deleting the require inside APP/Config/routes.php. <ide> */ <del> $prefixes = Router::prefixes(); <add>$prefixes = Router::prefixes(); <ide> <del> if ($plugins = CakePlugin::loaded()) { <del> App::uses('PluginShortRoute', 'Routing/Route'); <del> foreach ($plugins as $key => $value) { <del> $plugins[$key] = Inflector::underscore($value); <del> } <del> $pluginPattern = implode('|', $plugins); <del> $match = array('plugin' => $pluginPattern); <del> $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern); <del> <del> foreach ($prefixes as $prefix) { <del> $params = array('prefix' => $prefix, $prefix => true); <del> $indexParams = $params + array('action' => 'index'); <del> Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams); <del> Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match); <del> Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match); <del> } <del> Router::connect('/:plugin', array('action' => 'index'), $shortParams); <del> Router::connect('/:plugin/:controller', array('action' => 'index'), $match); <del> Router::connect('/:plugin/:controller/:action/*', array(), $match); <add>if ($plugins = CakePlugin::loaded()) { <add> App::uses('PluginShortRoute', 'Routing/Route'); <add> foreach ($plugins as $key => $value) { <add> $plugins[$key] = Inflector::underscore($value); <ide> } <add> $pluginPattern = implode('|', $plugins); <add> $match = array('plugin' => $pluginPattern); <add> $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern); <ide> <ide> foreach ($prefixes as $prefix) { <ide> $params = array('prefix' => $prefix, $prefix => true); <ide> $indexParams = $params + array('action' => 'index'); <del> Router::connect("/{$prefix}/:controller", $indexParams); <del> Router::connect("/{$prefix}/:controller/:action/*", $params); <add> Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams); <add> Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match); <add> Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match); <ide> } <del> Router::connect('/:controller', array('action' => 'index')); <del> Router::connect('/:controller/:action/*'); <add> Router::connect('/:plugin', array('action' => 'index'), $shortParams); <add> Router::connect('/:plugin/:controller', array('action' => 'index'), $match); <add> Router::connect('/:plugin/:controller/:action/*', array(), $match); <add>} <ide> <del> $namedConfig = Router::namedConfig(); <del> if ($namedConfig['rules'] === false) { <del> Router::connectNamed(true); <del> } <add>foreach ($prefixes as $prefix) { <add> $params = array('prefix' => $prefix, $prefix => true); <add> $indexParams = $params + array('action' => 'index'); <add> Router::connect("/{$prefix}/:controller", $indexParams); <add> Router::connect("/{$prefix}/:controller/:action/*", $params); <add>} <add>Router::connect('/:controller', array('action' => 'index')); <add>Router::connect('/:controller/:action/*'); <add> <add>$namedConfig = Router::namedConfig(); <add>if ($namedConfig['rules'] === false) { <add> Router::connectNamed(true); <add>} <ide> <del> unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, <del> $pluginPattern, $plugins, $key, $value); <add>unset($namedConfig, $params, $indexParams, $prefix, $prefixes, $shortParams, $match, <add> $pluginPattern, $plugins, $key, $value);
1
Text
Text
remove old system_errors
e02f511dccaf41f103403936359d43ce2ad86d1e
<ide><path>doc/api/errors.md <ide> The number of frames captured by the stack trace is bounded by the smaller of <ide> `Error.stackTraceLimit` or the number of available frames on the current event <ide> loop tick. <ide> <del>System-level errors are generated as augmented `Error` instances, which are <del>detailed [here](#errors_system_errors). <del> <ide> ## Class: AssertionError <ide> <ide> A subclass of `Error` that indicates the failure of an assertion. For details, <ide> Some exceptions are *unrecoverable* at the JavaScript layer. Such exceptions <ide> will *always* cause the Node.js process to crash. Examples include `assert()` <ide> checks or `abort()` calls in the C++ layer. <ide> <del>## System Errors <add>## Class: SystemError <ide> <ide> Node.js generates system errors when exceptions occur within its runtime <ide> environment. These usually occur when an application violates an operating <ide> system constraint. For example, a system error will occur if an application <ide> attempts to read a file that does not exist. <ide> <del>System errors are usually generated at the syscall level. For a comprehensive <del>list, see the [`errno`(3) man page][]. <del> <del>In Node.js, system errors are `Error` objects with extra properties. <del> <del>### Class: SystemError <del> <ide> * `address` {string} If present, the address to which a network connection <ide> failed <ide> * `code` {string} The string error code <ide> In Node.js, system errors are `Error` objects with extra properties. <ide> * `port` {number} If present, the network connection port that is not available <ide> * `syscall` {string} The name of the system call that triggered the error <ide> <del>#### error.address <add>### error.address <ide> <ide> * {string} <ide> <ide> If present, `error.address` is a string describing the address to which a <ide> network connection failed. <ide> <del>#### error.code <add>### error.code <ide> <ide> * {string} <ide> <ide> The `error.code` property is a string representing the error code. <ide> <del>#### error.dest <add>### error.dest <ide> <ide> * {string} <ide> <ide> If present, `error.dest` is the file path destination when reporting a file <ide> system error. <ide> <del>#### error.errno <add>### error.errno <ide> <ide> * {string|number} <ide> <ide> negative value which corresponds to the error code defined in <ide> (`deps/uv/include/uv/errno.h` in the Node.js source tree) for details. In case <ide> of a string, it is the same as `error.code`. <ide> <del>#### error.info <add>### error.info <ide> <ide> * {Object} <ide> <ide> If present, `error.info` is an object with details about the error condition. <ide> <del>#### error.message <add>### error.message <ide> <ide> * {string} <ide> <ide> `error.message` is a system-provided human-readable description of the error. <ide> <del>#### error.path <add>### error.path <ide> <ide> * {string} <ide> <ide> If present, `error.path` is a string containing a relevant invalid pathname. <ide> <del>#### error.port <add>### error.port <ide> <ide> * {number} <ide> <ide> If present, `error.port` is the network connection port that is not available. <ide> <del>#### error.syscall <add>### error.syscall <ide> <ide> * {string} <ide> <ide><path>doc/api/os.md <ide> The following process scheduling constants are exported by <ide> </tr> <ide> </table> <ide> <del>[`SystemError`]: errors.html#errors_system_errors <ide> [`process.arch`]: process.html#process_process_arch <ide> [`process.platform`]: process.html#process_process_platform <ide> [Android building]: https://github.com/nodejs/node/blob/master/BUILDING.md#androidandroid-based-devices-eg-firefox-os
2
Text
Text
add user import. refs #599
075b8c1037588a590360ab5290b25648367a26c5
<ide><path>docs/tutorial/4-authentication-and-permissions.md <ide> Because `'snippets'` is a *reverse* relationship on the User model, it will not <ide> <ide> We'll also add a couple of views to `views.py`. We'd like to just use read-only views for the user representations, so we'll use the `ListAPIView` and `RetrieveAPIView` generic class based views. <ide> <add> from django.contrib.auth.models import User <add> <add> <ide> class UserList(generics.ListAPIView): <ide> queryset = User.objects.all() <ide> serializer_class = UserSerializer
1
Javascript
Javascript
remove opacity property
88f399263d2718975f94fd5d2ca1cdc30db9e651
<ide><path>examples/js/loaders/SVGLoader.js <ide> THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype <ide> <ide> } <ide> <del> path.opacity = style.opacity || 1.0; <del> <ide> transformPath( path, currentTransform ); <ide> <ide> paths.push( path );
1
Javascript
Javascript
'(
9c27acebf97605027a38ea06d0262a3523396100
<ide><path>src/renderers/webgl/WebGLMaterials.js <del>import { BackSide } from "../../constants"; <add>import { BackSide } from "../../constants.js"; <ide> <ide> /** <del> * @author taphos / https://github.com/taphos <add> * @author mrdoob / http://mrdoob.com/ <ide> * <ide> * This is a helper which deals with webgl specific logic of builtin materials <ide> * i.e. uniforms refresh before material is being rendered
1
Ruby
Ruby
remove request and cookies helper methods
7191b038d829a1b5ae917ebb9298091c41f065b0
<ide><path>lib/action_cable/server.rb <ide> def worker_pool <ide> self.class.worker_pool <ide> end <ide> <del> def request <del> @request ||= ActionDispatch::Request.new(env) <del> end <del> <del> def cookies <del> request.cookie_jar <del> end <del> <ide> private <ide> def broadcast_ping_timestamp <ide> broadcast({ identifier: '_ping', message: Time.now.to_i }.to_json)
1
PHP
PHP
remove unused methods
4e29066129d270771ea4a4a894d440f7bcd90547
<ide><path>src/Console/Command/Task/ProjectTask.php <ide> public function bake($path) { <ide> return true; <ide> } <ide> <del>/** <del> * Enables Configure::read('Routing.prefixes') in /app/Config/routes.php <del> * <del> * @param string $name Name to use as admin routing <del> * @return bool Success <del> */ <del> public function cakeAdmin($name) { <del> $path = $this->appPath ?: APP; <del> $path .= 'Config/'; <del> $File = new File($path . 'routes.php'); <del> $contents = $File->read(); <del> if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(\]\[]*\);)%', $contents, $match)) { <del> $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', [\'' . $name . '\']);', $contents); <del> if ($File->write($result)) { <del> Configure::write('Routing.prefixes', [$name]); <del> return true; <del> } <del> } <del> return false; <del> } <del> <del>/** <del> * Checks for Configure::read('Routing.prefixes') and forces user to input it if not enabled <del> * <del> * @return string Admin route to use <del> */ <del> public function getPrefix() { <del> $admin = ''; <del> $prefixes = Configure::read('Routing.prefixes'); <del> if (!empty($prefixes)) { <del> if (count($prefixes) === 1) { <del> return $prefixes[0] . '_'; <del> } <del> if ($this->interactive) { <del> $this->out(); <del> $this->out(__d('cake_console', 'You have more than one routing prefix configured')); <del> } <del> $options = []; <del> foreach ($prefixes as $i => $prefix) { <del> $options[] = $i + 1; <del> if ($this->interactive) { <del> $this->out($i + 1 . '. ' . $prefix); <del> } <del> } <del> $selection = $this->in(__d('cake_console', 'Please choose a prefix to bake with.'), $options, 1); <del> return $prefixes[$selection - 1] . '_'; <del> } <del> if ($this->interactive) { <del> $this->hr(); <del> $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', <del> 'Configure::write(\'Routing.prefixes\', [\'admin\'])', <del> '/app/Config/routes.php')); <del> $this->out(__d('cake_console', 'What would you like the prefix route to be?')); <del> $this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller')); <del> while (!$admin) { <del> $admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin'); <del> } <del> if ($this->cakeAdmin($admin) !== true) { <del> $this->out(__d('cake_console', '<error>Unable to write to</error> %s.', '/app/Config/routes.php')); <del> $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', <del> 'Configure::write(\'Routing.prefixes\', [\'admin\'])', <del> '/app/Config/routes.php')); <del> return $this->_stop(); <del> } <del> return $admin . '_'; <del> } <del> return ''; <del> } <del> <ide> /** <ide> * get the option parser. <ide> * <ide><path>tests/TestCase/Console/Command/Task/ProjectTaskTest.php <ide> protected function _cloneRoutes() { <ide> $File->write($contents); <ide> } <ide> <del>/** <del> * test getPrefix method, and that it returns Routing.prefix or writes to config file. <del> * <del> * @return void <del> */ <del> public function testGetPrefix() { <del> Configure::write('Routing.prefixes', array('admin')); <del> $result = $this->Task->getPrefix(); <del> $this->assertEquals('admin_', $result); <del> <del> $this->_cloneRoutes(); <del> <del> Configure::write('Routing.prefixes', null); <del> $this->Task->appPath = TMP . 'BakeTestApp/'; <del> Configure::write('Routing.prefixes', null); <del> <del> $this->Task->expects($this->once())->method('in')->will($this->returnValue('super_duper_admin')); <del> <del> $result = $this->Task->getPrefix(); <del> $this->assertEquals('super_duper_admin_', $result); <del> } <del> <del>/** <del> * test cakeAdmin() writing routes.php <del> * <del> * @return void <del> */ <del> public function testCakeAdmin() { <del> $this->_cloneRoutes(); <del> <del> Configure::write('Routing.prefixes', null); <del> $this->Task->appPath = TMP . 'BakeTestApp/'; <del> $result = $this->Task->cakeAdmin('my_prefix'); <del> $this->assertTrue($result); <del> <del> $this->assertEquals(Configure::read('Routing.prefixes'), array('my_prefix')); <del> } <del> <del>/** <del> * test getting the prefix with more than one prefix setup <del> * <del> * @return void <del> */ <del> public function testGetPrefixWithMultiplePrefixes() { <del> Configure::write('Routing.prefixes', array('admin', 'ninja', 'shinobi')); <del> $this->Task->appPath = $this->Task->path . 'BakeTestApp/'; <del> $this->Task->expects($this->once())->method('in')->will($this->returnValue(2)); <del> <del> $result = $this->Task->getPrefix(); <del> $this->assertEquals('ninja_', $result); <del> } <ide> }
2
Ruby
Ruby
add test for installrenamed module
3b7c5af4315acdd8160d2308445a8ef6fe5141e6
<ide><path>Library/Homebrew/test/test_pathname.rb <ide> require 'testing_env' <ide> require 'tmpdir' <ide> require 'extend/pathname' <add>require 'install_renamed' <ide> <ide> class PathnameExtensionTests < Homebrew::TestCase <ide> include FileUtils <ide> def test_install_creates_intermediate_directories <ide> @dir.install(@file) <ide> assert_predicate @dir, :directory? <ide> end <add> <add> def test_install_renamed <add> @dir.extend(InstallRenamed) <add> <add> @file.write "a" <add> @dir.install @file <add> @file.write "b" <add> @dir.install @file <add> <add> assert_equal "a", File.read(@dir+@file.basename) <add> assert_equal "b", File.read(@dir+"#{@file.basename}.default") <add> end <ide> end
1
PHP
PHP
fix cs errors
3913bc0996fdb0eb13b2b9916cdb0e740418511e
<ide><path>src/Http/Runner.php <ide> */ <ide> namespace Cake\Http; <ide> <del>use Psr\Http\Message\ServerRequestInterface; <ide> use Psr\Http\Message\ResponseInterface; <add>use Psr\Http\Message\ServerRequestInterface; <ide> <ide> /** <ide> * Executes the middleware stack and provides the `next` callable <ide><path>src/Http/ServerRequestFactory.php <ide> protected static function updatePath($base, $request) <ide> * <ide> * This code is a copy/paste from Cake\Network\Request::_base() <ide> * <del> * @param \Psr\Http\Message\ServerRequestInterface <add> * @param \Psr\Http\Message\ServerRequestInterface $request The request. <ide> * @return array An array containing the [baseDir, webroot] <ide> */ <ide> protected static function getBase($request)
2
PHP
PHP
add strict typing to i18n\number
c60c23ace4cc6d39accf74f1e192f84d7bde4f4c
<ide><path>src/I18n/Number.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) <ide> * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) <ide> class Number <ide> * <ide> * - `locale`: The locale name to use for formatting the number, e.g. fr_FR <ide> * <del> * @param float $value A floating point number. <add> * @param float|string $value A floating point number. <ide> * @param int $precision The precision of the returned number. <ide> * @param array $options Additional options <ide> * @return string Formatted float. <ide> * @link https://book.cakephp.org/3.0/en/core-libraries/number.html#formatting-floating-point-numbers <ide> */ <del> public static function precision($value, $precision = 3, array $options = []) <add> public static function precision($value, int $precision = 3, array $options = []): string <ide> { <ide> $formatter = static::formatter(['precision' => $precision, 'places' => $precision] + $options); <ide> <ide> public static function precision($value, $precision = 3, array $options = []) <ide> /** <ide> * Returns a formatted-for-humans file size. <ide> * <del> * @param int $size Size in bytes <add> * @param int|string $size Size in bytes <ide> * @return string Human readable size <ide> * @link https://book.cakephp.org/3.0/en/core-libraries/number.html#interacting-with-human-readable-values <ide> */ <del> public static function toReadableSize($size) <add> public static function toReadableSize($size): string <ide> { <add> $size = (int)$size; <add> <ide> switch (true) { <ide> case $size < 1024: <ide> return __dn('cake', '{0,number,integer} Byte', '{0,number,integer} Bytes', $size, $size); <ide> public static function toReadableSize($size) <ide> * - `multiply`: Multiply the input value by 100 for decimal percentages. <ide> * - `locale`: The locale name to use for formatting the number, e.g. fr_FR <ide> * <del> * @param float $value A floating point number <add> * @param float|string $value A floating point number <ide> * @param int $precision The precision of the returned number <ide> * @param array $options Options <ide> * @return string Percentage string <ide> * @link https://book.cakephp.org/3.0/en/core-libraries/number.html#formatting-percentages <ide> */ <del> public static function toPercentage($value, $precision = 2, array $options = []) <add> public static function toPercentage($value, int $precision = 2, array $options = []): string <ide> { <ide> $options += ['multiply' => false]; <ide> if ($options['multiply']) { <ide> public static function toPercentage($value, $precision = 2, array $options = []) <ide> * - `before` - The string to place before whole numbers, e.g. '[' <ide> * - `after` - The string to place after decimal numbers, e.g. ']' <ide> * <del> * @param float $value A floating point number. <add> * @param float|string $value A floating point number. <ide> * @param array $options An array with options. <ide> * @return string Formatted number <ide> */ <del> public static function format($value, array $options = []) <add> public static function format($value, array $options = []): string <ide> { <ide> $formatter = static::formatter($options); <ide> $options += ['before' => '', 'after' => '']; <ide> public static function format($value, array $options = []) <ide> * @param array $options An array with options. <ide> * @return float point number <ide> */ <del> public static function parseFloat($value, array $options = []) <add> public static function parseFloat(string $value, array $options = []): float <ide> { <ide> $formatter = static::formatter($options); <ide> <ide> public static function parseFloat($value, array $options = []) <ide> * - `before` - The string to place before whole numbers, e.g. '[' <ide> * - `after` - The string to place after decimal numbers, e.g. ']' <ide> * <del> * @param float $value A floating point number <add> * @param float|string $value A floating point number <ide> * @param array $options Options list. <ide> * @return string formatted delta <ide> */ <del> public static function formatDelta($value, array $options = []) <add> public static function formatDelta($value, array $options = []): string <ide> { <ide> $options += ['places' => 0]; <del> $value = number_format($value, $options['places'], '.', ''); <add> $value = number_format((float)$value, $options['places'], '.', ''); <ide> $sign = $value > 0 ? '+' : ''; <ide> $options['before'] = isset($options['before']) ? $options['before'] . $sign : $sign; <ide> <ide> public static function formatDelta($value, array $options = []) <ide> * - `useIntlCode` - Whether or not to replace the currency symbol with the international <ide> * currency code. <ide> * <del> * @param float $value Value to format. <add> * @param floatt|string $value Value to format. <ide> * @param string|null $currency International currency name such as 'USD', 'EUR', 'JPY', 'CAD' <ide> * @param array $options Options list. <ide> * @return string Number formatted as a currency. <ide> */ <del> public static function currency($value, $currency = null, array $options = []) <add> public static function currency($value, ?string $currency = null, array $options = []): string <ide> { <ide> $value = (float)$value; <ide> $currency = $currency ?: static::defaultCurrency(); <ide> public static function currency($value, $currency = null, array $options = []) <ide> * currently stored value <ide> * @return string|null Currency <ide> */ <del> public static function defaultCurrency($currency = null) <add> public static function defaultCurrency($currency = null): ?string <ide> { <ide> if (!empty($currency)) { <ide> return self::$_defaultCurrency = $currency; <ide> public static function defaultCurrency($currency = null) <ide> * @param array $options An array with options. <ide> * @return \NumberFormatter The configured formatter instance <ide> */ <del> public static function formatter($options = []) <add> public static function formatter(array $options = []): NumberFormatter <ide> { <ide> $locale = $options['locale'] ?? ini_get('intl.default_locale'); <ide> <ide> public static function formatter($options = []) <ide> * @param array $options See Number::formatter() for possible options. <ide> * @return void <ide> */ <del> public static function config($locale, $type = NumberFormatter::DECIMAL, array $options = []) <add> public static function config(string $locale, int $type = NumberFormatter::DECIMAL, array $options = []): void <ide> { <ide> static::$_formatters[$locale][$type] = static::_setAttributes( <ide> new NumberFormatter($locale, $type), <ide> public static function config($locale, $type = NumberFormatter::DECIMAL, array $ <ide> * @param array $options See Number::formatter() for possible options. <ide> * @return \NumberFormatter <ide> */ <del> protected static function _setAttributes(NumberFormatter $formatter, array $options = []) <add> protected static function _setAttributes(NumberFormatter $formatter, array $options = []): NumberFormatter <ide> { <ide> if (isset($options['places'])) { <ide> $formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $options['places']); <ide> protected static function _setAttributes(NumberFormatter $formatter, array $opti <ide> * @param array $options An array with options. <ide> * @return string <ide> */ <del> public static function ordinal($value, array $options = []) <add> public static function ordinal($value, array $options = []): string <ide> { <ide> return static::formatter(['type' => NumberFormatter::ORDINAL] + $options)->format($value); <ide> } <ide><path>tests/TestCase/I18n/NumberTest.php <ide> <?php <add>declare(strict_types=1); <ide> /** <ide> * NumberTest file <ide> *
2
Javascript
Javascript
add failing tests
36b612e8af0d10ad2178b3d20ba5c3319a9a6a1b
<ide><path>test/configCases/parsing/harmony-this/abc.js <ide> function returnThis() { <del> if(typeof this === "undefined") return "undefined"; <add> if (typeof this === "undefined") return "undefined"; <ide> return this; <ide> } <ide> <ide> var a = returnThis; <ide> var b = returnThis; <ide> <del>export { <del> a, <del> b <del>} <add>export { a, b }; <ide> <ide> export const that = this; <ide> export const returnThisArrow = () => this; <ide> export class C { <ide> <ide> export const extendThisClass = () => { <ide> return class extends this.Buffer {}; <del>} <add>}; <ide> <ide> export function D() { <ide> this.prop = () => "ok"; <ide> } <ide> <add>// See https://github.com/webpack/webpack/issues/6379 <add>export const E = { <add> x: "bar", <add> foo(x = this.x) { <add> return x; <add> } <add>}; <add> <add>// See https://github.com/webpack/webpack/issues/6967 <add>export const F = function() { <add> return this; <add>}.call("ok"); <add> <add>export function f1(x = this.x) { <add> return x; <add>} <add> <add>export const f2 = function(x = this.x) { <add> return x; <add>}; <add> <add>export const f3 = (x = this) => x; <add> <add>export function G(x) { <add> this.x = x; <add> this.getX = (y = this.x) => y; <add>} <add> <ide> export default returnThis; <ide><path>test/configCases/parsing/harmony-this/index.js <ide> "use strict"; <ide> <del>import d, {a, b as B, C as _C, D as _D, extendThisClass, returnThisArrow, returnThisMember, that} from "./abc"; <add>import should from "should"; <add>import {extendThisClass, returnThisArrow, returnThisMember, that} from "./abc"; <add>import d, {a, b as B, C as _C, D as _D, E, F, f1, f2, f3, G} from "./abc"; <ide> <ide> import * as abc from "./abc"; <ide> <ide> it("should not break classes and functions", function() { <ide> (new _C).foo().should.be.eql("bar"); <ide> (new _C).bar().should.be.eql("bar"); <ide> (new _D).prop().should.be.eql("ok"); <add> E.foo().should.be.eql("bar"); <add> F.should.be.eql("ok"); <add> f1.call({x: "f1"}).should.be.eql("f1"); <add> f2.call({x: "f2"}).should.be.eql("f2"); <add> should(f3.call("f3")).be.eql(undefined); <add> should(f3()).be.eql(undefined); <add> (new G("ok")).getX().should.be.eql("ok"); <ide> }); <ide> <ide> function x() { throw new Error("should not be executed"); }
2
Python
Python
add kl divergence to metrics
999f4028295217324be0fe12487444fc510ca6f2
<ide><path>keras/metrics.py <ide> def binary_crossentropy(y_true, y_pred): <ide> return K.mean(K.binary_crossentropy(y_pred, y_true)) <ide> <ide> <add>def kullback_leibler_divergence(y_true, y_pred): <add> y_true = K.clip(y_true, K.epsilon(), 1) <add> y_pred = K.clip(y_pred, K.epsilon(), 1) <add> return K.sum(y_true * K.log(y_true / y_pred), axis=-1) <add> <add> <ide> def poisson(y_true, y_pred): <ide> return K.mean(y_pred - y_true * K.log(y_pred + K.epsilon())) <ide>
1
Javascript
Javascript
improve the code in test-crypto-dh
5520e40af3c3f8780ae012e8b244d4c305152870
<ide><path>test/parallel/test-crypto-dh.js <ide> let key2 = dh2.generateKeys('hex'); <ide> let secret1 = dh1.computeSecret(key2, 'hex', 'base64'); <ide> let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); <ide> <del>assert.strictEqual(secret1, secret2.toString('base64')); <add>assert.strictEqual(secret2.toString('base64'), secret1); <ide> assert.strictEqual(dh1.verifyError, 0); <ide> assert.strictEqual(dh2.verifyError, 0); <ide> <del>assert.throws(function() { <add>const argumentsError = <add> /^TypeError: First argument should be number, string or Buffer$/; <add> <add>assert.throws(() => { <ide> crypto.createDiffieHellman([0x1, 0x2]); <del>}); <add>}, argumentsError); <ide> <del>assert.throws(function() { <del> crypto.createDiffieHellman(function() { }); <del>}); <add>assert.throws(() => { <add> crypto.createDiffieHellman(() => { }); <add>}, argumentsError); <ide> <del>assert.throws(function() { <add>assert.throws(() => { <ide> crypto.createDiffieHellman(/abc/); <del>}); <add>}, argumentsError); <ide> <del>assert.throws(function() { <add>assert.throws(() => { <ide> crypto.createDiffieHellman({}); <del>}); <add>}, argumentsError); <ide> <ide> // Create "another dh1" using generated keys from dh1, <ide> // and compute secret again <ide> const secret3 = dh3.computeSecret(key2, 'hex', 'base64'); <ide> <ide> assert.strictEqual(secret1, secret3); <ide> <add>const wrongBlockLength = <add> new RegExp('^Error: error:0606506D:digital envelope' + <add> ' routines:EVP_DecryptFinal_ex:wrong final block length$'); <add> <ide> // Run this one twice to make sure that the dh3 clears its error properly <ide> { <ide> const c = crypto.createDecipheriv('aes-128-ecb', crypto.randomBytes(16), ''); <del> assert.throws(function() { c.final('utf8'); }, /wrong final block length/); <add> assert.throws(() => { <add> c.final('utf8'); <add> }, wrongBlockLength); <ide> } <ide> <del>assert.throws(function() { <del> dh3.computeSecret(''); <del>}, /key is too small/i); <del> <ide> { <ide> const c = crypto.createDecipheriv('aes-128-ecb', crypto.randomBytes(16), ''); <del> assert.throws(function() { c.final('utf8'); }, /wrong final block length/); <add> assert.throws(() => { <add> c.final('utf8'); <add> }, wrongBlockLength); <ide> } <ide> <add>assert.throws(() => { <add> dh3.computeSecret(''); <add>}, /^Error: Supplied key is too small$/); <add> <ide> // Create a shared using a DH group. <ide> const alice = crypto.createDiffieHellmanGroup('modp5'); <ide> const bob = crypto.createDiffieHellmanGroup('modp5'); <ide> assert(firstByte === 6 || firstByte === 7); <ide> const ecdh3 = crypto.createECDH('secp256k1'); <ide> const key3 = ecdh3.generateKeys(); <ide> <del>assert.throws(function() { <add>assert.throws(() => { <ide> ecdh2.computeSecret(key3, 'latin1', 'buffer'); <del>}); <add>}, /^Error: Failed to translate Buffer to a EC_POINT$/); <ide> <ide> // ECDH should allow .setPrivateKey()/.setPublicKey() <ide> const ecdh4 = crypto.createECDH('prime256v1'); <ide> <ide> ecdh4.setPrivateKey(ecdh1.getPrivateKey()); <ide> ecdh4.setPublicKey(ecdh1.getPublicKey()); <ide> <del>assert.throws(function() { <add>assert.throws(() => { <ide> ecdh4.setPublicKey(ecdh3.getPublicKey()); <del>}, /Failed to convert Buffer to EC_POINT/); <add>}, /^Error: Failed to convert Buffer to EC_POINT$/); <ide> <ide> // Verify that we can use ECDH without having to use newly generated keys. <ide> const ecdh5 = crypto.createECDH('secp256k1'); <ide> <ide> // Verify errors are thrown when retrieving keys from an uninitialized object. <del>assert.throws(function() { <add>assert.throws(() => { <ide> ecdh5.getPublicKey(); <del>}, /Failed to get ECDH public key/); <del>assert.throws(function() { <add>}, /^Error: Failed to get ECDH public key$/); <add> <add>assert.throws(() => { <ide> ecdh5.getPrivateKey(); <del>}, /Failed to get ECDH private key/); <add>}, /^Error: Failed to get ECDH private key$/); <ide> <ide> // A valid private key for the secp256k1 curve. <ide> const cafebabeKey = 'cafebabe'.repeat(8); <ide> assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); <ide> // Show why allowing the public key to be set on this type does not make sense. <ide> ecdh5.setPublicKey(peerPubPtComp, 'hex'); <ide> assert.strictEqual(ecdh5.getPublicKey('hex'), peerPubPtUnComp); <del>assert.throws(function() { <add>assert.throws(() => { <ide> // Error because the public key does not match the private key anymore. <ide> ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'); <del>}, /Invalid key pair/); <add>}, /^Error: Invalid key pair$/); <ide> <ide> // Set to a valid key to show that later attempts to set an invalid key are <ide> // rejected. <ide> ecdh5.setPrivateKey(cafebabeKey, 'hex'); <ide> '0000000000000000000000000000000000000000000000000000000000000000', <ide> 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', <ide> 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', <del>].forEach(function(element, index, object) { <del> assert.throws(function() { <add>].forEach((element) => { <add> assert.throws(() => { <ide> ecdh5.setPrivateKey(element, 'hex'); <del> }, /Private key is not valid for specified curve/); <add> }, /^Error: Private key is not valid for specified curve.$/); <ide> // Verify object state did not change. <ide> assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey); <ide> });
1
PHP
PHP
add commented code
69d0c504e3ff01e0fd219e02ebac9b1c22151c2a
<ide><path>app/Providers/RouteServiceProvider.php <ide> class RouteServiceProvider extends ServiceProvider <ide> */ <ide> public const HOME = '/home'; <ide> <add> /** <add> * The controller namespace for the application. <add> * <add> * @var string|null <add> */ <add> // protected $namespace = 'App\\Http\\Controllers'; <add> <ide> /** <ide> * Define your route model bindings, pattern filters, etc. <ide> *
1
Ruby
Ruby
link binaries in sbin as well as bin
1c5564264514535a951ee0129022e3ff8925e778
<ide><path>Library/Homebrew/brew.h.rb <ide> def prune <ide> $d=0 <ide> <ide> dirs=Array.new <del> paths=%w[bin etc lib include share].collect {|d| HOMEBREW_PREFIX+d} <add> paths=%w[bin sbin etc lib include share].collect {|d| HOMEBREW_PREFIX+d} <ide> <ide> paths.each do |path| <ide> path.find do |path| <ide> def initialize f <ide> share=f.prefix+'share' <ide> (f.prefix+'man').mv share rescue nil <ide> <del> [f.bin, f.lib].each {|d| clean_dir d} <add> [f.bin, f.sbin, f.lib].each {|d| clean_dir d} <ide> <ide> # you can read all of this shit online nowadays, save the space <ide> # info pages are shit, everyone agrees apart from Richard Stallman <ide><path>Library/Homebrew/formula.rb <ide> def path <ide> attr_reader :url, :version, :url, :homepage, :name <ide> <ide> def bin; prefix+'bin' end <add> def sbin; prefix+'sbin' end <ide> def doc; prefix+'share'+'doc'+name end <ide> def lib; prefix+'lib' end <ide> def man; prefix+'share'+'man' end <ide><path>Library/Homebrew/keg.rb <ide> def link <ide> # these dirs REMEMBER that *NOT* everything needs to be in the main tree <ide> link_dir('etc') {:mkpath} <ide> link_dir('bin') {:link} <add> link_dir('sbin') {:link} <ide> link_dir('lib') {|path| :mkpath if %w[pkgconfig php perl5].include? path.to_s} <ide> link_dir('include') {:link} <ide> link_dir('share') {|path| :mkpath if mkpaths.include? path.to_s}
3
Java
Java
update netty4clienthttprequestfactory buffer size
fd426aaa4df5ae08b448d21541d375f9a9d5b3a6
<ide><path>spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequest.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2015 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> import org.springframework.util.concurrent.ListenableFuture; <ide> import org.springframework.util.concurrent.SettableListenableFuture; <ide> <add> <ide> /** <ide> * {@link org.springframework.http.client.ClientHttpRequest} implementation that uses <ide> * Netty 4 to execute requests. <ide> * <ide> * <p>Created via the {@link Netty4ClientHttpRequestFactory}. <ide> * <ide> * @author Arjen Poutsma <add> * @author Rossen Stoyanchev <ide> * @since 4.1.2 <ide> */ <ide> class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements ClientHttpRequest { <ide> class Netty4ClientHttpRequest extends AbstractAsyncClientHttpRequest implements <ide> private final ByteBufOutputStream body; <ide> <ide> <del> public Netty4ClientHttpRequest(Bootstrap bootstrap, URI uri, HttpMethod method, int maxRequestSize) { <add> public Netty4ClientHttpRequest(Bootstrap bootstrap, URI uri, HttpMethod method) { <ide> this.bootstrap = bootstrap; <ide> this.uri = uri; <ide> this.method = method; <del> this.body = new ByteBufOutputStream(Unpooled.buffer(maxRequestSize)); <add> this.body = new ByteBufOutputStream(Unpooled.buffer(1024)); <ide> } <ide> <ide> <ide><path>spring-web/src/main/java/org/springframework/http/client/Netty4ClientHttpRequestFactory.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2015 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> import org.springframework.http.HttpMethod; <ide> import org.springframework.util.Assert; <ide> <add> <ide> /** <ide> * {@link org.springframework.http.client.ClientHttpRequestFactory} implementation that <ide> * uses <a href="http://netty.io/">Netty 4</a> to create requests. <ide> * across multiple clients. <ide> * <ide> * @author Arjen Poutsma <add> * @author Rossen Stoyanchev <ide> * @since 4.1.2 <ide> */ <ide> public class Netty4ClientHttpRequestFactory implements ClientHttpRequestFactory, <ide> AsyncClientHttpRequestFactory, InitializingBean, DisposableBean { <ide> <ide> /** <del> * The default maximum request size. <del> * @see #setMaxRequestSize(int) <add> * The default maximum response size. <add> * @see #setMaxResponseSize(int) <ide> */ <del> public static final int DEFAULT_MAX_REQUEST_SIZE = 1024 * 1024 * 10; <add> public static final int DEFAULT_MAX_RESPONSE_SIZE = 1024 * 1024 * 10; <ide> <ide> <ide> private final EventLoopGroup eventLoopGroup; <ide> <ide> private final boolean defaultEventLoopGroup; <ide> <del> private int maxRequestSize = DEFAULT_MAX_REQUEST_SIZE; <add> private int maxResponseSize = DEFAULT_MAX_RESPONSE_SIZE; <ide> <ide> private SslContext sslContext; <ide> <ide> public Netty4ClientHttpRequestFactory(EventLoopGroup eventLoopGroup) { <ide> <ide> <ide> /** <del> * Set the default maximum request size. <del> * <p>By default this is set to {@link #DEFAULT_MAX_REQUEST_SIZE}. <add> * Set the default maximum response size. <add> * <p>By default this is set to {@link #DEFAULT_MAX_RESPONSE_SIZE}. <ide> * @see HttpObjectAggregator#HttpObjectAggregator(int) <add> * @since 4.1.5 <ide> */ <del> public void setMaxRequestSize(int maxRequestSize) { <del> this.maxRequestSize = maxRequestSize; <add> public void setMaxResponseSize(int maxResponseSize) { <add> this.maxResponseSize = maxResponseSize; <ide> } <ide> <ide> /** <ide> protected void initChannel(SocketChannel channel) throws Exception { <ide> pipeline.addLast(sslContext.newHandler(channel.alloc())); <ide> } <ide> pipeline.addLast(new HttpClientCodec()); <del> pipeline.addLast(new HttpObjectAggregator(maxRequestSize)); <add> pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); <ide> } <ide> }); <ide> this.bootstrap = bootstrap; <ide> public AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod) <ide> } <ide> <ide> private Netty4ClientHttpRequest createRequestInternal(URI uri, HttpMethod httpMethod) { <del> return new Netty4ClientHttpRequest(getBootstrap(), uri, httpMethod, this.maxRequestSize); <add> return new Netty4ClientHttpRequest(getBootstrap(), uri, httpMethod); <ide> } <ide> <ide>
2
PHP
PHP
allow base url
1a383120a5b39c501cef9cab2a835ea076cc0eb6
<ide><path>src/Illuminate/Http/Client/PendingRequest.php <ide> class PendingRequest <ide> */ <ide> protected $factory; <ide> <add> /** <add> * The base URL for the request. <add> * <add> * @var string <add> */ <add> protected $baseUrl = ''; <add> <ide> /** <ide> * The request body format. <ide> * <ide> public function __construct(Factory $factory = null) <ide> }]); <ide> } <ide> <add> /** <add> * Set the base URL for the pending request. <add> * <add> * @param string $url <add> * @return $this <add> */ <add> public function baseUrl(string $url) <add> { <add> $this->baseUrl = $url; <add> <add> return $this; <add> } <add> <ide> /** <ide> * Indicate the request contains JSON. <ide> * <ide> public function delete($url, $data = []) <ide> */ <ide> public function send(string $method, string $url, array $options = []) <ide> { <add> $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/'); <add> <ide> if (isset($options[$this->bodyFormat])) { <ide> $options[$this->bodyFormat] = array_merge( <ide> $options[$this->bodyFormat], $this->pendingFiles
1
Go
Go
move plugin shutdown after layerstore shtudown
4b400ecc4df4bcf245f1f751a7fd0c9c193d9dbf
<ide><path>daemon/daemon.go <ide> func (daemon *Daemon) Shutdown() error { <ide> }) <ide> } <ide> <del> // Shutdown plugins after containers. Don't change the order. <add> if daemon.layerStore != nil { <add> if err := daemon.layerStore.Cleanup(); err != nil { <add> logrus.Errorf("Error during layer Store.Cleanup(): %v", err) <add> } <add> } <add> <add> // Shutdown plugins after containers and layerstore. Don't change the order. <ide> daemon.pluginShutdown() <ide> <ide> // trigger libnetwork Stop only if it's initialized <ide> if daemon.netController != nil { <ide> daemon.netController.Stop() <ide> } <ide> <del> if daemon.layerStore != nil { <del> if err := daemon.layerStore.Cleanup(); err != nil { <del> logrus.Errorf("Error during layer Store.Cleanup(): %v", err) <del> } <del> } <del> <ide> if err := daemon.cleanupMounts(); err != nil { <ide> return err <ide> }
1
Javascript
Javascript
add test for functor
d756660748bddaba66e9a642b5c1fd4ec05d4bc7
<ide><path>test/core/functor-test.js <add>require("../env"); <add>require("../../d3"); <add> <add>var vows = require("vows"), <add> assert = require("assert"); <add> <add>var suite = vows.describe("d3.functor"); <add> <add>suite.addBatch({ <add> "functor": { <add> topic: function() { <add> return d3.functor; <add> }, <add> "when passed a function, returns the function": function(functor) { <add> function foo() {} <add> assert.strictEqual(functor(foo), foo); <add> }, <add> "when passed a non-function, returns a wrapper function": function(functor) { <add> var a = {}; <add> assert.isNull(functor(null)()); <add> assert.isUndefined(functor(undefined)()); <add> assert.strictEqual(functor(a)(), a); <add> assert.strictEqual(functor(1)(), 1); <add> assert.deepEqual(functor([1])(), [1]); <add> } <add> } <add>}); <add> <add>suite.export(module);
1
Go
Go
fix testcases that expect trailing whitespace
e16e9775d48b6cd0cc7b4a66114d1b9680aa2f31
<ide><path>cli/command/container/ps.go <ide> func runPs(dockerCli *command.DockerCli, opts *psOptions) error { <ide> if len(dockerCli.ConfigFile().PsFormat) > 0 && !opts.quiet { <ide> format = dockerCli.ConfigFile().PsFormat <ide> } else { <del> format = "table" <add> format = formatter.TableFormatKey <ide> } <ide> } <ide> <ide> containerCtx := formatter.Context{ <ide> Output: dockerCli.Out(), <del> Format: formatter.NewContainerFormat(format, opts.quiet, opts.size), <add> Format: formatter.NewContainerFormat(format, opts.quiet, listOptions.Size), <ide> Trunc: !opts.noTrunc, <ide> } <ide> return formatter.ContainerWrite(containerCtx, containers) <ide><path>cli/command/formatter/container.go <ide> func NewContainerFormat(source string, quiet bool, size bool) Format { <ide> if quiet { <ide> return `container_id: {{.ID}}` <ide> } <del> format := `container_id: {{.ID}}\nimage: {{.Image}}\ncommand: {{.Command}}\ncreated_at: {{.CreatedAt}}\nstatus: {{.Status}}\nnames: {{.Names}}\nlabels: {{.Labels}}\nports: {{.Ports}}\n` <add> format := `container_id: {{.ID}} <add>image: {{.Image}} <add>command: {{.Command}} <add>created_at: {{.CreatedAt}} <add>status: {{- pad .Status 1 0}} <add>names: {{.Names}} <add>labels: {{- pad .Labels 1 0}} <add>ports: {{- pad .Ports 1 0}} <add>` <ide> if size { <ide> format += `size: {{.Size}}\n` <ide> } <ide><path>cli/command/formatter/volume.go <ide> func NewVolumeFormat(source string, quiet bool) Format { <ide> func VolumeWrite(ctx Context, volumes []*types.Volume) error { <ide> render := func(format func(subContext subContext) error) error { <ide> for _, volume := range volumes { <del> if err := format(&volumeContext{v: volume}); err != nil { <add> if err := format(&volumeContext{v: *volume}); err != nil { <ide> return err <ide> } <ide> } <ide> func VolumeWrite(ctx Context, volumes []*types.Volume) error { <ide> <ide> type volumeContext struct { <ide> HeaderContext <del> v *types.Volume <add> v types.Volume <ide> } <ide> <ide> func (c *volumeContext) Name() string { <ide><path>cli/command/formatter/volume_test.go <ide> func TestVolumeContext(t *testing.T) { <ide> call func() string <ide> }{ <ide> {volumeContext{ <del> v: &types.Volume{Name: volumeName}, <add> v: types.Volume{Name: volumeName}, <ide> }, volumeName, nameHeader, ctx.Name}, <ide> {volumeContext{ <del> v: &types.Volume{Driver: "driver_name"}, <add> v: types.Volume{Driver: "driver_name"}, <ide> }, "driver_name", driverHeader, ctx.Driver}, <ide> {volumeContext{ <del> v: &types.Volume{Scope: "local"}, <add> v: types.Volume{Scope: "local"}, <ide> }, "local", scopeHeader, ctx.Scope}, <ide> {volumeContext{ <del> v: &types.Volume{Mountpoint: "mountpoint"}, <add> v: types.Volume{Mountpoint: "mountpoint"}, <ide> }, "mountpoint", mountpointHeader, ctx.Mountpoint}, <ide> {volumeContext{ <del> v: &types.Volume{}, <add> v: types.Volume{}, <ide> }, "", labelsHeader, ctx.Labels}, <ide> {volumeContext{ <del> v: &types.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}}, <add> v: types.Volume{Labels: map[string]string{"label1": "value1", "label2": "value2"}}, <ide> }, "label1=value1,label2=value2", labelsHeader, ctx.Labels}, <ide> } <ide> <ide><path>cli/command/image/images.go <ide> func runImages(dockerCli *command.DockerCli, opts imagesOptions) error { <ide> if len(dockerCli.ConfigFile().ImagesFormat) > 0 && !opts.quiet { <ide> format = dockerCli.ConfigFile().ImagesFormat <ide> } else { <del> format = "table" <add> format = formatter.TableFormatKey <ide> } <ide> } <ide> <ide><path>cli/command/network/list.go <ide> func runList(dockerCli *command.DockerCli, opts listOptions) error { <ide> if len(dockerCli.ConfigFile().NetworksFormat) > 0 && !opts.quiet { <ide> format = dockerCli.ConfigFile().NetworksFormat <ide> } else { <del> format = "table" <add> format = formatter.TableFormatKey <ide> } <ide> } <ide> <ide><path>cli/command/volume/list.go <ide> func runList(dockerCli *command.DockerCli, opts listOptions) error { <ide> if len(dockerCli.ConfigFile().VolumesFormat) > 0 && !opts.quiet { <ide> format = dockerCli.ConfigFile().VolumesFormat <ide> } else { <del> format = "table" <add> format = formatter.TableFormatKey <ide> } <ide> } <ide> <ide><path>utils/templates/templates.go <ide> var basicFunctions = template.FuncMap{ <ide> "title": strings.Title, <ide> "lower": strings.ToLower, <ide> "upper": strings.ToUpper, <add> "pad": padWithSpace, <ide> } <ide> <ide> // Parse creates a new annonymous template with the basic functions <ide> func Parse(format string) (*template.Template, error) { <ide> func NewParse(tag, format string) (*template.Template, error) { <ide> return template.New(tag).Funcs(basicFunctions).Parse(format) <ide> } <add> <add>// padWithSpace adds whitespace to the input if the input is non-empty <add>func padWithSpace(source string, prefix, suffix int) string { <add> if source == "" { <add> return source <add> } <add> return strings.Repeat(" ", prefix) + source + strings.Repeat(" ", suffix) <add>}
8
Python
Python
pass platformversion only for fargate launch type
068ded96cd279dcd51f5b6d1e96f09205ecf40c8
<ide><path>airflow/contrib/operators/ecs_operator.py <ide> def execute(self, context): <ide> 'overrides': self.overrides, <ide> 'startedBy': self.owner, <ide> 'launchType': self.launch_type, <del> 'platformVersion': self.platform_version, <ide> } <add> <add> if self.launch_type == 'FARGATE': <add> run_opts['platformVersion'] = self.platform_version <ide> if self.group is not None: <ide> run_opts['group'] = self.group <ide> if self.placement_constraints is not None: <ide><path>tests/contrib/operators/test_ecs_operator.py <ide> import unittest <ide> from copy import deepcopy <ide> <add>from parameterized import parameterized <add> <ide> from airflow import configuration <ide> from airflow.exceptions import AirflowException <ide> from airflow.contrib.operators.ecs_operator import ECSOperator <ide> def setUp(self, aws_hook_mock): <ide> configuration.load_test_config() <ide> <ide> self.aws_hook_mock = aws_hook_mock <del> self.ecs = ECSOperator( <del> task_id='task', <del> task_definition='t', <del> cluster='c', <del> overrides={}, <del> aws_conn_id=None, <del> region_name='eu-west-1', <del> group='group', <del> placement_constraints=[ <del> { <del> 'expression': 'attribute:ecs.instance-type =~ t2.*', <del> 'type': 'memberOf' <del> } <del> ], <del> network_configuration={ <add> self.ecs_operator_args = { <add> 'task_id': 'task', <add> 'task_definition': 't', <add> 'cluster': 'c', <add> 'overrides': {}, <add> 'aws_conn_id': None, <add> 'region_name': 'eu-west-1', <add> 'group': 'group', <add> 'placement_constraints': [{ <add> 'expression': 'attribute:ecs.instance-type =~ t2.*', <add> 'type': 'memberOf' <add> }], <add> 'network_configuration': { <ide> 'awsvpcConfiguration': { <del> 'securityGroups': ['sg-123abc'] <add> 'securityGroups': ['sg-123abc'], <add> 'subnets': ['subnet-123456ab'] <ide> } <ide> } <del> ) <add> } <add> self.ecs = ECSOperator(**self.ecs_operator_args) <ide> <ide> def test_init(self): <ide> self.assertEqual(self.ecs.region_name, 'eu-west-1') <ide> def test_init(self): <ide> def test_template_fields_overrides(self): <ide> self.assertEqual(self.ecs.template_fields, ('overrides',)) <ide> <add> @parameterized.expand([ <add> ['EC2'], <add> ['FARGATE'] <add> ]) <ide> @mock.patch.object(ECSOperator, '_wait_for_task_ended') <ide> @mock.patch.object(ECSOperator, '_check_success_task') <del> def test_execute_without_failures(self, check_mock, wait_mock): <del> client_mock = self.aws_hook_mock.return_value.get_client_type.return_value <add> @mock.patch('airflow.contrib.operators.ecs_operator.AwsHook') <add> def test_execute_without_failures(self, launch_type, aws_hook_mock, <add> check_mock, wait_mock): <add> client_mock = aws_hook_mock.return_value.get_client_type.return_value <ide> client_mock.run_task.return_value = RESPONSE_WITHOUT_FAILURES <ide> <del> self.ecs.execute(None) <add> ecs = ECSOperator(launch_type=launch_type, **self.ecs_operator_args) <add> ecs.execute(None) <add> <add> aws_hook_mock.return_value.get_client_type.assert_called_once_with('ecs', <add> region_name='eu-west-1') <add> extend_args = {} <add> if launch_type == 'FARGATE': <add> extend_args['platformVersion'] = 'LATEST' <ide> <del> self.aws_hook_mock.return_value.get_client_type.assert_called_once_with('ecs', <del> region_name='eu-west-1') <ide> client_mock.run_task.assert_called_once_with( <ide> cluster='c', <del> launchType='EC2', <add> launchType=launch_type, <ide> overrides={}, <ide> startedBy=mock.ANY, # Can by 'airflow' or 'Airflow' <ide> taskDefinition='t', <ide> def test_execute_without_failures(self, check_mock, wait_mock): <ide> 'type': 'memberOf' <ide> } <ide> ], <del> platformVersion='LATEST', <ide> networkConfiguration={ <ide> 'awsvpcConfiguration': { <del> 'securityGroups': ['sg-123abc'] <add> 'securityGroups': ['sg-123abc'], <add> 'subnets': ['subnet-123456ab'] <ide> } <del> } <add> }, <add> **extend_args <ide> ) <ide> <ide> wait_mock.assert_called_once_with() <ide> check_mock.assert_called_once_with() <del> self.assertEqual(self.ecs.arn, <add> self.assertEqual(ecs.arn, <ide> 'arn:aws:ecs:us-east-1:012345678910:task/d8c67b3c-ac87-4ffe-a847-4785bc3a8b55') <ide> <ide> def test_execute_with_failures(self): <ide> def test_execute_with_failures(self): <ide> 'type': 'memberOf' <ide> } <ide> ], <del> platformVersion='LATEST', <ide> networkConfiguration={ <ide> 'awsvpcConfiguration': { <del> 'securityGroups': ['sg-123abc'] <add> 'securityGroups': ['sg-123abc'], <add> 'subnets': ['subnet-123456ab'], <ide> } <ide> } <ide> )
2
Javascript
Javascript
drop stray sample.js file
20f4c613256439962905eaba22c635cad729ffad
<ide><path>spec/sample.js <del>undefined <ide>\ No newline at end of file
1
Text
Text
add build fix from
7f6a4cccaf82627810a0d3d42118f125e4b240e4
<ide><path>docs/build-instructions/windows.md <ide> If none of this works, do install Github for Windows and use its Git shell. Make <ide> * https://github.com/TooTallNate/node-gyp/issues/297 <ide> * https://code.google.com/p/gyp/issues/detail?id=393 <ide> <add>* `script/build` stops at installing runas with 'Failed at the runas@0.5.4 install script.' <add> <add> See the next item. <add> <add>* `error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found.` <add> <add> * If you're building atom with Visual Studio 2013 try executing the following <add> command in your Git shell and then re-run `script/build`: <add> <add> ``` <add> $env:GYP_MSVS_VERSION=2013 <add> ``` <add> <ide> * Other `node-gyp` errors on first build attempt, even though the right node and python versions are installed. <ide> * Do try the build command one more time, as experience shows it often works on second try in many of these cases. <ide>
1
Text
Text
react proptypes challenge, improve test text
3d7af80047bac1e62e9652e8b7498659b2027a72
<ide><path>curriculum/challenges/english/03-front-end-libraries/react/use-proptypes-to-define-the-props-you-expect.english.md <ide> tests: <ide> testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ShoppingCart)); return mockedComponent.find('ShoppingCart').length === 1; })()); <ide> - text: The <code>Items</code> component should render. <ide> testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ShoppingCart)); return mockedComponent.find('Items').length === 1; })()); <del> - text: The <code>Items</code> component should include a <code>propTypes</code> check that requires <code>quantity</code> to be a <code>number</code>. <add> - text: The <code>Items</code> component should include a <code>propTypes</code> check to require a value for <code>quantity</code> and ensure that its value is a number. <ide> testString: getUserInput => assert((function() { const noWhiteSpace = __helpers.removeWhiteSpace(getUserInput('index')); return noWhiteSpace.includes('quantity:PropTypes.number.isRequired') && noWhiteSpace.includes('Items.propTypes='); })()); <ide> <ide> ```
1
Javascript
Javascript
remove react redundant imports on examples
44d74e399f70f04b16526a9466e0c8ddf72023fd
<ide><path>examples/analyze-bundles/pages/index.js <del>import React from 'react' <ide> import Link from 'next/link' <ide> import faker from 'faker' <ide> <ide><path>examples/api-routes-apollo-server-and-client-auth/apollo/client.js <del>import React from 'react' <ide> import Head from 'next/head' <ide> import { ApolloProvider } from '@apollo/react-hooks' <ide> import { ApolloClient } from 'apollo-client' <ide><path>examples/api-routes-apollo-server-and-client-auth/pages/signin.js <del>import React from 'react' <add>import { useState } from 'react' <ide> import Link from 'next/link' <ide> import { withApollo } from '../apollo/client' <ide> import gql from 'graphql-tag' <ide> const SignInMutation = gql` <ide> function SignIn() { <ide> const client = useApolloClient() <ide> const [signIn] = useMutation(SignInMutation) <del> const [errorMsg, setErrorMsg] = React.useState() <add> const [errorMsg, setErrorMsg] = useState() <ide> const router = useRouter() <ide> <ide> async function handleSubmit(event) { <ide><path>examples/api-routes-apollo-server-and-client-auth/pages/signout.js <del>import React from 'react' <add>import { useEffect } from 'react' <ide> import { useMutation, useApolloClient } from '@apollo/react-hooks' <ide> import gql from 'graphql-tag' <ide> import { useRouter } from 'next/router' <ide> function SignOut() { <ide> const router = useRouter() <ide> const [signOut] = useMutation(SignOutMutation) <ide> <del> React.useEffect(() => { <add> useEffect(() => { <ide> signOut().then(() => { <ide> client.resetStore().then(() => { <ide> router.push('/signin') <ide><path>examples/api-routes-apollo-server-and-client-auth/pages/signup.js <del>import React from 'react' <add>import { useState } from 'react' <ide> import Link from 'next/link' <ide> import { withApollo } from '../apollo/client' <ide> import gql from 'graphql-tag' <ide> const SignUpMutation = gql` <ide> <ide> function SignUp() { <ide> const [signUp] = useMutation(SignUpMutation) <del> const [errorMsg, setErrorMsg] = React.useState() <add> const [errorMsg, setErrorMsg] = useState() <ide> const router = useRouter() <ide> <ide> async function handleSubmit(event) { <ide><path>examples/custom-server-actionhero/pages/index.js <del>import React from 'react' <ide> import Link from 'next/link' <ide> <ide> export default function Home() { <ide><path>examples/custom-server/pages/a.js <del>import React from 'react' <del> <ide> export default function A() { <ide> return <div>a</div> <ide> } <ide><path>examples/custom-server/pages/b.js <del>import React from 'react' <del> <ide> export default function B() { <ide> return <div>b</div> <ide> } <ide><path>examples/custom-server/pages/index.js <del>import React from 'react' <ide> import Link from 'next/link' <ide> <ide> export default function Home() {
9
Javascript
Javascript
add guard to errorutils mock
4a226fc1af835db125cd7cf5a40c765096761753
<ide><path>Libraries/Utilities/__mocks__/ErrorUtils.js <ide> function reportError(error) { <ide> var ErrorUtils = { <ide> apply: jest.genMockFunction().mockImplementation(execute), <ide> applyWithGuard: jest.genMockFunction().mockImplementation(execute), <add> guard: jest.genMockFunction().mockImplementation(callback => callback), <ide> inGuard: jest.genMockFunction().mockReturnValue(true), <ide> reportError: jest.genMockFunction().mockImplementation(reportError), <ide> setGlobalHandler: jest.genMockFunction(),
1
Javascript
Javascript
fix experimental syntax
21e2eae7903eab8fbfa90cd92a58db301e922973
<ide><path>packages/ember-glimmer/tests/integration/syntax/experimental-syntax-test.js <ide> import { moduleFor, RenderingTest } from '../../utils/test-case'; <ide> import { strip } from '../../utils/abstract-test-case'; <ide> import { _registerMacros, _experimentalMacros } from 'ember-glimmer'; <del>import { compileExpression } from '@glimmer/runtime'; <ide> <ide> moduleFor('registerMacros', class extends RenderingTest { <ide> constructor() { <ide> let originalMacros = _experimentalMacros.slice(); <ide> <ide> _registerMacros(blocks => { <ide> blocks.add('-let', (params, hash, _default, inverse, builder) => { <del> compileExpression(params[0], builder); <del> builder.invokeStatic(_default, 1); <add> builder.compileParams(params); <add> builder.invokeStaticBlock(_default, params.length); <ide> }); <ide> }); <ide>
1
Javascript
Javascript
improve class transform
5f135a7f11f833233a938722615ca5e8f991fdb7
<ide><path>dist/immutable.js <ide> function Iterable(value) { <ide> return isIterable(value) ? value : Seq(value); <ide> } <del> createClass(Iterable); <del> <ide> <ide> <del> function KeyedIterable(value) { <add> createClass(KeyedIterable, Iterable); <add> function KeyedIterable(value) { <ide> return isKeyed(value) ? value : KeyedSeq(value); <ide> } <del> createClass(KeyedIterable,Iterable); <del> <ide> <ide> <del> function IndexedIterable(value) { <add> createClass(IndexedIterable, Iterable); <add> function IndexedIterable(value) { <ide> return isIndexed(value) ? value : IndexedSeq(value); <ide> } <del> createClass(IndexedIterable,Iterable); <del> <ide> <ide> <del> function SetIterable(value) { <add> createClass(SetIterable, Iterable); <add> function SetIterable(value) { <ide> return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); <ide> } <del> createClass(SetIterable,Iterable); <del> <ide> <ide> <ide> <ide> var IS_INDEXED_SENTINEL = ''; <ide> var IS_ORDERED_SENTINEL = ''; <ide> <add> /* global Symbol */ <add> <ide> var ITERATE_KEYS = 0; <ide> var ITERATE_VALUES = 1; <ide> var ITERATE_ENTRIES = 2; <ide> function Iterator(next) { <ide> this.next = next; <ide> } <del> createClass(Iterator); <del> <ide> <ide> Iterator.prototype.toString = function() { <ide> return '[Iterator]'; <ide> return value && typeof value.length === 'number'; <ide> } <ide> <del> function Seq(value) { <add> createClass(Seq, Iterable); <add> function Seq(value) { <ide> return value === null || value === undefined ? emptySequence() : <ide> isIterable(value) ? value.toSeq() : seqFromValue(value); <ide> } <del> createClass(Seq,Iterable); <del> <ide> <ide> Seq.of = function(/*...values*/) { <ide> return Seq(arguments); <ide> <ide> <ide> <del> function KeyedSeq(value) { <add> createClass(KeyedSeq, Seq); <add> function KeyedSeq(value) { <ide> return value === null || value === undefined ? <ide> emptySequence().toKeyedSeq() : <ide> isIterable(value) ? <ide> (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) : <ide> keyedSeqFromValue(value); <ide> } <del> createClass(KeyedSeq,Seq); <del> <ide> <ide> KeyedSeq.of = function(/*...values*/) { <ide> return KeyedSeq(arguments); <ide> <ide> <ide> <del> function IndexedSeq(value) { <add> createClass(IndexedSeq, Seq); <add> function IndexedSeq(value) { <ide> return value === null || value === undefined ? emptySequence() : <ide> !isIterable(value) ? indexedSeqFromValue(value) : <ide> isKeyed(value) ? value.entrySeq() : value.toIndexedSeq(); <ide> } <del> createClass(IndexedSeq,Seq); <del> <ide> <ide> IndexedSeq.of = function(/*...values*/) { <ide> return IndexedSeq(arguments); <ide> <ide> <ide> <del> function SetSeq(value) { <add> createClass(SetSeq, Seq); <add> function SetSeq(value) { <ide> return ( <ide> value === null || value === undefined ? emptySequence() : <ide> !isIterable(value) ? indexedSeqFromValue(value) : <ide> isKeyed(value) ? value.entrySeq() : value <ide> ).toSetSeq(); <ide> } <del> createClass(SetSeq,Seq); <del> <ide> <ide> SetSeq.of = function(/*...values*/) { <ide> return SetSeq(arguments); <ide> <ide> // #pragma Root Sequences <ide> <del> function ArraySeq(array) { <add> createClass(ArraySeq, IndexedSeq); <add> function ArraySeq(array) { <ide> this._array = array; <ide> this.size = array.length; <ide> } <del> createClass(ArraySeq,IndexedSeq); <del> <ide> <ide> ArraySeq.prototype.get = function(index, notSetValue) { <ide> return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; <ide> <ide> <ide> <del> function ObjectSeq(object) { <add> createClass(ObjectSeq, KeyedSeq); <add> function ObjectSeq(object) { <ide> var keys = Object.keys(object); <ide> this._object = object; <ide> this._keys = keys; <ide> this.size = keys.length; <ide> } <del> createClass(ObjectSeq,KeyedSeq); <del> <ide> <ide> ObjectSeq.prototype.get = function(key, notSetValue) { <ide> if (notSetValue !== undefined && !this.has(key)) { <ide> ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; <ide> <ide> <del> function IterableSeq(iterable) { <add> createClass(IterableSeq, IndexedSeq); <add> function IterableSeq(iterable) { <ide> this._iterable = iterable; <ide> this.size = iterable.length || iterable.size; <ide> } <del> createClass(IterableSeq,IndexedSeq); <del> <ide> <ide> IterableSeq.prototype.__iterateUncached = function(fn, reverse) { <ide> if (reverse) { <ide> <ide> <ide> <del> function IteratorSeq(iterator) { <add> createClass(IteratorSeq, IndexedSeq); <add> function IteratorSeq(iterator) { <ide> this._iterator = iterator; <ide> this._iteratorCache = []; <ide> } <del> createClass(IteratorSeq,IndexedSeq); <del> <ide> <ide> IteratorSeq.prototype.__iterateUncached = function(fn, reverse) { <ide> if (reverse) { <ide> return seq.__iteratorUncached(type, reverse); <ide> } <ide> <del> function Collection() { <add> createClass(Collection, Iterable); <add> function Collection() { <ide> throw TypeError('Abstract'); <ide> } <del> createClass(Collection,Iterable); <del> <ide> <ide> <del> function KeyedCollection() {} <del> createClass(KeyedCollection,Collection); <add> createClass(KeyedCollection, Collection);function KeyedCollection() {} <ide> <del> function IndexedCollection() {} <del> createClass(IndexedCollection,Collection); <add> createClass(IndexedCollection, Collection);function IndexedCollection() {} <ide> <del> function SetCollection() {} <del> createClass(SetCollection,Collection); <add> createClass(SetCollection, Collection);function SetCollection() {} <ide> <ide> <ide> Collection.Keyed = KeyedCollection; <ide> ); <ide> } <ide> <del> function ToKeyedSequence(indexed, useKeys) { <add> createClass(ToKeyedSequence, KeyedSeq); <add> function ToKeyedSequence(indexed, useKeys) { <ide> this._iter = indexed; <ide> this._useKeys = useKeys; <ide> this.size = indexed.size; <ide> } <del> createClass(ToKeyedSequence,KeyedSeq); <del> <ide> <ide> ToKeyedSequence.prototype.get = function(key, notSetValue) { <ide> return this._iter.get(key, notSetValue); <ide> ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; <ide> <ide> <del> function ToIndexedSequence(iter) { <add> createClass(ToIndexedSequence, IndexedSeq); <add> function ToIndexedSequence(iter) { <ide> this._iter = iter; <ide> this.size = iter.size; <ide> } <del> createClass(ToIndexedSequence,IndexedSeq); <del> <ide> <ide> ToIndexedSequence.prototype.contains = function(value) { <ide> return this._iter.contains(value); <ide> <ide> <ide> <del> function ToSetSequence(iter) { <add> createClass(ToSetSequence, SetSeq); <add> function ToSetSequence(iter) { <ide> this._iter = iter; <ide> this.size = iter.size; <ide> } <del> createClass(ToSetSequence,SetSeq); <del> <ide> <ide> ToSetSequence.prototype.has = function(key) { <ide> return this._iter.contains(key); <ide> <ide> <ide> <del> function FromEntriesSequence(entries) { <add> createClass(FromEntriesSequence, KeyedSeq); <add> function FromEntriesSequence(entries) { <ide> this._iter = entries; <ide> this.size = entries.size; <ide> } <del> createClass(FromEntriesSequence,KeyedSeq); <del> <ide> <ide> FromEntriesSequence.prototype.entrySeq = function() { <ide> return this._iter.toSeq(); <ide> return iter; <ide> } <ide> <del> function Map(value) { <add> createClass(Map, KeyedCollection); <add> <add> // @pragma Construction <add> <add> function Map(value) { <ide> return value === null || value === undefined ? emptyMap() : <ide> isMap(value) ? value : <ide> emptyMap().withMutations(function(map ) { <ide> iter.forEach(function(v, k) {return map.set(k, v)}); <ide> }); <ide> } <del> createClass(Map,KeyedCollection); <del> <del> // @pragma Construction <del> <del> <ide> <ide> Map.prototype.toString = function() { <ide> return this.__toString('Map {', '}'); <ide> <ide> // #pragma Trie Nodes <ide> <del> function ArrayMapNode(ownerID, entries) { <add> <add> <add> function ArrayMapNode(ownerID, entries) { <ide> this.ownerID = ownerID; <ide> this.entries = entries; <ide> } <del> createClass(ArrayMapNode); <del> <del> <ide> <ide> ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { <ide> var entries = this.entries; <ide> }; <ide> <ide> <del> function BitmapIndexedNode(ownerID, bitmap, nodes) { <add> <add> <add> function BitmapIndexedNode(ownerID, bitmap, nodes) { <ide> this.ownerID = ownerID; <ide> this.bitmap = bitmap; <ide> this.nodes = nodes; <ide> } <del> createClass(BitmapIndexedNode); <del> <del> <ide> <ide> BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) { <ide> if (keyHash === undefined) { <ide> }; <ide> <ide> <del> function HashArrayMapNode(ownerID, count, nodes) { <add> <add> <add> function HashArrayMapNode(ownerID, count, nodes) { <ide> this.ownerID = ownerID; <ide> this.count = count; <ide> this.nodes = nodes; <ide> } <del> createClass(HashArrayMapNode); <del> <del> <ide> <ide> HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) { <ide> if (keyHash === undefined) { <ide> }; <ide> <ide> <del> function HashCollisionNode(ownerID, keyHash, entries) { <add> <add> <add> function HashCollisionNode(ownerID, keyHash, entries) { <ide> this.ownerID = ownerID; <ide> this.keyHash = keyHash; <ide> this.entries = entries; <ide> } <del> createClass(HashCollisionNode); <del> <del> <ide> <ide> HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) { <ide> var entries = this.entries; <ide> }; <ide> <ide> <del> function ValueNode(ownerID, keyHash, entry) { <add> <add> <add> function ValueNode(ownerID, keyHash, entry) { <ide> this.ownerID = ownerID; <ide> this.keyHash = keyHash; <ide> this.entry = entry; <ide> } <del> createClass(ValueNode); <del> <del> <ide> <ide> ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) { <ide> return is(key, this.entry[0]) ? this.entry[1] : notSetValue; <ide> return fn(this.entry); <ide> } <ide> <del> function MapIterator(map, type, reverse) { <add> createClass(MapIterator, Iterator); <add> <add> function MapIterator(map, type, reverse) { <ide> this._type = type; <ide> this._reverse = reverse; <ide> this._stack = map._root && mapIteratorFrame(map._root); <ide> } <del> createClass(MapIterator,Iterator); <del> <del> <ide> <ide> MapIterator.prototype.next = function() { <ide> var type = this._type; <ide> var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; <ide> var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; <ide> <del> function List(value) { <add> createClass(List, IndexedCollection); <add> <add> // @pragma Construction <add> <add> function List(value) { <ide> var empty = emptyList(); <ide> if (value === null || value === undefined) { <ide> return empty; <ide> iter.forEach(function(v, i) {return list.set(i, v)}); <ide> }); <ide> } <del> createClass(List,IndexedCollection); <del> <del> // @pragma Construction <del> <del> <ide> <ide> List.of = function(/*...values*/) { <ide> return this(arguments); <ide> ListPrototype.wasAltered = MapPrototype.wasAltered; <ide> <ide> <del> function VNode(array, ownerID) { <add> <add> function VNode(array, ownerID) { <ide> this.array = array; <ide> this.ownerID = ownerID; <ide> } <del> createClass(VNode); <del> <ide> <ide> // TODO: seems like these methods are very similar <ide> <ide> return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT); <ide> } <ide> <del> function OrderedMap(value) { <add> createClass(OrderedMap, Map); <add> <add> // @pragma Construction <add> <add> function OrderedMap(value) { <ide> return value === null || value === undefined ? emptyOrderedMap() : <ide> isOrderedMap(value) ? value : <ide> emptyOrderedMap().withMutations(function(map ) { <ide> iter.forEach(function(v, k) {return map.set(k, v)}); <ide> }); <ide> } <del> createClass(OrderedMap,Map); <del> <del> // @pragma Construction <del> <del> <ide> <ide> OrderedMap.of = function(/*...values*/) { <ide> return this(arguments); <ide> return makeOrderedMap(newMap, newList); <ide> } <ide> <del> function Stack(value) { <add> createClass(Stack, IndexedCollection); <add> <add> // @pragma Construction <add> <add> function Stack(value) { <ide> return value === null || value === undefined ? emptyStack() : <ide> isStack(value) ? value : <ide> emptyStack().unshiftAll(value); <ide> } <del> createClass(Stack,IndexedCollection); <del> <del> // @pragma Construction <del> <del> <ide> <ide> Stack.of = function(/*...values*/) { <ide> return this(arguments); <ide> return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); <ide> } <ide> <del> function Set(value) { <add> createClass(Set, SetCollection); <add> <add> // @pragma Construction <add> <add> function Set(value) { <ide> return value === null || value === undefined ? emptySet() : <ide> isSet(value) ? value : <ide> emptySet().withMutations(function(set ) { <ide> iter.forEach(function(v ) {return set.add(v)}); <ide> }); <ide> } <del> createClass(Set,SetCollection); <del> <del> // @pragma Construction <del> <del> <ide> <ide> Set.of = function(/*...values*/) { <ide> return this(arguments); <ide> return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); <ide> } <ide> <del> function OrderedSet(value) { <add> createClass(OrderedSet, Set); <add> <add> // @pragma Construction <add> <add> function OrderedSet(value) { <ide> return value === null || value === undefined ? emptyOrderedSet() : <ide> isOrderedSet(value) ? value : <ide> emptyOrderedSet().withMutations(function(set ) { <ide> iter.forEach(function(v ) {return set.add(v)}); <ide> }); <ide> } <del> createClass(OrderedSet,Set); <del> <del> // @pragma Construction <del> <del> <ide> <ide> OrderedSet.of = function(/*...values*/) { <ide> return this(arguments); <ide> return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); <ide> } <ide> <del> function Record(defaultValues, name) { <add> createClass(Record, KeyedCollection); <add> <add> function Record(defaultValues, name) { <ide> var RecordType = function Record(values) { <ide> if (!(this instanceof RecordType)) { <ide> return new RecordType(values); <ide> <ide> return RecordType; <ide> } <del> createClass(Record,KeyedCollection); <del> <del> <ide> <ide> Record.prototype.toString = function() { <ide> return this.__toString(recordName(this) + ' {', '}'); <ide> return allEqual && a.size === bSize; <ide> } <ide> <del> function Range(start, end, step) { <add> createClass(Range, IndexedSeq); <add> <add> function Range(start, end, step) { <ide> if (!(this instanceof Range)) { <ide> return new Range(start, end, step); <ide> } <ide> EMPTY_RANGE = this; <ide> } <ide> } <del> createClass(Range,IndexedSeq); <del> <del> <ide> <ide> Range.prototype.toString = function() { <ide> if (this.size === 0) { <ide> <ide> var EMPTY_RANGE; <ide> <del> function Repeat(value, times) { <add> createClass(Repeat, IndexedSeq); <add> <add> function Repeat(value, times) { <ide> if (!(this instanceof Repeat)) { <ide> return new Repeat(value, times); <ide> } <ide> EMPTY_REPEAT = this; <ide> } <ide> } <del> createClass(Repeat,IndexedSeq); <del> <del> <ide> <ide> Repeat.prototype.toString = function() { <ide> if (this.size === 0) { <ide><path>dist/immutable.min.js <ide> se(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function Le(t){return!( <ide> });r+=t._origin;var i=t._tail,o=t._root,s=e(fn);return r>=Sr(t._capacity)?i=yr(i,t.__ownerID,0,r,n,s):o=yr(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,o,i):t}function yr(t,e,n,i,o,u){var s=i>>>n&sn,a=t&&t.array.length>s;if(!a&&void 0===o)return t;var h;if(n>0){var f=t&&t.array[s],c=yr(f,e,n-on,i,o,u);return c===f?t:(h=dr(t,e),h.array[s]=c,h)}return a&&t.array[s]===o?t:(r(u),h=dr(t,e),void 0===o&&s===h.array.length-1?h.array.pop():h.array[s]=o,h)}function dr(t,e){return e&&t&&e===t.ownerID?t:new cr(t?t.array.slice():[],e)}function mr(t,e){if(e>=Sr(t._capacity))return t._tail;if(1<<t._level+on>e){for(var r=t._root,n=t._level;r&&n>0;)r=r.array[e>>>n&sn],n-=on;return r}}function gr(t,e,r){var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:0>r?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var h=t._level,f=t._root,c=0;0>s+c;)f=new cr(f&&f.array.length?[void 0,f]:[],i),h+=on,c+=1<<h;c&&(s+=c,o+=c,a+=c,u+=c);for(var _=Sr(u),p=Sr(a);p>=1<<h+on;)f=new cr(f&&f.array.length?[f]:[],i),h+=on;var v=t._tail,l=_>p?mr(t,a-1):p>_?new cr([],i):v;if(v&&p>_&&u>s&&v.array.length){f=dr(f,i);for(var y=f,d=h;d>on;d-=on){var m=_>>>d&sn;y=y.array[m]=dr(y.array[m],i)}y.array[_>>>on&sn]=v}if(u>a&&(l=l&&l.removeAfter(i,0,a)),s>=p)s-=p,a-=p,h=on,f=null,l=l&&l.removeBefore(i,0,s);else if(s>o||_>p){for(c=0;f;){var g=s>>>h&sn;if(g!==p>>>h&sn)break;g&&(c+=(1<<h)*g),h-=on,f=f.array[g]}f&&s>o&&(f=f.removeBefore(i,h,s-c)),f&&_>p&&(f=f.removeAfter(i,h,p-c)),c&&(s-=c,a-=c)}return t.__ownerID?(t.size=a-s,t._origin=s,t._capacity=a,t._level=h,t._root=f,t._tail=l,t.__hash=void 0,t.__altered=!0,t):pr(s,a,h,f,l)}function wr(t,e,r){for(var n=[],i=0,o=0;r.length>o;o++){var u=r[o],s=v(u);s.size>i&&(i=s.size),y(u)||(s=s.map(function(t){return F(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),nr(t,e,n)}function Sr(t){return un>t?0:t-1>>>on<<on}function Ir(t){return null===t||void 0===t?qr():zr(t)?t:qr().withMutations(function(e){var r=p(t); <ide> se(r.size),r.forEach(function(t,r){return e.set(r,t)})})}function zr(t){return Le(t)&&w(t)}function br(t,e,r,n){var i=Object.create(Ir.prototype);return i.size=t?t.size:0,i._map=t,i._list=e,i.__ownerID=r,i.__hash=n,i}function qr(){return Jn||(Jn=br(Ye(),vr()))}function Dr(t,e,r){var n,i,o=t._map,u=t._list,s=o.get(e),a=void 0!==s;if(r===an){if(!a)return t;u.size>=un&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):br(n,i)}function Mr(t){return null===t||void 0===t?xr():Or(t)?t:xr().unshiftAll(t)}function Or(t){return!(!t||!t[Pn])}function Er(t,e,r,n){var i=Object.create(Hn);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function xr(){return Nn||(Nn=Er(0))}function kr(t){return null===t||void 0===t?Rr():Ar(t)?t:Rr().withMutations(function(e){var r=l(t);se(r.size),r.forEach(function(t){return e.add(t)})})}function Ar(t){return!(!t||!t[Vn])}function jr(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Kr(t,e){var r=Object.create(Yn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Rr(){return Qn||(Qn=Kr(Ye()))}function Ur(t){return null===t||void 0===t?Br():Lr(t)?t:Br().withMutations(function(e){var r=l(t);se(r.size),r.forEach(function(t){return e.add(t)})})}function Lr(t){return Ar(t)&&w(t)}function Tr(t,e){var r=Object.create(Xn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Br(){return Fn||(Fn=Tr(qr()))}function Wr(t,e){var r=function(t){return this instanceof r?void(this._map=Ue(t)):new r(t)},n=Object.keys(t),i=r.prototype=Object.create(Gn);i.constructor=r,e&&(i._name=e),i._defaultValues=t,i._keys=n,i.size=n.length;try{n.forEach(function(t){Object.defineProperty(r.prototype,t,{get:function(){return this.get(t) <ide> },set:function(e){ue(this.__ownerID,"Cannot set on an immutable record."),this.set(t,e)}})})}catch(o){}return r}function Cr(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function Jr(t){return t._name||t.constructor.name}function Pr(t,e){if(t===e)return!0;if(!y(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||d(t)!==d(e)||m(t)!==m(e)||w(t)!==w(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!g(t);if(w(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,an)):X(t.get(n,an),e))?void 0:(u=!1,!1)});return u&&t.size===s}function Hr(t,e,r){if(!(this instanceof Hr))return new Hr(t,e,r);if(ue(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(Zn)return Zn;Zn=this}}function Nr(t,e){if(!(this instanceof Nr))return new Nr(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if($n)return $n;$n=this}}function Vr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Yr(t,e){return e}function Qr(t,e){return[e,t]}function Xr(t){return function(){return!t.apply(this,arguments)}}function Fr(t){return function(){return-t.apply(this,arguments)}}function Gr(t){return"string"==typeof t?JSON.stringify(t):t}function Zr(t,e){return e>t?1:t>e?-1:0}function $r(t){if(1/0===t.size)return 0;var e=w(t),r=d(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+en(ee(t),ee(e))|0}:function(t,e){n=n+en(ee(t),ee(e))|0}:e?function(t){n=31*n+ee(t)|0}:function(t){n=n+ee(t)|0});return tn(i,n)}function tn(t,e){return e=zn(e,3432918353),e=zn(e<<15|e>>>-15,461845907),e=zn(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=zn(e^e>>>16,2246822507),e=zn(e^e>>>13,3266489909),e=te(e^e>>>16) <del>}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var rn=Array.prototype.slice,nn="delete",on=5,un=1<<on,sn=un-1,an={},hn={value:!1},fn={value:!1};t(_),t(p,_),t(v,_),t(l,_),_.isIterable=y,_.isKeyed=d,_.isIndexed=m,_.isAssociative=g,_.isOrdered=w,_.Keyed=p,_.Indexed=v,_.Set=l;var cn="",_n="",pn="",vn="",ln=0,yn=1,dn=2,mn="function"==typeof Symbol&&Symbol.iterator,gn="__IMMUTABLE_SEQ__@@";E.prototype[Sn]=!0,t(j,k),j.prototype.get=function(t,e){return this.has(t)?this._array[u(this,t)]:e},j.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length-1,i=0;n>=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},j.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new S(function(){return i>n?z():I(t,i,r[e?n-i++:i++]) <add>}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var rn=Array.prototype.slice,nn="delete",on=5,un=1<<on,sn=un-1,an={},hn={value:!1},fn={value:!1};t(p,_),t(v,_),t(l,_),_.isIterable=y,_.isKeyed=d,_.isIndexed=m,_.isAssociative=g,_.isOrdered=w,_.Keyed=p,_.Indexed=v,_.Set=l;var cn="",_n="",pn="",vn="",ln=0,yn=1,dn=2,mn="function"==typeof Symbol&&Symbol.iterator,gn="__IMMUTABLE_SEQ__@@";E.prototype[Sn]=!0,t(j,k),j.prototype.get=function(t,e){return this.has(t)?this._array[u(this,t)]:e},j.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length-1,i=0;n>=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},j.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new S(function(){return i>n?z():I(t,i,r[e?n-i++:i++]) <ide> })},t(K,x),K.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},K.prototype.has=function(t){return this._object.hasOwnProperty(t)},K.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},K.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new S(function(){var u=n[e?i-o:o];return o++>i?z():I(t,u,r[u])})},K.prototype[vn]=!0,t(R,k),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=this._iterable,n=D(r),i=0;if(q(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},R.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=D(r);if(!q(n))return new S(z);var i=0;return new S(function(){var e=n.next();return e.done?e:I(t,i++,e.value)})},t(U,k),U.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;n.length>i;)if(t(n[i],i++,this)===!1)return i;for(var o;!(o=r.next()).done;){var u=o.value;if(n[i]=u,t(u,i++,this)===!1)break}return i},U.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterator,n=this._iteratorCache,i=0;return new S(function(){if(i>=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return I(t,i,n[i++])})};var In;t(N,_),t(V,N),t(Y,N),t(Q,N),N.Keyed=V,N.Indexed=Y,N.Set=Q;var zn="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},bn=function(){try{return Object.defineProperty({},"x",{}),!0}catch(t){return!1}}(),qn="function"==typeof WeakMap&&new WeakMap,Dn=0,Mn="__immutablehash__";"function"==typeof Symbol&&(Mn=Symbol(Mn));var On=16,En=255,xn=0,kn={};t(ae,x),ae.prototype.get=function(t,e){return this._iter.get(t,e)},ae.prototype.has=function(t){return this._iter.has(t)},ae.prototype.valueSeq=function(){return this._iter.valueSeq() <ide> },ae.prototype.reverse=function(){var t=this,e=ve(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},ae.prototype.map=function(t,e){var r=this,n=pe(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},ae.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?xe(this):0,function(i){return t(i,e?--r:r++,n)}),e)},ae.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(yn,e),n=e?xe(this):0;return new S(function(){var i=r.next();return i.done?i:I(t,e?--n:n++,i.value,i)})},ae.prototype[vn]=!0,t(he,k),he.prototype.contains=function(t){return this._iter.contains(t)},he.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},he.prototype.__iterator=function(t,e){var r=this._iter.__iterator(yn,e),n=0;return new S(function(){var e=r.next();return e.done?e:I(t,n++,e.value,e)})},t(fe,A),fe.prototype.has=function(t){return this._iter.contains(t)},fe.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},fe.prototype.__iterator=function(t,e){var r=this._iter.__iterator(yn,e);return new S(function(){var e=r.next();return e.done?e:I(t,e.value,e.value,e)})},t(ce,x),ce.prototype.entrySeq=function(){return this._iter.toSeq()},ce.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return e?(Ee(e),t(e[1],e[0],r)):void 0},e)},ce.prototype.__iterator=function(t,e){var r=this._iter.__iterator(yn,e);return new S(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n)return Ee(n),t===dn?e:I(t,n[0],n[1],e)}})},he.prototype.cacheResult=ae.prototype.cacheResult=fe.prototype.cacheResult=ce.prototype.cacheResult=je,t(Ue,V),Ue.prototype.toString=function(){return this.__toString("Map {","}")},Ue.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},Ue.prototype.set=function(t,e){return Qe(this,t,e) <del>},Ue.prototype.setIn=function(t,e){return this.updateIn(t,an,function(){return e})},Ue.prototype.remove=function(t){return Qe(this,t,an)},Ue.prototype.deleteIn=function(t){return this.updateIn(t,function(){return an})},Ue.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Ue.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=ir(this,Re(t),e,r);return n===an?void 0:n},Ue.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Ye()},Ue.prototype.merge=function(){return er(this,void 0,arguments)},Ue.prototype.mergeWith=function(t){var e=rn.call(arguments,1);return er(this,t,e)},Ue.prototype.mergeIn=function(t){var e=rn.call(arguments,1);return this.updateIn(t,Ye(),function(t){return t.merge.apply(t,e)})},Ue.prototype.mergeDeep=function(){return er(this,rr(void 0),arguments)},Ue.prototype.mergeDeepWith=function(t){var e=rn.call(arguments,1);return er(this,rr(t),e)},Ue.prototype.mergeDeepIn=function(t){var e=rn.call(arguments,1);return this.updateIn(t,Ye(),function(t){return t.mergeDeep.apply(t,e)})},Ue.prototype.sort=function(t){return Ir(qe(this,t))},Ue.prototype.sortBy=function(t,e){return Ir(qe(this,e,t))},Ue.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ue.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Ue.prototype.asImmutable=function(){return this.__ensureOwner()},Ue.prototype.wasAltered=function(){return this.__altered},Ue.prototype.__iterator=function(t,e){return new Pe(this,t,e)},Ue.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Ue.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ve(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ue.isMap=Le;var An="",jn=Ue.prototype;jn[An]=!0,jn[nn]=jn.remove,jn.removeIn=jn.deleteIn,t(Te),Te.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1]; <del>return n},Te.prototype.update=function(t,e,n,o,u,s,a){for(var h=u===an,f=this.entries,c=0,_=f.length;_>c&&!X(o,f[c][0]);c++);var p=_>c;if(p?f[c][1]===u:h)return this;if(r(a),(h||!p)&&r(s),!h||1!==f.length){if(!p&&!h&&f.length>=Rn)return Ze(t,f,o,u);var v=t&&t===this.ownerID,l=v?f:i(f);return p?h?c===_-1?l.pop():l[c]=l.pop():l[c]=[o,u]:l.push([o,u]),v?(this.entries=l,this):new Te(t,l)}},t(Be),Be.prototype.get=function(t,e,r,n){void 0===e&&(e=ee(r));var i=1<<((0===t?e:e>>>t)&sn),o=this.bitmap;return 0===(o&i)?n:this.nodes[or(o&i-1)].get(t+on,e,r,n)},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ee(n));var s=(0===e?r:r>>>e)&sn,a=1<<s,h=this.bitmap,f=0!==(h&a);if(!f&&i===an)return this;var c=or(h&a-1),_=this.nodes,p=f?_[c]:void 0,v=Xe(p,t,e+on,r,n,i,o,u);if(v===p)return this;if(!f&&v&&_.length>=Un)return tr(t,_,h,s,v);if(f&&!v&&2===_.length&&Fe(_[1^c]))return _[1^c];if(f&&v&&1===_.length&&Fe(v))return v;var l=t&&t===this.ownerID,y=f?v?h:h^a:h|a,d=f?v?ur(_,c,v,l):ar(_,c,l):sr(_,c,v,l);return l?(this.bitmap=y,this.nodes=d,this):new Be(t,y,d)},t(We),We.prototype.get=function(t,e,r,n){void 0===e&&(e=ee(r));var i=(0===t?e:e>>>t)&sn,o=this.nodes[i];return o?o.get(t+on,e,r,n):n},We.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ee(n));var s=(0===e?r:r>>>e)&sn,a=i===an,h=this.nodes,f=h[s];if(a&&!f)return this;var c=Xe(f,t,e+on,r,n,i,o,u);if(c===f)return this;var _=this.count;if(f){if(!c&&(_--,Ln>_))return $e(t,h,_,s)}else _++;var p=t&&t===this.ownerID,v=ur(h,s,c,p);return p?(this.count=_,this.nodes=v,this):new We(t,_,v)},t(Ce),Ce.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Ce.prototype.update=function(t,e,n,o,u,s,a){void 0===n&&(n=ee(o));var h=u===an;if(n!==this.keyHash)return h?this:(r(a),r(s),Ge(this,t,e,n,[o,u]));for(var f=this.entries,c=0,_=f.length;_>c&&!X(o,f[c][0]);c++);var p=_>c;if(p?f[c][1]===u:h)return this;if(r(a),(h||!p)&&r(s),h&&2===_)return new Je(t,this.keyHash,f[1^c]);var v=t&&t===this.ownerID,l=v?f:i(f);return p?h?c===_-1?l.pop():l[c]=l.pop():l[c]=[o,u]:l.push([o,u]),v?(this.entries=l,this):new Ce(t,this.keyHash,l) <del>},t(Je),Je.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},Je.prototype.update=function(t,e,n,i,o,u,s){var a=o===an,h=X(i,this.entry[0]);return(h?o===this.entry[1]:a)?this:(r(s),a?void r(u):h?t&&t===this.ownerID?(this.entry[1]=o,this):new Je(t,this.keyHash,[i,o]):(r(u),Ge(this,t,e,ee(i),[i,o])))},Te.prototype.iterate=Ce.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Be.prototype.iterate=We.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Je.prototype.iterate=function(t){return t(this.entry)},t(Pe,S),Pe.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return He(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return He(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return He(t,o.entry);e=this._stack=Ne(o,e)}continue}e=this._stack=this._stack.__prev}return z()};var Kn,Rn=un/4,Un=un/2,Ln=un/4;t(hr,Y),hr.of=function(){return this(arguments)},hr.prototype.toString=function(){return this.__toString("List [","]")},hr.prototype.get=function(t,e){if(t=u(this,t),0>t||t>=this.size)return e;t+=this._origin;var r=mr(this,t);return r&&r.array[t&sn]},hr.prototype.set=function(t,e){return lr(this,t,e)},hr.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},hr.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=on,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):vr()},hr.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations(function(r){gr(r,0,e+t.length);for(var n=0;t.length>n;n++)r.set(e+n,t[n])})},hr.prototype.pop=function(){return gr(this,0,-1)},hr.prototype.unshift=function(){var t=arguments;return this.withMutations(function(e){gr(e,-t.length); <del>for(var r=0;t.length>r;r++)e.set(r,t[r])})},hr.prototype.shift=function(){return gr(this,1)},hr.prototype.merge=function(){return wr(this,void 0,arguments)},hr.prototype.mergeWith=function(t){var e=rn.call(arguments,1);return wr(this,t,e)},hr.prototype.mergeDeep=function(){return wr(this,rr(void 0),arguments)},hr.prototype.mergeDeepWith=function(t){var e=rn.call(arguments,1);return wr(this,rr(t),e)},hr.prototype.setSize=function(t){return gr(this,0,t)},hr.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:gr(this,h(t,r),f(e,r))},hr.prototype.__iterator=function(t,e){var r=0,n=_r(this,e);return new S(function(){var e=n();return e===Cn?z():I(t,r++,e)})},hr.prototype.__iterate=function(t,e){for(var r,n=0,i=_r(this,e);(r=i())!==Cn&&t(r,n++,this)!==!1;);return n},hr.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?pr(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):(this.__ownerID=t,this)},hr.isList=fr;var Tn="",Bn=hr.prototype;Bn[Tn]=!0,Bn[nn]=Bn.remove,Bn.setIn=jn.setIn,Bn.deleteIn=Bn.removeIn=jn.removeIn,Bn.update=jn.update,Bn.updateIn=jn.updateIn,Bn.mergeIn=jn.mergeIn,Bn.mergeDeepIn=jn.mergeDeepIn,Bn.withMutations=jn.withMutations,Bn.asMutable=jn.asMutable,Bn.asImmutable=jn.asImmutable,Bn.wasAltered=jn.wasAltered,t(cr),cr.prototype.removeBefore=function(t,e,r){if(r===e?1<<e:0||0===this.array.length)return this;var n=r>>>e&sn;if(n>=this.array.length)return new cr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-on,r),i===u&&o)return this}if(o&&!i)return this;var s=dr(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},cr.prototype.removeAfter=function(t,e,r){if(r===e?1<<e:0||0===this.array.length)return this;var n=r-1>>>e&sn;if(n>=this.array.length)return this;var i,o=n===this.array.length-1;if(e>0){var u=this.array[n];if(i=u&&u.removeAfter(t,e-on,r),i===u&&o)return this}if(o&&!i)return this;var s=dr(this,t);return o||s.array.pop(),i&&(s.array[n]=i),s};var Wn,Cn={};t(Ir,Ue),Ir.of=function(){return this(arguments) <add>},Ue.prototype.setIn=function(t,e){return this.updateIn(t,an,function(){return e})},Ue.prototype.remove=function(t){return Qe(this,t,an)},Ue.prototype.deleteIn=function(t){return this.updateIn(t,function(){return an})},Ue.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},Ue.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=ir(this,Re(t),e,r);return n===an?void 0:n},Ue.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Ye()},Ue.prototype.merge=function(){return er(this,void 0,arguments)},Ue.prototype.mergeWith=function(t){var e=rn.call(arguments,1);return er(this,t,e)},Ue.prototype.mergeIn=function(t){var e=rn.call(arguments,1);return this.updateIn(t,Ye(),function(t){return t.merge.apply(t,e)})},Ue.prototype.mergeDeep=function(){return er(this,rr(void 0),arguments)},Ue.prototype.mergeDeepWith=function(t){var e=rn.call(arguments,1);return er(this,rr(t),e)},Ue.prototype.mergeDeepIn=function(t){var e=rn.call(arguments,1);return this.updateIn(t,Ye(),function(t){return t.mergeDeep.apply(t,e)})},Ue.prototype.sort=function(t){return Ir(qe(this,t))},Ue.prototype.sortBy=function(t,e){return Ir(qe(this,e,t))},Ue.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},Ue.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},Ue.prototype.asImmutable=function(){return this.__ensureOwner()},Ue.prototype.wasAltered=function(){return this.__altered},Ue.prototype.__iterator=function(t,e){return new Pe(this,t,e)},Ue.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},Ue.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ve(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ue.isMap=Le;var An="",jn=Ue.prototype;jn[An]=!0,jn[nn]=jn.remove,jn.removeIn=jn.deleteIn,Te.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1]; <add>return n},Te.prototype.update=function(t,e,n,o,u,s,a){for(var h=u===an,f=this.entries,c=0,_=f.length;_>c&&!X(o,f[c][0]);c++);var p=_>c;if(p?f[c][1]===u:h)return this;if(r(a),(h||!p)&&r(s),!h||1!==f.length){if(!p&&!h&&f.length>=Rn)return Ze(t,f,o,u);var v=t&&t===this.ownerID,l=v?f:i(f);return p?h?c===_-1?l.pop():l[c]=l.pop():l[c]=[o,u]:l.push([o,u]),v?(this.entries=l,this):new Te(t,l)}},Be.prototype.get=function(t,e,r,n){void 0===e&&(e=ee(r));var i=1<<((0===t?e:e>>>t)&sn),o=this.bitmap;return 0===(o&i)?n:this.nodes[or(o&i-1)].get(t+on,e,r,n)},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ee(n));var s=(0===e?r:r>>>e)&sn,a=1<<s,h=this.bitmap,f=0!==(h&a);if(!f&&i===an)return this;var c=or(h&a-1),_=this.nodes,p=f?_[c]:void 0,v=Xe(p,t,e+on,r,n,i,o,u);if(v===p)return this;if(!f&&v&&_.length>=Un)return tr(t,_,h,s,v);if(f&&!v&&2===_.length&&Fe(_[1^c]))return _[1^c];if(f&&v&&1===_.length&&Fe(v))return v;var l=t&&t===this.ownerID,y=f?v?h:h^a:h|a,d=f?v?ur(_,c,v,l):ar(_,c,l):sr(_,c,v,l);return l?(this.bitmap=y,this.nodes=d,this):new Be(t,y,d)},We.prototype.get=function(t,e,r,n){void 0===e&&(e=ee(r));var i=(0===t?e:e>>>t)&sn,o=this.nodes[i];return o?o.get(t+on,e,r,n):n},We.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ee(n));var s=(0===e?r:r>>>e)&sn,a=i===an,h=this.nodes,f=h[s];if(a&&!f)return this;var c=Xe(f,t,e+on,r,n,i,o,u);if(c===f)return this;var _=this.count;if(f){if(!c&&(_--,Ln>_))return $e(t,h,_,s)}else _++;var p=t&&t===this.ownerID,v=ur(h,s,c,p);return p?(this.count=_,this.nodes=v,this):new We(t,_,v)},Ce.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},Ce.prototype.update=function(t,e,n,o,u,s,a){void 0===n&&(n=ee(o));var h=u===an;if(n!==this.keyHash)return h?this:(r(a),r(s),Ge(this,t,e,n,[o,u]));for(var f=this.entries,c=0,_=f.length;_>c&&!X(o,f[c][0]);c++);var p=_>c;if(p?f[c][1]===u:h)return this;if(r(a),(h||!p)&&r(s),h&&2===_)return new Je(t,this.keyHash,f[1^c]);var v=t&&t===this.ownerID,l=v?f:i(f);return p?h?c===_-1?l.pop():l[c]=l.pop():l[c]=[o,u]:l.push([o,u]),v?(this.entries=l,this):new Ce(t,this.keyHash,l) <add>},Je.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},Je.prototype.update=function(t,e,n,i,o,u,s){var a=o===an,h=X(i,this.entry[0]);return(h?o===this.entry[1]:a)?this:(r(s),a?void r(u):h?t&&t===this.ownerID?(this.entry[1]=o,this):new Je(t,this.keyHash,[i,o]):(r(u),Ge(this,t,e,ee(i),[i,o])))},Te.prototype.iterate=Ce.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},Be.prototype.iterate=We.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},Je.prototype.iterate=function(t){return t(this.entry)},t(Pe,S),Pe.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return He(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return He(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return He(t,o.entry);e=this._stack=Ne(o,e)}continue}e=this._stack=this._stack.__prev}return z()};var Kn,Rn=un/4,Un=un/2,Ln=un/4;t(hr,Y),hr.of=function(){return this(arguments)},hr.prototype.toString=function(){return this.__toString("List [","]")},hr.prototype.get=function(t,e){if(t=u(this,t),0>t||t>=this.size)return e;t+=this._origin;var r=mr(this,t);return r&&r.array[t&sn]},hr.prototype.set=function(t,e){return lr(this,t,e)},hr.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},hr.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=on,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):vr()},hr.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations(function(r){gr(r,0,e+t.length);for(var n=0;t.length>n;n++)r.set(e+n,t[n])})},hr.prototype.pop=function(){return gr(this,0,-1)},hr.prototype.unshift=function(){var t=arguments;return this.withMutations(function(e){gr(e,-t.length); <add>for(var r=0;t.length>r;r++)e.set(r,t[r])})},hr.prototype.shift=function(){return gr(this,1)},hr.prototype.merge=function(){return wr(this,void 0,arguments)},hr.prototype.mergeWith=function(t){var e=rn.call(arguments,1);return wr(this,t,e)},hr.prototype.mergeDeep=function(){return wr(this,rr(void 0),arguments)},hr.prototype.mergeDeepWith=function(t){var e=rn.call(arguments,1);return wr(this,rr(t),e)},hr.prototype.setSize=function(t){return gr(this,0,t)},hr.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:gr(this,h(t,r),f(e,r))},hr.prototype.__iterator=function(t,e){var r=0,n=_r(this,e);return new S(function(){var e=n();return e===Cn?z():I(t,r++,e)})},hr.prototype.__iterate=function(t,e){for(var r,n=0,i=_r(this,e);(r=i())!==Cn&&t(r,n++,this)!==!1;);return n},hr.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?pr(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):(this.__ownerID=t,this)},hr.isList=fr;var Tn="",Bn=hr.prototype;Bn[Tn]=!0,Bn[nn]=Bn.remove,Bn.setIn=jn.setIn,Bn.deleteIn=Bn.removeIn=jn.removeIn,Bn.update=jn.update,Bn.updateIn=jn.updateIn,Bn.mergeIn=jn.mergeIn,Bn.mergeDeepIn=jn.mergeDeepIn,Bn.withMutations=jn.withMutations,Bn.asMutable=jn.asMutable,Bn.asImmutable=jn.asImmutable,Bn.wasAltered=jn.wasAltered,cr.prototype.removeBefore=function(t,e,r){if(r===e?1<<e:0||0===this.array.length)return this;var n=r>>>e&sn;if(n>=this.array.length)return new cr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-on,r),i===u&&o)return this}if(o&&!i)return this;var s=dr(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},cr.prototype.removeAfter=function(t,e,r){if(r===e?1<<e:0||0===this.array.length)return this;var n=r-1>>>e&sn;if(n>=this.array.length)return this;var i,o=n===this.array.length-1;if(e>0){var u=this.array[n];if(i=u&&u.removeAfter(t,e-on,r),i===u&&o)return this}if(o&&!i)return this;var s=dr(this,t);return o||s.array.pop(),i&&(s.array[n]=i),s};var Wn,Cn={};t(Ir,Ue),Ir.of=function(){return this(arguments) <ide> },Ir.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Ir.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Ir.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):qr()},Ir.prototype.set=function(t,e){return Dr(this,t,e)},Ir.prototype.remove=function(t){return Dr(this,t,an)},Ir.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Ir.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Ir.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Ir.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?br(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Ir.isOrderedMap=zr,Ir.prototype[vn]=!0,Ir.prototype[nn]=Ir.prototype.remove;var Jn;t(Mr,Y),Mr.of=function(){return this(arguments)},Mr.prototype.toString=function(){return this.__toString("Stack [","]")},Mr.prototype.get=function(t,e){for(var r=this._head;r&&t--;)r=r.next;return r?r.value:e},Mr.prototype.peek=function(){return this._head&&this._head.value},Mr.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):Er(t,e)},Mr.prototype.pushAll=function(t){if(t=v(t),0===t.size)return this;se(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Er(e,r)},Mr.prototype.pop=function(){return this.slice(1)},Mr.prototype.unshift=function(){return this.push.apply(this,arguments)},Mr.prototype.unshiftAll=function(t){return this.pushAll(t)},Mr.prototype.shift=function(){return this.pop.apply(this,arguments) <ide> },Mr.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):xr()},Mr.prototype.slice=function(t,e){if(a(t,e,this.size))return this;var r=h(t,this.size),n=f(e,this.size);if(n!==this.size)return Y.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Er(i,o)},Mr.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Er(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Mr.prototype.__iterate=function(t,e){if(e)return this.toSeq().cacheResult.__iterate(t,e);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Mr.prototype.__iterator=function(t,e){if(e)return this.toSeq().cacheResult().__iterator(t,e);var r=0,n=this._head;return new S(function(){if(n){var e=n.value;return n=n.next,I(t,r++,e)}return z()})},Mr.isStack=Or;var Pn="",Hn=Mr.prototype;Hn[Pn]=!0,Hn.withMutations=jn.withMutations,Hn.asMutable=jn.asMutable,Hn.asImmutable=jn.asImmutable,Hn.wasAltered=jn.wasAltered;var Nn;t(kr,Q),kr.of=function(){return this(arguments)},kr.fromKeys=function(t){return this(p(t).keySeq())},kr.prototype.toString=function(){return this.__toString("Set {","}")},kr.prototype.has=function(t){return this._map.has(t)},kr.prototype.add=function(t){return jr(this,this._map.set(t,!0))},kr.prototype.remove=function(t){return jr(this,this._map.remove(t))},kr.prototype.clear=function(){return jr(this,this._map.clear())},kr.prototype.union=function(){var t=rn.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0===this.size&&1===t.length?this.constructor(t[0]):this.withMutations(function(e){for(var r=0;t.length>r;r++)l(t[r]).forEach(function(t){return e.add(t)})})},kr.prototype.intersect=function(){var t=rn.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return l(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.every(function(t){return t.contains(e) <ide> })||r.remove(e)})})},kr.prototype.subtract=function(){var t=rn.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return l(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.some(function(t){return t.contains(e)})&&r.remove(e)})})},kr.prototype.merge=function(){return this.union.apply(this,arguments)},kr.prototype.mergeWith=function(){var t=rn.call(arguments,1);return this.union.apply(this,t)},kr.prototype.sort=function(t){return Ur(qe(this,t))},kr.prototype.sortBy=function(t,e){return Ur(qe(this,e,t))},kr.prototype.wasAltered=function(){return this._map.wasAltered()},kr.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},kr.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},kr.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):(this.__ownerID=t,this._map=e,this)},kr.isSet=Ar;var Vn="",Yn=kr.prototype;Yn[Vn]=!0,Yn[nn]=Yn.remove,Yn.mergeDeep=Yn.merge,Yn.mergeDeepWith=Yn.mergeWith,Yn.withMutations=jn.withMutations,Yn.asMutable=jn.asMutable,Yn.asImmutable=jn.asImmutable,Yn.__empty=Rr,Yn.__make=Kr;var Qn;t(Ur,kr),Ur.of=function(){return this(arguments)},Ur.fromKeys=function(t){return this(p(t).keySeq())},Ur.prototype.toString=function(){return this.__toString("OrderedSet {","}")},Ur.isOrderedSet=Lr;var Xn=Ur.prototype;Xn[vn]=!0,Xn.__empty=Br,Xn.__make=Tr;var Fn;t(Wr,V),Wr.prototype.toString=function(){return this.__toString(Jr(this)+" {","}")},Wr.prototype.has=function(t){return this._defaultValues.hasOwnProperty(t)},Wr.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._defaultValues[t];return this._map?this._map.get(t,r):r},Wr.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var t=Object.getPrototypeOf(this).constructor;return t._empty||(t._empty=Cr(this,Ye()))},Wr.prototype.set=function(t,e){if(!this.has(t))throw Error('Cannot set unknown key "'+t+'" on '+Jr(this)); <ide><path>resources/declassify.js <ide> var MagicString = require('magic-string'); <ide> /** <ide> * ES6 Class transpiler woefully lacking in features. Overwhelming priority to <ide> * produce the smallest reasonable source code. <add> * <add> * Clowntown: <add> * <add> * * Members are assigned directly to prototype instead of defined as <add> * properties. <add> * <add> * * Class Expressions only work when prefixed by an export declaration <add> * <ide> */ <ide> function declassify(source) { <ide> if (!/\bclass\b/.test(source)) { <ide> function declassify(source) { <ide> <ide> var body = new MagicString(source); <ide> <del> body.prepend('import createClass from "./utils/createClass"'); <del> <ide> var ast = acorn.parse(source, { <ide> ecmaVersion: 6, <ide> locations: true <ide> }); <ide> <add> var needsCreateClass; <ide> var classInfo; <ide> <ide> estraverse.traverse(ast, { <ide> enter: function (node) { <ide> switch (node.type) { <add> case 'ExportDeclaration': <add> var declaration = node.declaration; <add> if (declaration.type === 'ClassExpression' || <add> declaration.type === 'ClassDeclaration') { <add> body.insert( <add> declaration.start, <add> node.default ? <add> declaration.id.name + ';' : <add> '{' + declaration.id.name + '};' <add> ); <add> } <add> break; <add> <ide> case 'ClassExpression': <ide> case 'ClassDeclaration': <ide> var className = node.id.name; <ide> function declassify(source) { <ide> prev: classInfo, <ide> }; <ide> <del> var constructor = node.body.body.filter(function (method) { <del> return method.type === 'MethodDefinition' && <del> method.key.name === 'constructor'; <del> })[0]; <del> <del> var constructorBody = <del> constructor ? <del> body.slice(constructor.value.start, constructor.value.end) : <del> '() {}'; <add> var classExpr = ''; <ide> <del> var constructorSrc = 'function ' + className + constructorBody; <add> var hasSuper = !!node.superClass; <add> if (hasSuper) { <add> needsCreateClass = true; <add> var superExpr = body.slice(node.superClass.start, node.superClass.end); <add> classExpr += 'createClass(' + className + ', ' + superExpr + ');'; <add> } <ide> <del> var superClassExpr = node.superClass && <del> body.slice(node.superClass.start, node.superClass.end); <add> var hasConstructor = node.body.body.some(function (method) { <add> return method.type === 'MethodDefinition' && <add> method.key.name === 'constructor'; <add> }); <add> if (!hasConstructor) { <add> classExpr += 'function ' + className + '() {}'; <add> } <ide> <del> var classSrc = 'createClass('+className+ ( <del> superClassExpr ? ', ' + superClassExpr : '' <del> ) + ');'; <add> body.replace(node.start, node.body.start, classExpr); <ide> <del> body.replace( <del> node.start, <del> node.body.start, <del> constructorSrc + '\n' + classSrc <del> ); <add> // remove { } around class body <ide> body.remove(node.body.start, node.body.start + 1); <ide> body.remove(node.body.end - 1, node.body.end); <ide> break; <ide> <ide> case 'MethodDefinition': <ide> if (node.key.name === 'constructor') { <del> body.remove(node.start, node.end); <add> body.replace( <add> node.key.start, <add> node.key.end, <add> 'function ' + classInfo.name <add> ); <ide> } else { <ide> var methodName = node.key.name; <del> body.replace(node.start, node.key.end, <del> classInfo.name + <del> (node.static ? '.' : '.prototype.') + methodName + ' = function' <add> body.replace( <add> node.start, <add> node.key.end, <add> classInfo.name + (node.static ? '.' : '.prototype.') + <add> methodName + ' = function' <ide> ); <ide> body.insert(node.end, ';'); <ide> } <ide> function declassify(source) { <ide> } <ide> }); <ide> <add> if (needsCreateClass) { <add> body.prepend('import createClass from "./utils/createClass"'); <add> } <add> <ide> return body.toString(); <ide> } <ide>
3
Javascript
Javascript
fix a typo.
b3f15f8d5c7f3923ead925e7d9e24724777141cc
<ide><path>server/render.js <ide> export async function renderScriptError (req, res, page, error, customFields, op <ide> res.setHeader('Content-Type', 'text/javascript') <ide> res.end(` <ide> window.__NEXT_REGISTER_PAGE('${page}', function() { <del> var error = new Error('Page not exists: ${page}') <add> var error = new Error('Page does not exist: ${page}') <ide> error.statusCode = 404 <ide> <ide> return { error: error }
1
Text
Text
update urls in releasing_rails.md [ci skip]
da412b02f395c7b7a64c9d407bfebc2ec8094c58
<ide><path>RELEASING_RAILS.md <ide> Today is mostly coordination tasks. Here are the things you must do today: <ide> Do not release with a Red CI. You can find the CI status here: <ide> <ide> ``` <del>http://travis-ci.org/rails/rails <add>https://travis-ci.org/rails/rails <ide> ``` <ide> <ide> ### Is Sam Ruby happy? If not, make him happy. <ide> <ide> Sam Ruby keeps a [test suite](https://github.com/rubys/awdwr) that makes <ide> sure the code samples in his book <del>([Agile Web Development with Rails](https://pragprog.com/titles/rails5/agile-web-development-with-rails-5th-edition)) <add>([Agile Web Development with Rails](https://pragprog.com/book/rails51/agile-web-development-with-rails-51)) <ide> all work. These are valuable system tests <ide> for Rails. You can check the status of these tests here: <ide>
1
Text
Text
update webassembly strategy with wasm web api
0f82afaac0cafd5298c3087e93fd7f625b043377
<ide><path>doc/contributing/maintaining-web-assembly.md <ide> APIs as important: <ide> * WebAssembly System Interface (WASI). This provides the ability for <ide> WebAssembly to interact with the outside world. Node.js currently <ide> has an implementation (see below for more details). <del>* WebAssembly streaming APIs - As the Node.js implementation of <del> [WebStreams](https://nodejs.org/api/webstreams.html) matures, <del> implementing the embedder APIs to enable streaming with WebAssembly <add>* [WebAssembly Web API](https://www.w3.org/TR/wasm-web-api-1/). Node.js <add> currently has an implementation of streaming module compilation and <add> instantiation. As this and other specifications evolve, keeping up with them <ide> will be important. <ide> * [WebAssembly Component Model](https://github.com/WebAssembly/component-model/). <ide> This API is still in the definition stage but the project should
1
Python
Python
execute message tests by default
1c7057f09cfe4c1d27439b6ef9b1549ee0fa9496
<ide><path>tools/test.py <ide> def ExpandCommand(args): <ide> return ExpandCommand <ide> <ide> <del>BUILT_IN_TESTS = ['simple', 'pummel', 'internet'] <add>BUILT_IN_TESTS = ['simple', 'pummel', 'message', 'internet'] <ide> <ide> <ide> def GetSuites(test_root):
1
Ruby
Ruby
convert softwarespec test to spec
1be7852493cee7f7af9b31cef4547aca23bebb0b
<ide><path>Library/Homebrew/test/software_spec_spec.rb <add>require "software_spec" <add> <add>RSpec::Matchers.alias_matcher :have_defined_resource, :be_resource_defined <add>RSpec::Matchers.alias_matcher :have_defined_option, :be_option_defined <add> <add>describe SoftwareSpec do <add> let(:owner) { double(name: "some_name", full_name: "some_name", tap: "homebrew/core") } <add> <add> describe "#resource" do <add> it "defines a resource" do <add> subject.resource("foo") { url "foo-1.0" } <add> expect(subject).to have_defined_resource("foo") <add> end <add> <add> it "sets itself to be the resource's owner" do <add> subject.resource("foo") { url "foo-1.0" } <add> subject.owner = owner <add> subject.resources.each_value do |r| <add> expect(r.owner).to eq(subject) <add> end <add> end <add> <add> it "receives the owner's version if it has no own version" do <add> subject.url("foo-42") <add> subject.resource("bar") { url "bar" } <add> subject.owner = owner <add> <add> expect(subject.resource("bar").version).to eq("42") <add> end <add> <add> it "raises an error when duplicate resources are defined" do <add> subject.resource("foo") { url "foo-1.0" } <add> expect { <add> subject.resource("foo") { url "foo-1.0" } <add> }.to raise_error(DuplicateResourceError) <add> end <add> <add> it "raises an error when accessing missing resources" do <add> subject.owner = owner <add> expect { <add> subject.resource("foo") <add> }.to raise_error(ResourceMissingError) <add> end <add> end <add> <add> describe "#owner" do <add> it "sets the owner" do <add> subject.owner = owner <add> expect(subject.owner).to eq(owner) <add> end <add> <add> it "sets the name" do <add> subject.owner = owner <add> expect(subject.name).to eq(owner.name) <add> end <add> end <add> <add> describe "#option" do <add> it "defines an option" do <add> subject.option("foo") <add> expect(subject).to have_defined_option("foo") <add> end <add> <add> it "raises an error when it begins with dashes" do <add> expect { <add> subject.option("--foo") <add> }.to raise_error(ArgumentError) <add> end <add> <add> it "raises an error when name is empty" do <add> expect { <add> subject.option("") <add> }.to raise_error(ArgumentError) <add> end <add> <add> it "special cases the cxx11 option" do <add> subject.option(:cxx11) <add> expect(subject).to have_defined_option("c++11") <add> expect(subject).not_to have_defined_option("cxx11") <add> end <add> <add> it "supports options with descriptions" do <add> subject.option("bar", "description") <add> expect(subject.options.first.description).to eq("description") <add> end <add> <add> it "defaults to an empty string when no description is given" do <add> subject.option("foo") <add> expect(subject.options.first.description).to eq("") <add> end <add> end <add> <add> describe "#deprecated_option" do <add> it "allows specifying deprecated options" do <add> subject.deprecated_option("foo" => "bar") <add> expect(subject.deprecated_options).not_to be_empty <add> expect(subject.deprecated_options.first.old).to eq("foo") <add> expect(subject.deprecated_options.first.current).to eq("bar") <add> end <add> <add> it "allows specifying deprecated options as a Hash from an Array/String to an Array/String" do <add> subject.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"]) <add> expect(subject.deprecated_options).to include(DeprecatedOption.new("foo1", "bar1")) <add> expect(subject.deprecated_options).to include(DeprecatedOption.new("foo2", "bar1")) <add> expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar2")) <add> expect(subject.deprecated_options).to include(DeprecatedOption.new("foo3", "bar3")) <add> end <add> <add> it "raises an error when empty" do <add> expect { <add> subject.deprecated_option({}) <add> }.to raise_error(ArgumentError) <add> end <add> end <add> <add> describe "#depends_on" do <add> it "allows specifying dependencies" do <add> subject.depends_on("foo") <add> expect(subject.deps.first.name).to eq("foo") <add> end <add> <add> it "allows specifying optional dependencies" do <add> subject.depends_on "foo" => :optional <add> expect(subject).to have_defined_option("with-foo") <add> end <add> <add> it "allows specifying recommended dependencies" do <add> subject.depends_on "bar" => :recommended <add> expect(subject).to have_defined_option("without-bar") <add> end <add> end <add> <add> specify "explicit options override defaupt depends_on option description" do <add> subject.option("with-foo", "blah") <add> subject.depends_on("foo" => :optional) <add> expect(subject.options.first.description).to eq("blah") <add> end <add> <add> describe "#patch" do <add> it "adds a patch" do <add> subject.patch(:p1, :DATA) <add> expect(subject.patches.count).to eq(1) <add> expect(subject.patches.first.strip).to eq(:p1) <add> end <add> end <add>end <add> <add>describe HeadSoftwareSpec do <add> specify "#version" do <add> expect(subject.version).to eq(Version.create("HEAD")) <add> end <add> <add> specify "#verify_download_integrity" do <add> expect(subject.verify_download_integrity(Object.new)).to be nil <add> end <add>end <add> <add>describe BottleSpecification do <add> specify "#sha256" do <add> checksums = { <add> snow_leopard_32: "deadbeef" * 8, <add> snow_leopard: "faceb00c" * 8, <add> lion: "baadf00d" * 8, <add> mountain_lion: "8badf00d" * 8, <add> } <add> <add> checksums.each_pair do |cat, digest| <add> subject.sha256(digest => cat) <add> end <add> <add> checksums.each_pair do |cat, digest| <add> checksum, = subject.checksum_for(cat) <add> expect(Checksum.new(:sha256, digest)).to eq(checksum) <add> end <add> end <add> <add> %w[root_url prefix cellar rebuild].each do |method| <add> specify "##{method}" do <add> object = Object.new <add> subject.public_send(method, object) <add> expect(subject.public_send(method)).to eq(object) <add> end <add> end <add>end <ide><path>Library/Homebrew/test/software_spec_test.rb <del>require "testing_env" <del>require "software_spec" <del> <del>class SoftwareSpecTests < Homebrew::TestCase <del> def setup <del> super <del> @spec = SoftwareSpec.new <del> end <del> <del> def test_resource <del> @spec.resource("foo") { url "foo-1.0" } <del> assert @spec.resource_defined?("foo") <del> end <del> <del> def test_raises_when_duplicate_resources_are_defined <del> @spec.resource("foo") { url "foo-1.0" } <del> assert_raises(DuplicateResourceError) do <del> @spec.resource("foo") { url "foo-1.0" } <del> end <del> end <del> <del> def test_raises_when_accessing_missing_resources <del> @spec.owner = Class.new do <del> def name <del> "test" <del> end <del> <del> def full_name <del> "test" <del> end <del> <del> def tap <del> "homebrew/core" <del> end <del> end.new <del> assert_raises(ResourceMissingError) { @spec.resource("foo") } <del> end <del> <del> def test_set_owner <del> owner = stub name: "some_name", <del> full_name: "some_name", <del> tap: "homebrew/core" <del> @spec.owner = owner <del> assert_equal owner, @spec.owner <del> end <del> <del> def test_resource_owner <del> @spec.resource("foo") { url "foo-1.0" } <del> @spec.owner = stub name: "some_name", <del> full_name: "some_name", <del> tap: "homebrew/core" <del> assert_equal "some_name", @spec.name <del> @spec.resources.each_value { |r| assert_equal @spec, r.owner } <del> end <del> <del> def test_resource_without_version_receives_owners_version <del> @spec.url("foo-42") <del> @spec.resource("bar") { url "bar" } <del> @spec.owner = stub name: "some_name", <del> full_name: "some_name", <del> tap: "homebrew/core" <del> assert_version_equal "42", @spec.resource("bar").version <del> end <del> <del> def test_option <del> @spec.option("foo") <del> assert @spec.option_defined?("foo") <del> end <del> <del> def test_option_raises_when_begins_with_dashes <del> assert_raises(ArgumentError) { @spec.option("--foo") } <del> end <del> <del> def test_option_raises_when_name_empty <del> assert_raises(ArgumentError) { @spec.option("") } <del> end <del> <del> def test_cxx11_option_special_case <del> @spec.option(:cxx11) <del> assert @spec.option_defined?("c++11") <del> refute @spec.option_defined?("cxx11") <del> end <del> <del> def test_option_description <del> @spec.option("bar", "description") <del> assert_equal "description", @spec.options.first.description <del> end <del> <del> def test_option_description_defaults_to_empty_string <del> @spec.option("foo") <del> assert_equal "", @spec.options.first.description <del> end <del> <del> def test_deprecated_option <del> @spec.deprecated_option("foo" => "bar") <del> refute_empty @spec.deprecated_options <del> assert_equal "foo", @spec.deprecated_options.first.old <del> assert_equal "bar", @spec.deprecated_options.first.current <del> end <del> <del> def test_deprecated_options <del> @spec.deprecated_option(["foo1", "foo2"] => "bar1", "foo3" => ["bar2", "bar3"]) <del> assert_includes @spec.deprecated_options, DeprecatedOption.new("foo1", "bar1") <del> assert_includes @spec.deprecated_options, DeprecatedOption.new("foo2", "bar1") <del> assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar2") <del> assert_includes @spec.deprecated_options, DeprecatedOption.new("foo3", "bar3") <del> end <del> <del> def test_deprecated_option_raises_when_empty <del> assert_raises(ArgumentError) { @spec.deprecated_option({}) } <del> end <del> <del> def test_depends_on <del> @spec.depends_on("foo") <del> assert_equal "foo", @spec.deps.first.name <del> end <del> <del> def test_dependency_option_integration <del> @spec.depends_on "foo" => :optional <del> @spec.depends_on "bar" => :recommended <del> assert @spec.option_defined?("with-foo") <del> assert @spec.option_defined?("without-bar") <del> end <del> <del> def test_explicit_options_override_default_dep_option_description <del> @spec.option("with-foo", "blah") <del> @spec.depends_on("foo" => :optional) <del> assert_equal "blah", @spec.options.first.description <del> end <del> <del> def test_patch <del> @spec.patch :p1, :DATA <del> assert_equal 1, @spec.patches.length <del> assert_equal :p1, @spec.patches.first.strip <del> end <del>end <del> <del>class HeadSoftwareSpecTests < Homebrew::TestCase <del> def setup <del> super <del> @spec = HeadSoftwareSpec.new <del> end <del> <del> def test_version <del> assert_version_equal "HEAD", @spec.version <del> end <del> <del> def test_verify_download_integrity <del> assert_nil @spec.verify_download_integrity(Object.new) <del> end <del>end <del> <del>class BottleSpecificationTests < Homebrew::TestCase <del> def setup <del> super <del> @spec = BottleSpecification.new <del> end <del> <del> def test_checksum_setters <del> checksums = { <del> snow_leopard_32: "deadbeef"*8, <del> snow_leopard: "faceb00c"*8, <del> lion: "baadf00d"*8, <del> mountain_lion: "8badf00d"*8, <del> } <del> <del> checksums.each_pair do |cat, digest| <del> @spec.sha256(digest => cat) <del> end <del> <del> checksums.each_pair do |cat, digest| <del> checksum, = @spec.checksum_for(cat) <del> assert_equal Checksum.new(:sha256, digest), checksum <del> end <del> end <del> <del> def test_other_setters <del> double = Object.new <del> %w[root_url prefix cellar rebuild].each do |method| <del> @spec.send(method, double) <del> assert_equal double, @spec.send(method) <del> end <del> end <del>end
2
Ruby
Ruby
open incomplete download in append mode
6a406763f306d88c52729343b4a65e9050f8981f
<ide><path>Library/Homebrew/cask/lib/hbc/download_strategy.rb <ide> def fetch <ide> else <ide> had_incomplete_download = temporary_path.exist? <ide> begin <del> File.open(temporary_path, "w+") do |f| <add> File.open(temporary_path, "a+") do |f| <ide> f.flock(File::LOCK_EX) <ide> _fetch <ide> f.flock(File::LOCK_UN)
1
Go
Go
move image into sub pkg
82a5439835b0bff3ab3dfb169415948dae504d56
<ide><path>container.go <ide> import ( <ide> "github.com/dotcloud/docker/engine" <ide> "github.com/dotcloud/docker/execdriver" <ide> "github.com/dotcloud/docker/graphdriver" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/links" <ide> "github.com/dotcloud/docker/nat" <ide> "github.com/dotcloud/docker/runconfig" <ide> func (container *Container) Changes() ([]archive.Change, error) { <ide> return container.runtime.Changes(container) <ide> } <ide> <del>func (container *Container) GetImage() (*Image, error) { <add>func (container *Container) GetImage() (*image.Image, error) { <ide> if container.runtime == nil { <ide> return nil, fmt.Errorf("Can't get image of unregistered container") <ide> } <ide><path>graph.go <ide> import ( <ide> "github.com/dotcloud/docker/archive" <ide> "github.com/dotcloud/docker/dockerversion" <ide> "github.com/dotcloud/docker/graphdriver" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/runconfig" <ide> "github.com/dotcloud/docker/utils" <ide> "io" <ide> func (graph *Graph) Exists(id string) bool { <ide> } <ide> <ide> // Get returns the image with the given id, or an error if the image doesn't exist. <del>func (graph *Graph) Get(name string) (*Image, error) { <add>func (graph *Graph) Get(name string) (*image.Image, error) { <ide> id, err := graph.idIndex.Get(name) <ide> if err != nil { <ide> return nil, err <ide> } <ide> // FIXME: return nil when the image doesn't exist, instead of an error <del> img, err := LoadImage(graph.imageRoot(id)) <add> img, err := image.LoadImage(graph.ImageRoot(id)) <ide> if err != nil { <ide> return nil, err <ide> } <ide> if img.ID != id { <ide> return nil, fmt.Errorf("Image stored at '%s' has wrong id '%s'", id, img.ID) <ide> } <del> img.graph = graph <add> img.SetGraph(graph) <ide> <ide> if img.Size < 0 { <ide> rootfs, err := graph.driver.Get(img.ID) <ide> func (graph *Graph) Get(name string) (*Image, error) { <ide> } <ide> <ide> img.Size = size <del> if err := img.SaveSize(graph.imageRoot(id)); err != nil { <add> if err := img.SaveSize(graph.ImageRoot(id)); err != nil { <ide> return nil, err <ide> } <ide> } <ide> return img, nil <ide> } <ide> <ide> // Create creates a new image and registers it in the graph. <del>func (graph *Graph) Create(layerData archive.ArchiveReader, container *Container, comment, author string, config *runconfig.Config) (*Image, error) { <del> img := &Image{ <del> ID: GenerateID(), <add>func (graph *Graph) Create(layerData archive.ArchiveReader, container *Container, comment, author string, config *runconfig.Config) (*image.Image, error) { <add> img := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: comment, <ide> Created: time.Now().UTC(), <ide> DockerVersion: dockerversion.VERSION, <ide> func (graph *Graph) Create(layerData archive.ArchiveReader, container *Container <ide> <ide> // Register imports a pre-existing image into the graph. <ide> // FIXME: pass img as first argument <del>func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, img *Image) (err error) { <add>func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, img *image.Image) (err error) { <ide> defer func() { <ide> // If any error occurs, remove the new dir from the driver. <ide> // Don't check for errors since the dir might not have been created. <ide> func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, i <ide> graph.driver.Remove(img.ID) <ide> } <ide> }() <del> if err := ValidateID(img.ID); err != nil { <add> if err := utils.ValidateID(img.ID); err != nil { <ide> return err <ide> } <ide> // (This is a convenience to save time. Race conditions are taken care of by os.Rename) <ide> func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, i <ide> // Ensure that the image root does not exist on the filesystem <ide> // when it is not registered in the graph. <ide> // This is common when you switch from one graph driver to another <del> if err := os.RemoveAll(graph.imageRoot(img.ID)); err != nil && !os.IsNotExist(err) { <add> if err := os.RemoveAll(graph.ImageRoot(img.ID)); err != nil && !os.IsNotExist(err) { <ide> return err <ide> } <ide> <ide> func (graph *Graph) Register(jsonData []byte, layerData archive.ArchiveReader, i <ide> return fmt.Errorf("Driver %s failed to get image rootfs %s: %s", graph.driver, img.ID, err) <ide> } <ide> defer graph.driver.Put(img.ID) <del> img.graph = graph <del> if err := StoreImage(img, jsonData, layerData, tmp, rootfs); err != nil { <add> img.SetGraph(graph) <add> if err := image.StoreImage(img, jsonData, layerData, tmp, rootfs); err != nil { <ide> return err <ide> } <ide> // Commit <del> if err := os.Rename(tmp, graph.imageRoot(img.ID)); err != nil { <add> if err := os.Rename(tmp, graph.ImageRoot(img.ID)); err != nil { <ide> return err <ide> } <ide> graph.idIndex.Add(img.ID) <ide> func (graph *Graph) TempLayerArchive(id string, compression archive.Compression, <ide> <ide> // Mktemp creates a temporary sub-directory inside the graph's filesystem. <ide> func (graph *Graph) Mktemp(id string) (string, error) { <del> dir := path.Join(graph.Root, "_tmp", GenerateID()) <add> dir := path.Join(graph.Root, "_tmp", utils.GenerateRandomID()) <ide> if err := os.MkdirAll(dir, 0700); err != nil { <ide> return "", err <ide> } <ide> func (graph *Graph) Delete(name string) error { <ide> return err <ide> } <ide> graph.idIndex.Delete(id) <del> err = os.Rename(graph.imageRoot(id), tmp) <add> err = os.Rename(graph.ImageRoot(id), tmp) <ide> if err != nil { <ide> return err <ide> } <ide> func (graph *Graph) Delete(name string) error { <ide> } <ide> <ide> // Map returns a list of all images in the graph, addressable by ID. <del>func (graph *Graph) Map() (map[string]*Image, error) { <del> images := make(map[string]*Image) <del> err := graph.walkAll(func(image *Image) { <add>func (graph *Graph) Map() (map[string]*image.Image, error) { <add> images := make(map[string]*image.Image) <add> err := graph.walkAll(func(image *image.Image) { <ide> images[image.ID] = image <ide> }) <ide> if err != nil { <ide> func (graph *Graph) Map() (map[string]*Image, error) { <ide> <ide> // walkAll iterates over each image in the graph, and passes it to a handler. <ide> // The walking order is undetermined. <del>func (graph *Graph) walkAll(handler func(*Image)) error { <add>func (graph *Graph) walkAll(handler func(*image.Image)) error { <ide> files, err := ioutil.ReadDir(graph.Root) <ide> if err != nil { <ide> return err <ide> func (graph *Graph) walkAll(handler func(*Image)) error { <ide> // If an image of id ID has 3 children images, then the value for key ID <ide> // will be a list of 3 images. <ide> // If an image has no children, it will not have an entry in the table. <del>func (graph *Graph) ByParent() (map[string][]*Image, error) { <del> byParent := make(map[string][]*Image) <del> err := graph.walkAll(func(image *Image) { <del> parent, err := graph.Get(image.Parent) <add>func (graph *Graph) ByParent() (map[string][]*image.Image, error) { <add> byParent := make(map[string][]*image.Image) <add> err := graph.walkAll(func(img *image.Image) { <add> parent, err := graph.Get(img.Parent) <ide> if err != nil { <ide> return <ide> } <ide> if children, exists := byParent[parent.ID]; exists { <del> byParent[parent.ID] = append(children, image) <add> byParent[parent.ID] = append(children, img) <ide> } else { <del> byParent[parent.ID] = []*Image{image} <add> byParent[parent.ID] = []*image.Image{img} <ide> } <ide> }) <ide> return byParent, err <ide> } <ide> <ide> // Heads returns all heads in the graph, keyed by id. <ide> // A head is an image which is not the parent of another image in the graph. <del>func (graph *Graph) Heads() (map[string]*Image, error) { <del> heads := make(map[string]*Image) <add>func (graph *Graph) Heads() (map[string]*image.Image, error) { <add> heads := make(map[string]*image.Image) <ide> byParent, err := graph.ByParent() <ide> if err != nil { <ide> return nil, err <ide> } <del> err = graph.walkAll(func(image *Image) { <add> err = graph.walkAll(func(image *image.Image) { <ide> // If it's not in the byParent lookup table, then <ide> // it's not a parent -> so it's a head! <ide> if _, exists := byParent[image.ID]; !exists { <ide> func (graph *Graph) Heads() (map[string]*Image, error) { <ide> return heads, err <ide> } <ide> <del>func (graph *Graph) imageRoot(id string) string { <add>func (graph *Graph) ImageRoot(id string) string { <ide> return path.Join(graph.Root, id) <ide> } <ide> <ide><path>image/graph.go <add>package image <add> <add>import ( <add> "github.com/dotcloud/docker/graphdriver" <add>) <add> <add>type Graph interface { <add> Get(id string) (*Image, error) <add> ImageRoot(id string) string <add> Driver() graphdriver.Driver <add>} <add><path>image/image.go <del><path>image.go <del>package docker <add>package image <ide> <ide> import ( <del> "crypto/rand" <del> "encoding/hex" <ide> "encoding/json" <ide> "fmt" <ide> "github.com/dotcloud/docker/archive" <ide> "github.com/dotcloud/docker/graphdriver" <ide> "github.com/dotcloud/docker/runconfig" <ide> "github.com/dotcloud/docker/utils" <del> "io" <ide> "io/ioutil" <ide> "os" <ide> "path" <ide> "strconv" <del> "strings" <ide> "time" <ide> ) <ide> <ide> type Image struct { <ide> Config *runconfig.Config `json:"config,omitempty"` <ide> Architecture string `json:"architecture,omitempty"` <ide> OS string `json:"os,omitempty"` <del> graph *Graph <ide> Size int64 <add> <add> graph Graph <ide> } <ide> <ide> func LoadImage(root string) (*Image, error) { <ide> func LoadImage(root string) (*Image, error) { <ide> if err := json.Unmarshal(jsonData, img); err != nil { <ide> return nil, err <ide> } <del> if err := ValidateID(img.ID); err != nil { <add> if err := utils.ValidateID(img.ID); err != nil { <ide> return nil, err <ide> } <ide> <ide> func StoreImage(img *Image, jsonData []byte, layerData archive.ArchiveReader, ro <ide> var ( <ide> size int64 <ide> err error <del> driver = img.graph.driver <add> driver = img.graph.Driver() <ide> ) <ide> if err := os.MkdirAll(layer, 0755); err != nil { <ide> return err <ide> func StoreImage(img *Image, jsonData []byte, layerData archive.ArchiveReader, ro <ide> return nil <ide> } <ide> <add>func (img *Image) SetGraph(graph Graph) { <add> img.graph = graph <add>} <add> <ide> // SaveSize stores the current `size` value of `img` in the directory `root`. <ide> func (img *Image) SaveSize(root string) error { <ide> if err := ioutil.WriteFile(path.Join(root, "layersize"), []byte(strconv.Itoa(int(img.Size))), 0600); err != nil { <ide> func (img *Image) TarLayer() (arch archive.Archive, err error) { <ide> if img.graph == nil { <ide> return nil, fmt.Errorf("Can't load storage driver for unregistered image %s", img.ID) <ide> } <del> driver := img.graph.driver <add> driver := img.graph.Driver() <ide> if differ, ok := driver.(graphdriver.Differ); ok { <ide> return differ.Diff(img.ID) <ide> } <ide> func (img *Image) TarLayer() (arch archive.Archive, err error) { <ide> }), nil <ide> } <ide> <del>func ValidateID(id string) error { <del> if id == "" { <del> return fmt.Errorf("Image id can't be empty") <del> } <del> if strings.Contains(id, ":") { <del> return fmt.Errorf("Invalid character in image id: ':'") <del> } <del> return nil <del>} <del> <del>func GenerateID() string { <del> for { <del> id := make([]byte, 32) <del> if _, err := io.ReadFull(rand.Reader, id); err != nil { <del> panic(err) // This shouldn't happen <del> } <del> value := hex.EncodeToString(id) <del> // if we try to parse the truncated for as an int and we don't have <del> // an error then the value is all numberic and causes issues when <del> // used as a hostname. ref #3869 <del> if _, err := strconv.Atoi(utils.TruncateID(value)); err == nil { <del> continue <del> } <del> return value <del> } <del>} <del> <ide> // Image includes convenience proxy functions to its graph <ide> // These functions will return an error if the image is not registered <ide> // (ie. if image.graph == nil) <ide> func (img *Image) root() (string, error) { <ide> if img.graph == nil { <ide> return "", fmt.Errorf("Can't lookup root of unregistered image") <ide> } <del> return img.graph.imageRoot(img.ID), nil <add> return img.graph.ImageRoot(img.ID), nil <ide> } <ide> <del>func (img *Image) getParentsSize(size int64) int64 { <add>func (img *Image) GetParentsSize(size int64) int64 { <ide> parentImage, err := img.GetParent() <ide> if err != nil || parentImage == nil { <ide> return size <ide> } <ide> size += parentImage.Size <del> return parentImage.getParentsSize(size) <add> return parentImage.GetParentsSize(size) <ide> } <ide> <ide> // Depth returns the number of parents for a <ide><path>integration/api_test.go <ide> import ( <ide> "github.com/dotcloud/docker/api" <ide> "github.com/dotcloud/docker/dockerversion" <ide> "github.com/dotcloud/docker/engine" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/runconfig" <ide> "github.com/dotcloud/docker/utils" <ide> "github.com/dotcloud/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" <ide> func TestGetImagesByName(t *testing.T) { <ide> } <ide> assertHttpNotError(r, t) <ide> <del> img := &docker.Image{} <add> img := &image.Image{} <ide> if err := json.Unmarshal(r.Body.Bytes(), img); err != nil { <ide> t.Fatal(err) <ide> } <ide><path>integration/buildfile_test.go <ide> import ( <ide> "github.com/dotcloud/docker" <ide> "github.com/dotcloud/docker/archive" <ide> "github.com/dotcloud/docker/engine" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/utils" <ide> "io/ioutil" <ide> "net" <ide> func TestBuild(t *testing.T) { <ide> } <ide> } <ide> <del>func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, useCache bool) (*docker.Image, error) { <add>func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, useCache bool) (*image.Image, error) { <ide> if eng == nil { <ide> eng = NewTestEngine(t) <ide> runtime := mkRuntimeFromEngine(eng, t) <ide><path>integration/commands_test.go <ide> import ( <ide> "github.com/dotcloud/docker" <ide> "github.com/dotcloud/docker/api" <ide> "github.com/dotcloud/docker/engine" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/pkg/term" <ide> "github.com/dotcloud/docker/utils" <ide> "io" <ide> func TestImagesTree(t *testing.T) { <ide> }) <ide> } <ide> <del>func buildTestImages(t *testing.T, eng *engine.Engine) *docker.Image { <add>func buildTestImages(t *testing.T, eng *engine.Engine) *image.Image { <ide> <ide> var testBuilder = testContextTemplate{ <ide> ` <ide><path>integration/graph_test.go <ide> import ( <ide> "github.com/dotcloud/docker/archive" <ide> "github.com/dotcloud/docker/dockerversion" <ide> "github.com/dotcloud/docker/graphdriver" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/utils" <ide> "io" <ide> "io/ioutil" <ide> func TestInterruptedRegister(t *testing.T) { <ide> graph, _ := tempGraph(t) <ide> defer nukeGraph(graph) <ide> badArchive, w := io.Pipe() // Use a pipe reader as a fake archive which never yields data <del> image := &docker.Image{ <del> ID: docker.GenerateID(), <add> image := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: "testing", <ide> Created: time.Now(), <ide> } <ide> func TestGraphCreate(t *testing.T) { <ide> if err != nil { <ide> t.Fatal(err) <ide> } <del> image, err := graph.Create(archive, nil, "Testing", "", nil) <add> img, err := graph.Create(archive, nil, "Testing", "", nil) <ide> if err != nil { <ide> t.Fatal(err) <ide> } <del> if err := docker.ValidateID(image.ID); err != nil { <add> if err := utils.ValidateID(img.ID); err != nil { <ide> t.Fatal(err) <ide> } <del> if image.Comment != "Testing" { <del> t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", image.Comment) <add> if img.Comment != "Testing" { <add> t.Fatalf("Wrong comment: should be '%s', not '%s'", "Testing", img.Comment) <ide> } <del> if image.DockerVersion != dockerversion.VERSION { <del> t.Fatalf("Wrong docker_version: should be '%s', not '%s'", dockerversion.VERSION, image.DockerVersion) <add> if img.DockerVersion != dockerversion.VERSION { <add> t.Fatalf("Wrong docker_version: should be '%s', not '%s'", dockerversion.VERSION, img.DockerVersion) <ide> } <ide> images, err := graph.Map() <ide> if err != nil { <ide> t.Fatal(err) <ide> } else if l := len(images); l != 1 { <ide> t.Fatalf("Wrong number of images. Should be %d, not %d", 1, l) <ide> } <del> if images[image.ID] == nil { <del> t.Fatalf("Could not find image with id %s", image.ID) <add> if images[img.ID] == nil { <add> t.Fatalf("Could not find image with id %s", img.ID) <ide> } <ide> } <ide> <ide> func TestRegister(t *testing.T) { <ide> if err != nil { <ide> t.Fatal(err) <ide> } <del> image := &docker.Image{ <del> ID: docker.GenerateID(), <add> image := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: "testing", <ide> Created: time.Now(), <ide> } <ide> func TestDeletePrefix(t *testing.T) { <ide> assertNImages(graph, t, 0) <ide> } <ide> <del>func createTestImage(graph *docker.Graph, t *testing.T) *docker.Image { <add>func createTestImage(graph *docker.Graph, t *testing.T) *image.Image { <ide> archive, err := fakeTar() <ide> if err != nil { <ide> t.Fatal(err) <ide> func TestByParent(t *testing.T) { <ide> <ide> graph, _ := tempGraph(t) <ide> defer nukeGraph(graph) <del> parentImage := &docker.Image{ <del> ID: docker.GenerateID(), <add> parentImage := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: "parent", <ide> Created: time.Now(), <ide> Parent: "", <ide> } <del> childImage1 := &docker.Image{ <del> ID: docker.GenerateID(), <add> childImage1 := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: "child1", <ide> Created: time.Now(), <ide> Parent: parentImage.ID, <ide> } <del> childImage2 := &docker.Image{ <del> ID: docker.GenerateID(), <add> childImage2 := &image.Image{ <add> ID: utils.GenerateRandomID(), <ide> Comment: "child2", <ide> Created: time.Now(), <ide> Parent: parentImage.ID, <ide><path>integration/runtime_test.go <ide> import ( <ide> "fmt" <ide> "github.com/dotcloud/docker" <ide> "github.com/dotcloud/docker/engine" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/nat" <ide> "github.com/dotcloud/docker/runconfig" <ide> "github.com/dotcloud/docker/sysinit" <ide> func spawnGlobalDaemon() { <ide> <ide> // FIXME: test that ImagePull(json=true) send correct json output <ide> <del>func GetTestImage(runtime *docker.Runtime) *docker.Image { <add>func GetTestImage(runtime *docker.Runtime) *image.Image { <ide> imgs, err := runtime.Graph().Map() <ide> if err != nil { <ide> log.Fatalf("Unable to get the test image: %s", err) <ide><path>runtime.go <ide> import ( <ide> _ "github.com/dotcloud/docker/graphdriver/btrfs" <ide> _ "github.com/dotcloud/docker/graphdriver/devmapper" <ide> _ "github.com/dotcloud/docker/graphdriver/vfs" <add> "github.com/dotcloud/docker/image" <ide> _ "github.com/dotcloud/docker/networkdriver/lxc" <ide> "github.com/dotcloud/docker/networkdriver/portallocator" <ide> "github.com/dotcloud/docker/pkg/graphdb" <ide> func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe <ide> } <ide> <ide> // Generate id <del> id := GenerateID() <add> id := utils.GenerateRandomID() <ide> <ide> if name == "" { <ide> name, err = generateRandomName(runtime) <ide> func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe <ide> <ide> // Commit creates a new filesystem image from the current state of a container. <ide> // The image can optionally be tagged into a repository <del>func (runtime *Runtime) Commit(container *Container, repository, tag, comment, author string, config *runconfig.Config) (*Image, error) { <add>func (runtime *Runtime) Commit(container *Container, repository, tag, comment, author string, config *runconfig.Config) (*image.Image, error) { <ide> // FIXME: freeze the container before copying it to avoid data corruption? <ide> // FIXME: this shouldn't be in commands. <ide> if err := container.Mount(); err != nil { <ide><path>server.go <ide> import ( <ide> "github.com/dotcloud/docker/daemonconfig" <ide> "github.com/dotcloud/docker/dockerversion" <ide> "github.com/dotcloud/docker/engine" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/pkg/graphdb" <ide> "github.com/dotcloud/docker/registry" <ide> "github.com/dotcloud/docker/runconfig" <ide> func (srv *Server) ImageExport(job *engine.Job) engine.Status { <ide> return engine.StatusOK <ide> } <ide> <del>func (srv *Server) exportImage(image *Image, tempdir string) error { <del> for i := image; i != nil; { <add>func (srv *Server) exportImage(img *image.Image, tempdir string) error { <add> for i := img; i != nil; { <ide> // temporary directory <ide> tmpImageDir := path.Join(tempdir, i.ID) <ide> if err := os.Mkdir(tmpImageDir, os.ModeDir); err != nil { <ide> func (srv *Server) recursiveLoad(address, tmpImageDir string) error { <ide> utils.Debugf("Error reading embedded tar", err) <ide> return err <ide> } <del> img, err := NewImgJSON(imageJson) <add> img, err := image.NewImgJSON(imageJson) <ide> if err != nil { <ide> utils.Debugf("Error unmarshalling json", err) <ide> return err <ide> func (srv *Server) ImagesViz(job *engine.Job) engine.Status { <ide> job.Stdout.Write([]byte("digraph docker {\n")) <ide> <ide> var ( <del> parentImage *Image <add> parentImage *image.Image <ide> err error <ide> ) <ide> for _, image := range images { <ide> func (srv *Server) ImagesViz(job *engine.Job) engine.Status { <ide> <ide> func (srv *Server) Images(job *engine.Job) engine.Status { <ide> var ( <del> allImages map[string]*Image <add> allImages map[string]*image.Image <ide> err error <ide> ) <ide> if job.GetenvBool("all") { <ide> func (srv *Server) Images(job *engine.Job) engine.Status { <ide> out.Set("Id", image.ID) <ide> out.SetInt64("Created", image.Created.Unix()) <ide> out.SetInt64("Size", image.Size) <del> out.SetInt64("VirtualSize", image.getParentsSize(0)+image.Size) <add> out.SetInt64("VirtualSize", image.GetParentsSize(0)+image.Size) <ide> lookup[id] = out <ide> } <ide> <ide> func (srv *Server) Images(job *engine.Job) engine.Status { <ide> out.Set("Id", image.ID) <ide> out.SetInt64("Created", image.Created.Unix()) <ide> out.SetInt64("Size", image.Size) <del> out.SetInt64("VirtualSize", image.getParentsSize(0)+image.Size) <add> out.SetInt64("VirtualSize", image.GetParentsSize(0)+image.Size) <ide> outs.Add(out) <ide> } <ide> } <ide> func (srv *Server) ImageHistory(job *engine.Job) engine.Status { <ide> return job.Errorf("Usage: %s IMAGE", job.Name) <ide> } <ide> name := job.Args[0] <del> image, err := srv.runtime.repositories.LookupImage(name) <add> foundImage, err := srv.runtime.repositories.LookupImage(name) <ide> if err != nil { <ide> return job.Error(err) <ide> } <ide> func (srv *Server) ImageHistory(job *engine.Job) engine.Status { <ide> } <ide> <ide> outs := engine.NewTable("Created", 0) <del> err = image.WalkHistory(func(img *Image) error { <add> err = foundImage.WalkHistory(func(img *image.Image) error { <ide> out := &engine.Env{} <ide> out.Set("Id", img.ID) <ide> out.SetInt64("Created", img.Created.Unix()) <ide> func (srv *Server) pullImage(r *registry.Registry, out io.Writer, imgID, endpoin <ide> // FIXME: Keep going in case of error? <ide> return err <ide> } <del> img, err := NewImgJSON(imgJSON) <add> img, err := image.NewImgJSON(imgJSON) <ide> if err != nil { <ide> out.Write(sf.FormatProgress(utils.TruncateID(id), "Error pulling dependent layers", nil)) <ide> return fmt.Errorf("Failed to parse json: %s", err) <ide> func (srv *Server) canDeleteImage(imgID string) error { <ide> return err <ide> } <ide> <del> if err := parent.WalkHistory(func(p *Image) error { <add> if err := parent.WalkHistory(func(p *image.Image) error { <ide> if imgID == p.ID { <ide> return fmt.Errorf("Conflict, cannot delete %s because the container %s is using it", utils.TruncateID(imgID), utils.TruncateID(container.ID)) <ide> } <ide> func (srv *Server) canDeleteImage(imgID string) error { <ide> return nil <ide> } <ide> <del>func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*Image, error) { <add>func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*image.Image, error) { <ide> <ide> // Retrieve all images <ide> images, err := srv.runtime.graph.Map() <ide> func (srv *Server) ImageGetCached(imgID string, config *runconfig.Config) (*Imag <ide> } <ide> <ide> // Loop on the children of the given image and check the config <del> var match *Image <add> var match *image.Image <ide> for elem := range imageMap[imgID] { <ide> img, err := srv.runtime.graph.Get(elem) <ide> if err != nil { <ide> func (srv *Server) ContainerInspect(name string) (*Container, error) { <ide> return nil, fmt.Errorf("No such container: %s", name) <ide> } <ide> <del>func (srv *Server) ImageInspect(name string) (*Image, error) { <add>func (srv *Server) ImageInspect(name string) (*image.Image, error) { <ide> if image, err := srv.runtime.repositories.LookupImage(name); err == nil && image != nil { <ide> return image, nil <ide> } <ide><path>tags.go <ide> package docker <ide> import ( <ide> "encoding/json" <ide> "fmt" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/utils" <ide> "io/ioutil" <ide> "os" <ide> func (store *TagStore) Reload() error { <ide> return nil <ide> } <ide> <del>func (store *TagStore) LookupImage(name string) (*Image, error) { <add>func (store *TagStore) LookupImage(name string) (*image.Image, error) { <ide> // FIXME: standardize on returning nil when the image doesn't exist, and err for everything else <ide> // (so we can pass all errors here) <ide> repos, tag := utils.ParseRepositoryTag(name) <ide> func (store *TagStore) Get(repoName string) (Repository, error) { <ide> return nil, nil <ide> } <ide> <del>func (store *TagStore) GetImage(repoName, tagOrID string) (*Image, error) { <add>func (store *TagStore) GetImage(repoName, tagOrID string) (*image.Image, error) { <ide> repo, err := store.Get(repoName) <ide> if err != nil { <ide> return nil, err <ide><path>tags_unit_test.go <ide> package docker <ide> <ide> import ( <ide> "github.com/dotcloud/docker/graphdriver" <add> "github.com/dotcloud/docker/image" <ide> "github.com/dotcloud/docker/utils" <ide> "os" <ide> "path" <ide> func mkTestTagStore(root string, t *testing.T) *TagStore { <ide> if err != nil { <ide> t.Fatal(err) <ide> } <del> img := &Image{ID: testImageID} <add> img := &image.Image{ID: testImageID} <ide> // FIXME: this fails on Darwin with: <ide> // tags_unit_test.go:36: mkdir /var/folders/7g/b3ydb5gx4t94ndr_cljffbt80000gq/T/docker-test569b-tRunner-075013689/vfs/dir/foo/etc/postgres: permission denied <ide> if err := graph.Register(nil, archive, img); err != nil { <ide><path>utils/utils.go <ide> package utils <ide> <ide> import ( <ide> "bytes" <add> "crypto/rand" <ide> "crypto/sha1" <ide> "crypto/sha256" <ide> "encoding/hex" <ide> func TruncateID(id string) string { <ide> return id[:shortLen] <ide> } <ide> <add>// GenerateRandomID returns an unique id <add>func GenerateRandomID() string { <add> for { <add> id := make([]byte, 32) <add> if _, err := io.ReadFull(rand.Reader, id); err != nil { <add> panic(err) // This shouldn't happen <add> } <add> value := hex.EncodeToString(id) <add> // if we try to parse the truncated for as an int and we don't have <add> // an error then the value is all numberic and causes issues when <add> // used as a hostname. ref #3869 <add> if _, err := strconv.Atoi(TruncateID(value)); err == nil { <add> continue <add> } <add> return value <add> } <add>} <add> <add>func ValidateID(id string) error { <add> if id == "" { <add> return fmt.Errorf("Id can't be empty") <add> } <add> if strings.Contains(id, ":") { <add> return fmt.Errorf("Invalid character in id: ':'") <add> } <add> return nil <add>} <add> <ide> // Code c/c from io.Copy() modified to handle escape sequence <ide> func CopyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error) { <ide> buf := make([]byte, 32*1024)
14
PHP
PHP
fix tests that need to change error reporting
245b5eb095116aefc6b8f808be38f9e09d4af735
<ide><path>src/Error/BaseErrorHandler.php <ide> use RuntimeException; <ide> use Throwable; <ide> <del> <ide> /** <ide> * Base error handler that provides logic common to the CLI + web <ide> * error/exception handlers. <ide><path>tests/TestCase/Error/ErrorHandlerTest.php <ide> */ <ide> class ErrorHandlerTest extends TestCase <ide> { <del> protected $_restoreError = false; <del> <ide> /** <ide> * @var \Cake\Log\Engine\ArrayLog <ide> */ <ide> public function tearDown(): void <ide> parent::tearDown(); <ide> Log::reset(); <ide> $this->clearPlugins(); <del> if ($this->_restoreError) { <del> restore_error_handler(); <del> restore_exception_handler(); <del> } <ide> error_reporting(self::$errorLevel); <ide> } <ide> <ide> public function testInvalidRenderer(): void <ide> <ide> /** <ide> * test error handling when debug is on, an error should be printed from Debugger. <add> * <add> * @runInSeparateProcess <add> * @preserveGlobalState disabled <ide> */ <ide> public function testHandleErrorDebugOn(): void <ide> { <add> Configure::write('debug', true); <ide> $errorHandler = new ErrorHandler(); <ide> <ide> $result = ''; <ide> public function testHandleErrorDebugOn(): void <ide> $wrong = $wrong + 1; <ide> $result = ob_get_clean(); <ide> }); <del> $this->_restoreError = true; <ide> <ide> $this->assertMatchesRegularExpression('/<div class="cake-error">/', $result); <ide> if (version_compare(PHP_VERSION, '8.0.0-dev', '<')) { <ide> public function testHandleErrorDebugOn(): void <ide> $this->assertMatchesRegularExpression('/variable \$wrong/', $result); <ide> } <ide> $this->assertStringContainsString( <del> 'ErrorHandlerTest.php, line ' . (__LINE__ - 12), <add> 'ErrorHandlerTest.php, line ' . (__LINE__ - 13), <ide> $result, <ide> 'Should contain file and line reference' <ide> ); <ide> public static function errorProvider(): array <ide> /** <ide> * test error mappings <ide> * <add> * @runInSeparateProcess <add> * @preserveGlobalState disabled <ide> * @dataProvider errorProvider <ide> */ <ide> public function testErrorMapping(int $error, string $expected): void <ide> public function testErrorMapping(int $error, string $expected): void <ide> <ide> /** <ide> * test error prepended by @ <add> * <add> * @runInSeparateProcess <add> * @preserveGlobalState disabled <ide> */ <ide> public function testErrorSuppressed(): void <ide> { <ide> public function testErrorSuppressed(): void <ide> // phpcs:enable <ide> $this->assertEmpty(ob_get_clean()); <ide> }); <del> $this->_restoreError = true; <ide> } <ide> <ide> /** <ide> * Test that errors go into Cake Log when debug = 0. <add> * <add> * @runInSeparateProcess <add> * @preserveGlobalState disabled <ide> */ <ide> public function testHandleErrorDebugOff(): void <ide> { <ide> public function testHandleErrorDebugOff(): void <ide> $errorHandler->register(); <ide> $out = $out + 1; <ide> }); <del> $this->_restoreError = true; <ide> <ide> $messages = $this->logger->read(); <ide> $this->assertMatchesRegularExpression('/^(notice|debug|warning)/', $messages[0]); <ide> <ide> if (version_compare(PHP_VERSION, '8.0.0-dev', '<')) { <ide> $this->assertStringContainsString( <del> 'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ - 9) . ']', <add> 'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ - 8) . ']', <ide> $messages[0] <ide> ); <ide> } else { <ide> $this->assertStringContainsString( <del> 'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 14) . ']', <add> 'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 13) . ']', <ide> $messages[0] <ide> ); <ide> } <ide> } <ide> <ide> /** <ide> * Test that errors going into Cake Log include traces. <add> * <add> * @runInSeparateProcess <add> * @preserveGlobalState disabled <ide> */ <ide> public function testHandleErrorLoggingTrace(): void <ide> { <ide> public function testHandleErrorLoggingTrace(): void <ide> $errorHandler->register(); <ide> $out = $out + 1; <ide> }); <del> $this->_restoreError = true; <ide> <ide> $messages = $this->logger->read(); <ide> $this->assertMatchesRegularExpression('/^(notice|debug|warning)/', $messages[0]); <ide> public function testHandleErrorLoggingTrace(): void <ide> ); <ide> } else { <ide> $this->assertStringContainsString( <del> 'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 13) . ']', <add> 'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 12) . ']', <ide> $messages[0] <ide> ); <ide> }
2
Text
Text
add step for updating doc branch
da3a52746b3ec43049dc3a8ca58b44d0188f043e
<ide><path>hack/RELEASE-CHECKLIST.md <ide> git push origin $VERSION <ide> It's very important that we don't make the tag until after the official <ide> release is uploaded to get.docker.io! <ide> <del>### 10. Go to github to merge the `bump_$VERSION` into release <add>### 10. Go to github to merge the `bump_$VERSION` branch into release <ide> <del>Merging the pull request to the release branch will automatically <add>Don't delete the leftover branch just yet, as we will need it for the next step. <add> <add>### 11. Go to github to merge the `bump_$VERSION` branch into docs <add> <add>Merging the pull request to the docs branch will automatically <ide> update the documentation on the "latest" revision of the docs. You <ide> should see the updated docs 5-10 minutes after the merge. The docs <ide> will appear on http://docs.docker.io/. For more information about <ide> documentation releases, see `docs/README.md`. <ide> Don't forget to push that pretty blue button to delete the leftover <ide> branch afterwards! <ide> <del>### 11. Create a new pull request to merge release back into master <add>### 12. Create a new pull request to merge release back into master <ide> <ide> ```bash <ide> git checkout master <ide> echo "https://github.com/dotcloud/docker/compare/master...merge_release_$VERSION <ide> Again, get two maintainers to validate, then merge, then push that pretty <ide> blue button to delete your branch. <ide> <del>### 12. Rejoice and Evangelize! <add>### 13. Rejoice and Evangelize! <ide> <ide> Congratulations! You're done. <ide>
1
Python
Python
add --list option to migrate command
9f6e6009a44f26b9acfe3aadf76da7c29627a00b
<ide><path>django/core/management/commands/migrate.py <add># encoding: utf8 <add>from __future__ import unicode_literals <ide> from optparse import make_option <ide> from collections import OrderedDict <ide> from importlib import import_module <ide> from django.core.management.sql import custom_sql_for_model, emit_post_migrate_signal, emit_pre_migrate_signal <ide> from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS <ide> from django.db.migrations.executor import MigrationExecutor <del>from django.db.migrations.loader import AmbiguityError <add>from django.db.migrations.loader import MigrationLoader, AmbiguityError <ide> from django.utils.module_loading import module_has_submodule <ide> <ide> <ide> class Command(BaseCommand): <ide> 'Defaults to the "default" database.'), <ide> make_option('--fake', action='store_true', dest='fake', default=False, <ide> help='Mark migrations as run without actually running them'), <add> make_option('--list', action='store_true', dest='list', default=False, <add> help='Show a list of all known migrations and which are applied'), <ide> ) <ide> <ide> help = "Updates database schema. Manages both apps with migrations and those without." <ide> def handle(self, *args, **options): <ide> db = options.get('database') <ide> connection = connections[db] <ide> <add> # If they asked for a migration listing, quit main execution flow and show it <add> if options.get("list", False): <add> return self.show_migration_list(connection, args) <add> <ide> # Work out which apps have migrations and which do not <ide> executor = MigrationExecutor(connection, self.migration_progress_callback) <ide> <ide> def model_installed(model): <ide> call_command('loaddata', 'initial_data', verbosity=self.verbosity, database=connection.alias, skip_validation=True) <ide> <ide> return created_models <add> <add> def show_migration_list(self, connection, apps=None): <add> """ <add> Shows a list of all migrations on the system, or only those of <add> some named apps. <add> """ <add> # Load migrations from disk/DB <add> loader = MigrationLoader(connection) <add> graph = loader.graph <add> # If we were passed a list of apps, validate it <add> if apps: <add> invalid_apps = [] <add> for app in apps: <add> if app_label not in loader.migrated_apps: <add> invalid_apps.append(app) <add> if invalid_apps: <add> raise CommandError("No migrations present for: %s" % (", ".join(invalid_apps))) <add> # Otherwise, show all apps in alphabetic order <add> else: <add> apps = sorted(loader.migrated_apps) <add> # For each app, print its migrations in order from oldest (roots) to <add> # newest (leaves). <add> for app in apps: <add> self.stdout.write(app, self.style.MIGRATE_LABEL) <add> shown = set() <add> for node in graph.leaf_nodes(app): <add> for plan_node in graph.forwards_plan(node): <add> if plan_node not in shown and plan_node[0] == app: <add> if plan_node in loader.applied_migrations: <add> self.stdout.write(" [X] %s" % plan_node[1]) <add> else: <add> self.stdout.write(" [ ] %s" % plan_node[1]) <add> shown.add(plan_node) <add> # If we didn't print anything, then a small message <add> if not shown: <add> self.stdout.write(" (no migrations)", self.style.MIGRATE_FAILURE) <ide><path>django/db/migrations/graph.py <ide> def root_nodes(self): <ide> roots.add(node) <ide> return roots <ide> <del> def leaf_nodes(self): <add> def leaf_nodes(self, app=None): <ide> """ <ide> Returns all leaf nodes - that is, nodes with no dependents in their app. <ide> These are the "most current" version of an app's schema. <ide> def leaf_nodes(self): <ide> """ <ide> leaves = set() <ide> for node in self.nodes: <del> if not any(key[0] == node[0] for key in self.dependents.get(node, set())): <add> if not any(key[0] == node[0] for key in self.dependents.get(node, set())) and (not app or app == node[0]): <ide> leaves.add(node) <ide> return leaves <ide>
2