Questions tagged [argument-matching]

Argument matching is the process by which the actual arguments passed to a function are matched to the formal arguments of the function. Languages vary in how they match arguments, from exact-matching only to complicated and flexible rules (such as in R).

Argument matching is the process by which the actual passed to a function are matched to the formal arguments of the function. Languages vary in how they match arguments, from exact-matching only to complicated and flexible rules (such as in ).

16 questions
25
votes
1 answer

Why does R use partial matching?

I know that for a list, partial matching is done when indexing using the basic operators $ and [[. For example: ll <- list(yy=1) ll$y [1] 1 But I am still an R newbie and this is new for me, partial matching of function arguments: h <-…
agstudy
  • 119,832
  • 17
  • 199
  • 261
18
votes
2 answers

Abbreviation of "collapse" in paste?

Using the command paste in R, I wanted to use both arguments sep and collapse, but you cannot abbreviate collapse to coll or even collaps. Yet for other functions partial abbreviation works. For example: paste(letters, colla=", ") # [1] "a , " "b ,…
user1879178
  • 181
  • 2
2
votes
0 answers

Why does Mockito throw up when accessing a mock while verifying another one?

See this example: class Foo { } class Bar { void takeIt(int i, String arg) { System.out.println(arg + i); } } public class Mcve { @Test public void passes() { Foo foo = Mockito.mock(Foo.class); Bar bar =…
GhostCat
  • 137,827
  • 25
  • 176
  • 248
2
votes
1 answer

Python argument matching for f(a, *b)

def f(a,*b): print(a,b) for the function f defined as above, if I call f(1, *(2,3)) it prints 1, (2,3) as expected. However calling f(a=1, *(2,3)) causes an error: TypeError: f() got multiple values for argument 'a' Any positional argument…
Royalblue
  • 639
  • 10
  • 22
2
votes
1 answer

Setup argment matcher with IEnumerable in NSubstitue

I am working on a unit test for a project and I cannot figure out how to get NSubstitute to work the way I would expect it to. The issue I am having is that the code I was to substitute is in a while loop and depending on what is returned from the…
ninja coder
  • 1,067
  • 9
  • 22
1
vote
0 answers

Argument matchers for type parameters when using Mockito

I was trying to find out if I can use something like the any argument matcher for a method with type parameters: when(store.getItems[Product](any[FilterParams])) .thenReturn(allProducts) When running the code with the above snippet, I get…
1
vote
3 answers

ArgumentMatcher for Kotlin

I'm trying to use ArgumentMatcher in my tests. I do next: Mockito.`when`(someRepository.save( argThat { it.name == someName } // Here I want to do mock for all objects with name someName )).thenReturn(save(someEntity)) And I get next…
Valeriy K.
  • 2,616
  • 1
  • 30
  • 53
1
vote
1 answer

How to stub a method by matching an argument by a superclass in NSubstitute?

Referring to the following sample code: using NSubstitute; using NUnit.Framework; public class Class1 { } public class Class2 { public void Method(Class1 class1) { } } public class Class3 : Class1 { } [TestFixture] public class…
Chry Cheng
  • 3,378
  • 5
  • 47
  • 79
1
vote
2 answers

Require exactly one set of multiple arguments in R

I'm in the process of developing a framework in R and would like one of my functions to be multi-purposed. I would like to achieve this by requiring that exactly one set of arguments be passed. In other words, I would like to write a function foo…
Alex Firsov
  • 168
  • 11
1
vote
3 answers

how to pass in multiple ArgumentMatchers to Mockito

I have two custom ArgumentMatchers and I'd like my mock to return a different value based on the argument value. Example: when(myMock.method(new ArgMatcher1()).thenReturn(false); when(myMock.method(new…
Chris Morris
  • 4,335
  • 4
  • 24
  • 28
0
votes
2 answers

C++ concept for argument matching of const/non-const references to specified type on template functions

I want to know if there is a better way to solve the code duplication problem on template functions like this struct Z { void doSomething() { std::cout << "non-const version\n"; } void doSomething() const { std::cout << "const version\n";…
0
votes
1 answer

Using argument matchers when stubbing a method call results in type error

This is my code: class Foo { int bar(int x) => x; } class MockFoo extends Mock implements Foo {} void main() { final foo = MockFoo(); when(foo.bar(any)).thenReturn(42); print(foo.bar(7)); // prints 42 } How come passing in any as an…
Joel Castro
  • 485
  • 6
  • 20
0
votes
1 answer

Is it possible using variables of ArgumentMatchers?

Let's say I have an interface looks like this. interface Some { /** * Does some on specified array with specified index and returns the array. * * @param array the array. * @param index the index. * @returns given…
Jin Kwon
  • 20,295
  • 14
  • 115
  • 184
0
votes
1 answer

Unable to extract features from time series data using 'extract_features' method from tsfresh package

I am running the code in Spyder(3.3.3) from Anaconda3 2019.03(Python 3.7.3 64-bit). And using tsfresh 0.11.1 The code I'm running deals with a huge set of time-series data that has sensor data(data of 17 sensors in 17 different files. (dataset url :…
0
votes
1 answer

Match a func delegate in argument matcher in nsubstitute Received method

I am trying to check if a method is called a specific number of times on a mock instance of a class. The problem is the method has a func delegate and that is not matching. I have the following scenario: public interface ISomeService: IService { …
Sunil Kumar
  • 390
  • 1
  • 7
  • 25
1
2