search for: test_m

Displaying 17 results from an estimated 17 matches for "test_m".

Did you mean: test_
2019 May 14
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
..."gen") > > .gen.formula <- function(object, ...){ > message("I am the S3method-declared method.") > } > > gen.formula <- function(object, ...){ > message("I am the function with an unfortunate name.") > } > > test_me <- function(){ > message("I am the tester. Which one will I call?") > gen(a~b) > } > > and the following NAMESPACE: > > export(gen) > S3method(gen, formula, .gen.formula) > export(gen.formula) > export(test_me) > > Now, >...
2019 Jun 11
0
Re: [nbdkit PATCH v2] Introduce cacheextents filter
...(i%4)) > + done > + ;; > + pread) dd if=/dev/zero count=\$3 iflag=count_bytes ;; > + can_write) ;; > + pwrite) dd of=/dev/null ;; > + can_trim) ;; > + trim) ;; > + can_zero) ;; > + trim) ;; zero) > + *) exit 2 ;; > +esac > +EOF > + > + > +test_me() { > + num_accesses=$1 > + shift > + > + qemu-io -f raw "$@" "$sockurl" > + test "$(grep -c "^extents request: " $accessfile)" -eq "$num_accesses" > + ret=$? > + rm -f "$accessfile" > + return...
2019 Jun 11
5
[nbdkit PATCH v2] Introduce cacheextents filter
...\$block_size \$((i%4)) >>$accessfile_full + echo \${i}M \$block_size \$((i%4)) + done + ;; + pread) dd if=/dev/zero count=\$3 iflag=count_bytes ;; + can_write) ;; + pwrite) dd of=/dev/null ;; + can_trim) ;; + trim) ;; + can_zero) ;; + trim) ;; + *) exit 2 ;; +esac +EOF + + +test_me() { + num_accesses=$1 + shift + + qemu-io -f raw "$@" "$sockurl" + test "$(grep -c "^extents request: " $accessfile)" -eq "$num_accesses" + ret=$? + rm -f "$accessfile" + return $ret +} + +# First one causes caching,...
2007 Mar 15
1
Howto find out, a function was called
Hello there! I just started with Mocha (great job, by the way), and want to solve a problem, perhaps you can give me a hint. I have a Observer (yes, in Rails), and want to test, that this observer does (or does not) call a special method on the observed object. In this example, the object has a sync-method, that shall be called before_update. The Observer looks like class BlaObserver <
2006 Aug 15
0
Mocha - dynamic method calling
...#39;lookup'').call(''jim'', ''johnson'', ''tx'') > > and have it behave as if I had just called lookup directly. Hmm. You''ve definitely got a point here. I was wondering if you couldn''t do something like this... def test_me phone_book = mock() lookup_method = mock() phone_book.expects(:method).with(''lookup'').returns(lookup_method) lookup_method.expects(:call).with(''jim'', ''johnson'', ''tx'') phone_book.method(''lookup'...
2019 May 14
2
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
...int. > > > library(anRpackage) > > gen(a~b) > I am the S3method-declared method. > > gen.formula <- function(object, ...){message("I am the externally declared method.")} > > gen(a~b) > I am the externally declared method. > > test_me() > I am the tester. Which one will I call? > I am the function with an unfortunate name. > > In that case, I think that the least surprising behaviour would > prioritise declarations and methods "nearer" to the caller over those > "farther" from the cal...
2007 Jun 12
4
advice on new failures with 0.5.0
Hi all, We just updated to the latest version of Mocha and now we''re seeing a lot of odd test failures. If this isn''t the appropriate place for a question like this, please let me know. Say I have code like this in a controller: DataMonitor.toggle_notification! And I mock it like this: DataMonitor.any_instance.stubs(:toggle_notification!) This would work fine with Mocha
2009 Dec 13
2
Reshape a data set
I am trying to reshape a data set. Could someone please help me with the reshape, cast, and melt functions? I am new to R and I have tried reading up on how to use the reshape package, but I am very confused. Here is an example of what I am trying to do: subject coder score time [1,] 1 1 20 5 [2,] 1 2 30 4 [3,] 2 3 10 10 [4,] 2 2
2006 Apr 09
1
curious unpacking issue
...tion for unpacking an initramfs image ontop of the in-kernel image? Currently, I am using kernel 2.6.16.2 with klibc 1.3.2 (1.3.4 failed to build last I tried, so I rolled back). menu.lst is as follows: title TESTING root (hd0,0) kernel /vmlinuz26-EXPERIMENTAL root=/dev/hda3 ro vga=791 initrd /test_me.img Thanks for any pointers... I'll delve into the kernel init code for the "is ramfs" check now. Aaron Griffin
2019 May 14
0
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
...) after > you. That's a good point. > library(anRpackage) > gen(a~b) I am the S3method-declared method. > gen.formula <- function(object, ...){message("I am the externally declared method.")} > gen(a~b) I am the externally declared method. > test_me() I am the tester. Which one will I call? I am the function with an unfortunate name. In that case, I think that the least surprising behaviour would prioritise declarations and methods "nearer" to the caller over those "farther" from the caller (where "caller"...
2019 May 18
0
[R-pkg-devel] Three-argument S3method declaration does not seem to affect dispatching from inside the package.
Hi, Inaki, On Tue, 2019-05-14 at 12:50 +0200, I?aki Ucar wrote: > The thing is that, in R, "nearer" means "the calling environment" > (and then, other things). When you call test_me(), the calling > environment for gen() is the package namespace. When you call gen() > directly, thenthe calling environment is the global environment. So > what happens here follows the principle of least astonishment. I don't think that we disagree about which environment takes pre...
2007 Apr 11
0
Fwd: [ mocha-Bugs-8687 ] Block''s return value is dropped on stubbed yielding methods.
...1 07:03 Message: Hi Erik, Thanks for the bug report & suggested patch. To be honest I can''t see anything wrong with Mocha''s behaviour in the example you''ve given. It''s not obvious what you are trying to test. Can you not do something like this... def test_me foo = mock() bar = mock() bar.stubs(:get_baz).returns(:baz) foo.stubs(:with_something).yields(bar) baz = nil foo.with_something do |bar| baz = bar.get_baz.to_s end assert_equal ''baz'', baz end (see http://pastie.caboo.se/530...
2006 Oct 13
6
If I stub do I have to mock as well?
Hi, I''m new to mocha and stubba but eager to learn. I have a rails functional test in which I would like to stub an instance method of particular class to always return true. I tried the following: def test_post_checkout Order.any_instance.stubs(:successful?).returns(true) post :checkout assert_response :redirect assert_equal "Checkout was successful.",
2007 Aug 21
7
mocking singletons
How can I safely mock a singleton without the mocked method living on outside the scope of the test method? I''ve run into this problem with mocking methods on globals (gasp!) in the past by doing something like def mock_my_global original = $my_global $my_global.expects(:foo).returns(''bar'') yield $my_global = original end Is there something similar I
2006 Oct 06
8
Expecting calls with two different parameters
Hello, I''ve just started using Mocha in the tests for my Rails app, and I''ve run across an issue with mocking a method that should be called with different parameters. How would I setup a mock that expects that a method will be called once with no paramaters, and a second time with a parameter? I''d be tempted to shortcut and just do something like
2007 Nov 13
5
how to ensure signature compliance while mocking in ruby
On 13/11/2007, Pradeep Gatram <pradeep.gatram at gmail.com> wrote: > > Let me put my dilemma as an example. Take a look at a snippet from > FooTest. > > #using mocha > def test_method1 > Bar.expects(:method2).with(''param1'', ''param2'').once > Foo.method1 > end > > And now the implementation > > class Foo > def self.method1 > Bar.method2(''param1'', ''param2'') > end &...
2006 Aug 14
14
A mock which extends rather than replaces a class?
While running tests, we would like to instrument some of the classes under test. We still want the classes to do exactly what they currently do, but we would like them to do more when running in the test environment. Clearly we can (and currently do) just extend the objects "on the fly" where necessary, but this is a bit messy - we''d like some centralised way to always