Advertisement
Guest User

Untitled

a guest
Oct 26th, 2018
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. # In test-comp.p6
  2. use v6.c;
  3. use nqp;
  4. my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix=>'cache'.IO);
  5. my $precomp = CompUnit::PrecompilationRepository::Default.new(store=> $precomp-store );
  6. my $key = nqp::sha1('test.pod6');
  7. 'test.pod6'.IO.spurt(q:to/--END--/);
  8. =begin pod
  9. =TITLE More and more
  10.  
  11. Some text
  12.  
  13. =end pod
  14. --END--
  15. $precomp.precompile('test.pod6'.IO, $key, :force);
  16. my $mod1 = 'test.pod6'.IO.modified;
  17. my $handle = $precomp.load( $key )[0];
  18. my $resurrected = nqp::atkey($handle.unit,'$=pod')[0];
  19. say $resurrected ~~ Pod::Block::Named;
  20. 'test.pod6'.IO.spurt(q:to/--END--/);
  21. =begin pod
  22. =TITLE More and more
  23.  
  24. Some more text added
  25.  
  26. =end pod
  27. --END--
  28. say "modified first: " ~ $mod1;
  29. say "modified next: " ~ 'test.pod6'.IO.modified;
  30. my $new-handle = $precomp.load($key, :since('test.pod6'.IO.modified))[0];
  31. with $new-handle { say 'new-handle exists'} else { say 'no new-handle'};
  32. put $handle;
  33. put $new-handle;
  34.  
  35.  
  36. ### Output is
  37. $ perl6 comp-test.p6
  38. True
  39. modified first: Instant:1540539480.589026
  40. modified next: Instant:1540539480.689027
  41. new-handle exists
  42. CompUnit::Handle<140206592874160>
  43. CompUnit::Handle<140206592874160>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement