events
stringlengths
233
2.9k
input
stringlengths
273
1.93k
output
stringlengths
363
2.15k
User edited file: "core/src/test/java/eu/nerro/wolappla/entity/MagicPacketTest.java": ```diff @@ -17,7 +17,7 @@ } @Test - public void getSynchronizationStream_lengthShouldBeSix() { + public void getSynchronizationStream_arrayLengthShouldBeSix() { MagicPacket magicPacket = new MagicPacket(); byte[] stream = magicPacket.getSynchronizationStream(); @@ -32,4 +32,4 @@ assertThat(actualStream, equalTo(expectedStream)); } -} +} ```
```core/src/test/java/eu/nerro/wolappla/entity/MagicPacketTest.java package eu.nerro.wolappla.entity; import org.junit.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; public class MagicPacketTest { @Test public void getSynchronizationStream_shouldNotBeNull() { MagicPacket magicPacket = new MagicPacket(); byte[] synchronizationStream = magicPacket.getSynchronizationStream(); assertThat(synchronizationStream, is(notNullValue())); } @Test public void getSynchronizationStream_arrayLengthShouldBeSix() { MagicPacket magicPacket = new MagicPacket(); byte[] stream = magicPacket.getSynchronizationStream(); assertThat(stream.length, is(6)); } @Test <|user_cursor_is_here|> public void getSynchronizationStream_shouldBeSixBytesOf0xff() { MagicPacket magicPacket = new MagicPacket(); byte[] actualStream = magicPacket.getSynchronizationStream(); byte[] expectedStream = {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}; assertThat(actualStream, equalTo(expectedStream)); } } ```
```core/src/test/java/eu/nerro/wolappla/entity/MagicPacketTest.java package eu.nerro.wolappla.entity; import org.junit.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; public class MagicPacketTest { @Test public void getSynchronizationStream_shouldNotBeNull() { MagicPacket magicPacket = new MagicPacket(); byte[] synchronizationStream = magicPacket.getSynchronizationStream(); assertThat(synchronizationStream, is(notNullValue())); } @Test public void getSynchronizationStream_arrayLengthShouldBeSix() { MagicPacket magicPacket = new MagicPacket(); byte[] stream = magicPacket.getSynchronizationStream(); assertThat(stream.length, is(6)); } @Test <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "getSynchronizationStream_shouldBeSixBytesOf0xff", "newName": "getSynchronizationStream_shouldContainSixBytesOf0xFF"}} </|tool_call|> public void getSynchronizationStream_shouldBeSixBytesOf0xff() { MagicPacket magicPacket = new MagicPacket(); byte[] actualStream = magicPacket.getSynchronizationStream(); byte[] expectedStream = {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}; assertThat(actualStream, equalTo(expectedStream)); } } ```
User edited file: "pybossa/auth/category.py": ```diff @@ -1,7 +1,7 @@ from flask.ext.login import current_user -def create(app=None): +def create(category=None): if current_user.is_authenticated(): if current_user.admin is True: return True @@ -20,4 +20,4 @@ def delete(app): - return create(app) + return create(app) ``` User edited file: "pybossa/auth/category.py": ```diff @@ -11,7 +11,7 @@ return False -def read(app=None): +def read(category=None): return True ``` User edited file: "pybossa/auth/category.py": ```diff @@ -15,7 +15,7 @@ return True -def update(app): +def update(category): return create(app) ``` User edited file: "pybossa/auth/category.py": ```diff @@ -16,7 +16,7 @@ def update(category): - return create(app) + return create(category) def delete(app): ``` User edited file: "pybossa/auth/category.py": ```diff @@ -19,5 +19,5 @@ return create(category) -def delete(app): +def delete(category): return create(app) ```
```pybossa/auth/category.py from flask.ext.login import current_user def create(category=None): if current_user.is_authenticated(): if current_user.admin is True: return True else: return False else: return False def read(category=None): return True def update(category): return create(category) def delete(category): <|user_cursor_is_here|> return create(app) ```
```pybossa/auth/category.py from flask.ext.login import current_user def create(category=None): if current_user.is_authenticated(): if current_user.admin is True: return True else: return False else: return False def read(category=None): return True def update(category): return create(category) def delete(category): <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "app", "newName": "category"}} </|tool_call|> return create(app) ```
User edited file: "src/main/java/com/google/sps/data/AggregationResponseEntry.java": ```diff @@ -11,7 +11,7 @@ */ public final class AggregationResponseEntry { - private String assetId; + private String annotatedAssetId; private String location; private String user; private final int count; @@ -38,4 +38,4 @@ this.count = count; } -} +} ``` User edited file: "src/main/java/com/google/sps/data/AggregationResponseEntry.java": ```diff @@ -12,7 +12,7 @@ public final class AggregationResponseEntry { private String annotatedAssetId; - private String location; + private String annotatedLocation; private String user; private final int count; ``` User edited file: "src/main/java/com/google/sps/data/AggregationResponseEntry.java": ```diff @@ -13,7 +13,7 @@ private String annotatedAssetId; private String annotatedLocation; - private String user; + private String annotatedUser; private final int count; public AggregationResponseEntry(MultiKey key, int count, Set<AnnotatedField> fields) { ``` User edited file: "src/main/java/com/google/sps/data/AggregationResponseEntry.java": ```diff @@ -25,7 +25,7 @@ while (it.hasNext()) { switch(it.next()) { case ASSET_ID: - this.assetId = keys[currKey++]; + this.annotatedAssetId = keys[currKey++]; break; case LOCATION: this.location = keys[currKey++]; ```
```src/main/java/com/google/sps/data/AggregationResponseEntry.java package com.google.sps.data; import java.util.Iterator; import java.util.List; import java.util.Set; import org.apache.commons.collections4.keyvalue.MultiKey; /* * Class representing one row/entry in the aggregation response. A NULL field value * means the field was not being aggregated by, and will be omitted from the JSON response */ public final class AggregationResponseEntry { private String annotatedAssetId; private String annotatedLocation; private String annotatedUser; private final int count; public AggregationResponseEntry(MultiKey key, int count, Set<AnnotatedField> fields) { String keys[] = (String[]) key.getKeys(); int currKey = 0; Iterator<AnnotatedField> it = fields.iterator(); while (it.hasNext()) { switch(it.next()) { case ASSET_ID: this.annotatedAssetId = keys[currKey++]; break; case LOCATION: <|user_cursor_is_here|> this.location = keys[currKey++]; break; case USER: this.user = keys[currKey++]; break; } } this.count = count; } } ```
```src/main/java/com/google/sps/data/AggregationResponseEntry.java package com.google.sps.data; import java.util.Iterator; import java.util.List; import java.util.Set; import org.apache.commons.collections4.keyvalue.MultiKey; /* * Class representing one row/entry in the aggregation response. A NULL field value * means the field was not being aggregated by, and will be omitted from the JSON response */ public final class AggregationResponseEntry { private String annotatedAssetId; private String annotatedLocation; private String annotatedUser; private final int count; public AggregationResponseEntry(MultiKey key, int count, Set<AnnotatedField> fields) { String keys[] = (String[]) key.getKeys(); int currKey = 0; Iterator<AnnotatedField> it = fields.iterator(); while (it.hasNext()) { switch(it.next()) { case ASSET_ID: this.annotatedAssetId = keys[currKey++]; break; case LOCATION: <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "location", "newName": "annotatedLocation"}} </|tool_call|> this.location = keys[currKey++]; break; case USER: this.user = keys[currKey++]; break; } } this.count = count; } } ```
User edited file: "src/main/java/org/cru/godtools/s3/AmazonS3GodToolsConfig.java": ```diff @@ -9,9 +9,10 @@ { public static final String BUCKET_NAME = "cru-godtools"; - private static final String META = "meta"; + private static final String META = "meta/"; private static final String PACKAGES = "packages/"; private static final String LANGUAGES = "languages/"; + private static final String META_FILE = "meta"; private static final String ALL = "all/"; private static final String CURRENT = "current/"; private static final String XML = ".XML"; @@ -40,4 +41,4 @@ { return LANGUAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP; } -} +} ``` User edited file: "src/main/java/org/cru/godtools/s3/AmazonS3GodToolsConfig.java": ```diff @@ -15,8 +15,8 @@ private static final String META_FILE = "meta"; private static final String ALL = "all/"; private static final String CURRENT = "current/"; - private static final String XML = ".XML"; - private static final String ZIP = ".ZIP"; + private static final String XML = ".xml"; + private static final String ZIP = ".zip"; public static String getMetaKey(String languageCode, String packageCode) { ```
```src/main/java/org/cru/godtools/s3/AmazonS3GodToolsConfig.java package org.cru.godtools.s3; import com.google.common.base.Strings; /** * Created by ryancarlson on 7/11/15. */ public class AmazonS3GodToolsConfig { public static final String BUCKET_NAME = "cru-godtools"; private static final String META = "meta/"; private static final String PACKAGES = "packages/"; private static final String LANGUAGES = "languages/"; private static final String META_FILE = "meta"; private static final String ALL = "all/"; private static final String CURRENT = "current/"; private static final String XML = ".xml"; private static final String ZIP = ".zip"; public static String getMetaKey(String languageCode, String packageCode) { if(!Strings.isNullOrEmpty(languageCode) && !Strings.isNullOrEmpty(packageCode)) { <|user_cursor_is_here|> return META + CURRENT + languageCode + "/" + packageCode + "/" + META + XML; } if(!Strings.isNullOrEmpty(languageCode)) { return META + CURRENT + languageCode + "/" + META + XML; } return META + CURRENT + META + XML; } public static String getPackagesKey(String languageCode, String packageCode) { return PACKAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP; } public static String getLanguagesKey(String languageCode, String packagesCode) { return LANGUAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP; } } ```
```src/main/java/org/cru/godtools/s3/AmazonS3GodToolsConfig.java package org.cru.godtools.s3; import com.google.common.base.Strings; /** * Created by ryancarlson on 7/11/15. */ public class AmazonS3GodToolsConfig { public static final String BUCKET_NAME = "cru-godtools"; private static final String META = "meta/"; private static final String PACKAGES = "packages/"; private static final String LANGUAGES = "languages/"; private static final String META_FILE = "meta"; private static final String ALL = "all/"; private static final String CURRENT = "current/"; private static final String XML = ".xml"; private static final String ZIP = ".zip"; public static String getMetaKey(String languageCode, String packageCode) { if(!Strings.isNullOrEmpty(languageCode) && !Strings.isNullOrEmpty(packageCode)) { <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "META", "newName": "META_FILE"}} </|tool_call|> return META + CURRENT + languageCode + "/" + packageCode + "/" + META + XML; } if(!Strings.isNullOrEmpty(languageCode)) { return META + CURRENT + languageCode + "/" + META + XML; } return META + CURRENT + META + XML; } public static String getPackagesKey(String languageCode, String packageCode) { return PACKAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP; } public static String getLanguagesKey(String languageCode, String packagesCode) { return LANGUAGES + CURRENT + languageCode + "/" + ALL + languageCode + ZIP; } } ```
User edited file: "src/test/java/org/junit/contrib/truth/extensiontest/MySubject.java": ```diff @@ -19,7 +19,6 @@ import org.junit.contrib.truth.FailureStrategy; import org.junit.contrib.truth.subjects.Subject; -import org.junit.contrib.truth.subjects.And; /** * A simple example Subject to demonstrate extension. @@ -39,4 +38,4 @@ return new And<MySubject>(this); } -} +} ```
```src/test/java/org/junit/contrib/truth/extensiontest/MySubject.java /* * Copyright (c) 2011 David Saff * Copyright (c) 2011 Christian Gruber * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.junit.contrib.truth.extensiontest; import org.junit.contrib.truth.FailureStrategy; import org.junit.contrib.truth.subjects.Subject; /** * A simple example Subject to demonstrate extension. * * @author Christian Gruber ([email protected]) */ public class MySubject extends Subject<MySubject, MyType> { public MySubject(FailureStrategy failureStrategy, MyType subject) { super(failureStrategy, subject); } public And<MySubject> matches(MyType object) { if (getSubject().value != object.value) { fail("matches", getSubject(), object); } <|user_cursor_is_here|> return new And<MySubject>(this); } } ```
```src/test/java/org/junit/contrib/truth/extensiontest/MySubject.java /* * Copyright (c) 2011 David Saff * Copyright (c) 2011 Christian Gruber * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.junit.contrib.truth.extensiontest; import org.junit.contrib.truth.FailureStrategy; import org.junit.contrib.truth.subjects.Subject; /** * A simple example Subject to demonstrate extension. * * @author Christian Gruber ([email protected]) */ public class MySubject extends Subject<MySubject, MyType> { public MySubject(FailureStrategy failureStrategy, MyType subject) { super(failureStrategy, subject); } public And<MySubject> matches(MyType object) { if (getSubject().value != object.value) { fail("matches", getSubject(), object); } <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "new And<MySubject>(this)", "newName": "nextChain()"}} </|tool_call|> return new And<MySubject>(this); } } ```
User edited file: "tests/integration/test_proxy.py": ```diff @@ -3,7 +3,6 @@ # External imports import multiprocessing -import SocketServer import SimpleHTTPServer import pytest requests = pytest.importorskip("requests") @@ -39,4 +38,4 @@ '''Ensure that it works with a proxy.''' with vcr.use_cassette(str(tmpdir.join('proxy.yaml'))): requests.get(httpbin.url, proxies={'http': proxy_server}) - requests.get(httpbin.url, proxies={'http': proxy_server}) + requests.get(httpbin.url, proxies={'http': proxy_server}) ``` User edited file: "tests/integration/test_proxy.py": ```diff @@ -3,7 +3,6 @@ # External imports import multiprocessing -import SimpleHTTPServer import pytest requests = pytest.importorskip("requests") ``` User edited file: "tests/integration/test_proxy.py": ```diff @@ -6,6 +6,7 @@ import pytest requests = pytest.importorskip("requests") +from six.moves import socketserver, SimpleHTTPServer from six.moves.urllib.request import urlopen # Internal imports ```
```tests/integration/test_proxy.py # -*- coding: utf-8 -*- '''Test using a proxy.''' # External imports import multiprocessing import pytest requests = pytest.importorskip("requests") from six.moves import socketserver, SimpleHTTPServer from six.moves.urllib.request import urlopen # Internal imports import vcr class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): ''' Simple proxy server. (from: http://effbot.org/librarybook/simplehttpserver.htm). ''' def do_GET(self): self.copyfile(urlopen(self.path), self.wfile) @pytest.yield_fixture(scope='session') def proxy_server(httpbin): <|user_cursor_is_here|> httpd = SocketServer.ForkingTCPServer(('', 0), Proxy) proxy_process = multiprocessing.Process( target=httpd.serve_forever, ) proxy_process.start() yield 'http://{}:{}'.format(*httpd.server_address) proxy_process.terminate() def test_use_proxy(tmpdir, httpbin, proxy_server): '''Ensure that it works with a proxy.''' with vcr.use_cassette(str(tmpdir.join('proxy.yaml'))): requests.get(httpbin.url, proxies={'http': proxy_server}) requests.get(httpbin.url, proxies={'http': proxy_server}) ```
```tests/integration/test_proxy.py # -*- coding: utf-8 -*- '''Test using a proxy.''' # External imports import multiprocessing import pytest requests = pytest.importorskip("requests") from six.moves import socketserver, SimpleHTTPServer from six.moves.urllib.request import urlopen # Internal imports import vcr class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): ''' Simple proxy server. (from: http://effbot.org/librarybook/simplehttpserver.htm). ''' def do_GET(self): self.copyfile(urlopen(self.path), self.wfile) @pytest.yield_fixture(scope='session') def proxy_server(httpbin): <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "SocketServer", "newName": "socketserver"}} </|tool_call|> httpd = SocketServer.ForkingTCPServer(('', 0), Proxy) proxy_process = multiprocessing.Process( target=httpd.serve_forever, ) proxy_process.start() yield 'http://{}:{}'.format(*httpd.server_address) proxy_process.terminate() def test_use_proxy(tmpdir, httpbin, proxy_server): '''Ensure that it works with a proxy.''' with vcr.use_cassette(str(tmpdir.join('proxy.yaml'))): requests.get(httpbin.url, proxies={'http': proxy_server}) requests.get(httpbin.url, proxies={'http': proxy_server}) ```
User edited file: "hc2002/plugin/symbolic_values.py": ```diff @@ -8,7 +8,8 @@ 'subnet:') def apply(instance): - def _resolve_symbol(value): + def resolve_symbol(original_value): + value = original_value visited = set() while isinstance(value, basestring) \ and value.startswith(prefix): @@ -33,4 +34,4 @@ # Drop resolvable symbols for key in instance.keys(): if key.startswith(_prefixes): - del instance[key] + del instance[key] ``` User edited file: "hc2002/plugin/symbolic_values.py": ```diff @@ -18,6 +18,13 @@ and value not in visited: visited.add(value) value = instance[value] + else: + if original_value == value: + raise Exception("Unable to resolve '%s'" % value) + else: + raise Exception( + "While resolving '%s': unable to resolve '%s'" + % (original_value, value)) return value # Resolve symbols ```
```hc2002/plugin/symbolic_values.py import hc2002.plugin as plugin import hc2002.config as config plugin.register_for_resource(__name__, 'hc2002.resource.instance') _prefixes = ('availability-zone:', 'image:', 'kernel:', 'key:', 'load-balancers:', 'ramdisk:', 'security-groups:', 'spot-price:', 'subnet:') def apply(instance): def resolve_symbol(original_value): value = original_value visited = set() while isinstance(value, basestring) \ and value.startswith(prefix): value = value.format(region=config.region, **instance) if value in instance \ and value not in visited: visited.add(value) value = instance[value] else: if original_value == value: raise Exception("Unable to resolve '%s'" % value) else: raise Exception( "While resolving '%s': unable to resolve '%s'" % (original_value, value)) return value # Resolve symbols for prefix in _prefixes: key = prefix[:-1] if key not in instance: continue if isinstance(instance[key], basestring): <|user_cursor_is_here|> instance[key] = _resolve_symbol(instance[key]) elif isinstance(instance[key], list): instance[key] = map(_resolve_symbol, instance[key]) # Drop resolvable symbols for key in instance.keys(): if key.startswith(_prefixes): del instance[key] ```
```hc2002/plugin/symbolic_values.py import hc2002.plugin as plugin import hc2002.config as config plugin.register_for_resource(__name__, 'hc2002.resource.instance') _prefixes = ('availability-zone:', 'image:', 'kernel:', 'key:', 'load-balancers:', 'ramdisk:', 'security-groups:', 'spot-price:', 'subnet:') def apply(instance): def resolve_symbol(original_value): value = original_value visited = set() while isinstance(value, basestring) \ and value.startswith(prefix): value = value.format(region=config.region, **instance) if value in instance \ and value not in visited: visited.add(value) value = instance[value] else: if original_value == value: raise Exception("Unable to resolve '%s'" % value) else: raise Exception( "While resolving '%s': unable to resolve '%s'" % (original_value, value)) return value # Resolve symbols for prefix in _prefixes: key = prefix[:-1] if key not in instance: continue if isinstance(instance[key], basestring): <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "_resolve_symbol", "newName": "resolve_symbol"}} </|tool_call|> instance[key] = _resolve_symbol(instance[key]) elif isinstance(instance[key], list): instance[key] = map(_resolve_symbol, instance[key]) # Drop resolvable symbols for key in instance.keys(): if key.startswith(_prefixes): del instance[key] ```
User edited file: "src/protocolsupport/protocol/transformer/middlepacket/clientbound/play/MiddleSpawnPainting.java": ```diff @@ -1,6 +1,7 @@ package protocolsupport.protocol.transformer.middlepacket.clientbound.play; import java.io.IOException; +import java.util.UUID; import net.minecraft.server.v1_9_R1.BlockPosition; import protocolsupport.protocol.PacketDataSerializer; @@ -21,4 +22,4 @@ direction = serializer.readByte(); } -} +} ``` User edited file: "src/protocolsupport/protocol/transformer/middlepacket/clientbound/play/MiddleSpawnPainting.java": ```diff @@ -10,6 +10,7 @@ public abstract class MiddleSpawnPainting<T> extends ClientBoundMiddlePacket<T> { protected int entityId; + protected UUID uuid; protected String type; protected BlockPosition position; protected int direction; ``` User edited file: "src/protocolsupport/protocol/transformer/middlepacket/clientbound/play/MiddleSpawnPainting.java": ```diff @@ -18,6 +18,7 @@ @Override public void readFromServerData(PacketDataSerializer serializer) throws IOException { entityId = serializer.readVarInt(); + uuid = serializer.readUUID(); type = serializer.readString(13); position = serializer.readPosition(); direction = serializer.readByte(); ```
```src/protocolsupport/protocol/transformer/middlepacket/clientbound/play/MiddleSpawnPainting.java package protocolsupport.protocol.transformer.middlepacket.clientbound.play; import java.io.IOException; import java.util.UUID; import net.minecraft.server.v1_9_R1.BlockPosition; import protocolsupport.protocol.PacketDataSerializer; import protocolsupport.protocol.transformer.middlepacket.ClientBoundMiddlePacket; public abstract class MiddleSpawnPainting<T> extends ClientBoundMiddlePacket<T> { protected int entityId; protected UUID uuid; protected String type; protected BlockPosition position; protected int direction; @Override public void readFromServerData(PacketDataSerializer serializer) throws IOException { entityId = serializer.readVarInt(); uuid = serializer.readUUID(); type = serializer.readString(13); position = serializer.readPosition(); <|user_cursor_is_here|> direction = serializer.readByte(); } } ```
```src/protocolsupport/protocol/transformer/middlepacket/clientbound/play/MiddleSpawnPainting.java package protocolsupport.protocol.transformer.middlepacket.clientbound.play; import java.io.IOException; import java.util.UUID; import net.minecraft.server.v1_9_R1.BlockPosition; import protocolsupport.protocol.PacketDataSerializer; import protocolsupport.protocol.transformer.middlepacket.ClientBoundMiddlePacket; public abstract class MiddleSpawnPainting<T> extends ClientBoundMiddlePacket<T> { protected int entityId; protected UUID uuid; protected String type; protected BlockPosition position; protected int direction; @Override public void readFromServerData(PacketDataSerializer serializer) throws IOException { entityId = serializer.readVarInt(); uuid = serializer.readUUID(); type = serializer.readString(13); position = serializer.readPosition(); <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "readByte", "newName": "readUnsignedByte"}} </|tool_call|> direction = serializer.readByte(); } } ```
User edited file: "extend.js": ```diff @@ -28,7 +28,7 @@ a.getBar() == 'sim' */ -var create = require('std/create') +var copy = require('std/copy') module.exports = function extend(target, extendWith) { target = target ? create(target) : {} @@ -37,4 +37,4 @@ target[key] = extendWith[key] } return target -} +} ```
```extend.js /* Example usage: var A = Class(function() { var defaults = { foo: 'cat', bar: 'dum' } this.init = function(opts) { opts = std.extend(opts, defaults) this._foo = opts.foo this._bar = opts.bar } this.getFoo = function() { return this._foo } this.getBar = function() { return this._bar } }) var a = new A({ bar:'sim' }) a.getFoo() == 'cat' a.getBar() == 'sim' */ var copy = require('std/copy') module.exports = function extend(target, extendWith) { <|user_cursor_is_here|> target = target ? create(target) : {} for (var key in extendWith) { if (typeof target[key] != 'undefined') { continue } target[key] = extendWith[key] } return target } ```
```extend.js /* Example usage: var A = Class(function() { var defaults = { foo: 'cat', bar: 'dum' } this.init = function(opts) { opts = std.extend(opts, defaults) this._foo = opts.foo this._bar = opts.bar } this.getFoo = function() { return this._foo } this.getBar = function() { return this._bar } }) var a = new A({ bar:'sim' }) a.getFoo() == 'cat' a.getBar() == 'sim' */ var copy = require('std/copy') module.exports = function extend(target, extendWith) { <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "create", "newName": "copy"}} </|tool_call|> target = target ? create(target) : {} for (var key in extendWith) { if (typeof target[key] != 'undefined') { continue } target[key] = extendWith[key] } return target } ```
User edited file: "src/test_path.rs": ```diff @@ -18,7 +18,7 @@ #[test] fn test_path() { assert_eq!(parse_str(&["./argparse_test", "-s", "/hello"]), - From::from("/hello")); + PathBuf::from("/hello")); assert_eq!(parse_str(&["./argparse_test", "--set", "a///b/../c"]), From::from("a/b/../c")); } @@ -27,4 +27,4 @@ #[should_panic] fn test_err() { parse_str(&["./argparse_test", "--set"]); -} +} ```
```src/test_path.rs use std::path::PathBuf; use parser::ArgumentParser; use super::Parse; use test_parser::{check_ok}; fn parse_str(args: &[&str]) -> PathBuf { let mut val: PathBuf = From::from(""); { let mut ap = ArgumentParser::new(); ap.refer(&mut val) .add_option(&["-s", "--set"], Parse, "Set path value"); check_ok(&ap, args); } return val; } #[test] fn test_path() { assert_eq!(parse_str(&["./argparse_test", "-s", "/hello"]), PathBuf::from("/hello")); assert_eq!(parse_str(&["./argparse_test", "--set", "a///b/../c"]), <|user_cursor_is_here|> From::from("a/b/../c")); } #[test] #[should_panic] fn test_err() { parse_str(&["./argparse_test", "--set"]); } ```
```src/test_path.rs use std::path::PathBuf; use parser::ArgumentParser; use super::Parse; use test_parser::{check_ok}; fn parse_str(args: &[&str]) -> PathBuf { let mut val: PathBuf = From::from(""); { let mut ap = ArgumentParser::new(); ap.refer(&mut val) .add_option(&["-s", "--set"], Parse, "Set path value"); check_ok(&ap, args); } return val; } #[test] fn test_path() { assert_eq!(parse_str(&["./argparse_test", "-s", "/hello"]), PathBuf::from("/hello")); assert_eq!(parse_str(&["./argparse_test", "--set", "a///b/../c"]), <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "From", "newName": "PathBuf"}} </|tool_call|> From::from("a/b/../c")); } #[test] #[should_panic] fn test_err() { parse_str(&["./argparse_test", "--set"]); } ```
User edited file: "tests/test_train_dictionary.py": ```diff @@ -1,3 +1,4 @@ +import sys import unittest import zstd @@ -29,4 +30,4 @@ self.assertLessEqual(len(d), 8192) dict_id = zstd.dictionary_id(d) - self.assertIsInstance(dict_id, int) + self.assertIsInstance(dict_id, int) ``` User edited file: "tests/test_train_dictionary.py": ```diff @@ -2,6 +2,12 @@ import unittest import zstd + + +if sys.version_info[0] >= 3: + int_type = int +else: + int_type = long class TestTrainDictionary(unittest.TestCase): ```
```tests/test_train_dictionary.py import sys import unittest import zstd if sys.version_info[0] >= 3: int_type = int else: int_type = long class TestTrainDictionary(unittest.TestCase): def test_no_args(self): with self.assertRaises(TypeError): zstd.train_dictionary() def test_bad_args(self): with self.assertRaises(TypeError): zstd.train_dictionary(8192, u'foo') with self.assertRaises(ValueError): zstd.train_dictionary(8192, [u'foo']) def test_basic(self): samples = [] for i in range(128): samples.append(b'foo' * 64) samples.append(b'bar' * 64) samples.append(b'foobar' * 64) samples.append(b'baz' * 64) samples.append(b'foobaz' * 64) samples.append(b'bazfoo' * 64) d = zstd.train_dictionary(8192, samples) self.assertLessEqual(len(d), 8192) dict_id = zstd.dictionary_id(d) <|user_cursor_is_here|> self.assertIsInstance(dict_id, int) ```
```tests/test_train_dictionary.py import sys import unittest import zstd if sys.version_info[0] >= 3: int_type = int else: int_type = long class TestTrainDictionary(unittest.TestCase): def test_no_args(self): with self.assertRaises(TypeError): zstd.train_dictionary() def test_bad_args(self): with self.assertRaises(TypeError): zstd.train_dictionary(8192, u'foo') with self.assertRaises(ValueError): zstd.train_dictionary(8192, [u'foo']) def test_basic(self): samples = [] for i in range(128): samples.append(b'foo' * 64) samples.append(b'bar' * 64) samples.append(b'foobar' * 64) samples.append(b'baz' * 64) samples.append(b'foobaz' * 64) samples.append(b'bazfoo' * 64) d = zstd.train_dictionary(8192, samples) self.assertLessEqual(len(d), 8192) dict_id = zstd.dictionary_id(d) <|tool_call|> {"name": "refactor.rename", "arguments": {"symbol": "int", "newName": "int_type"}} </|tool_call|> self.assertIsInstance(dict_id, int) ```