Advertisement
happy-barney

context-singleton

Jul 27th, 2023
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. contrive q (Animal)
  2. => class => Animal::
  3. => builder => q (new),
  4. ;
  5.  
  6. my $animal = deduce q (Animal);
  7.  
  8. # in tests (in new frame generally) you can override your singleton
  9. subtest ... => sub {
  10. frame {
  11. # now we can inject different singleton
  12. proclaim q (Animal) => Test::Fixture::Animal->new;
  13.  
  14. ...
  15. };
  16. # and q (Animal) is back
  17. };
  18.  
  19. # Test::YAFT::subtest creates frame for you
  20. Test::YAFT::subtest ... => sub {
  21. proclaim ...;
  22. };
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement