<commit_before>
use v6.c;
use Test;

use Time::Spec::at;
use Time::Spec::at::Grammar;
use Time::Spec::at::Actions;

# set a consistent $now for testing

my $now = DateTime.now;
diag $now;

# helper functions

my sub tpa ($str, :$now = $UNIT::now) {
  Time::Spec::at::Grammar::At.parse(
    $str,
    actions => Time::Spec::at::Actions::AtActions.new(:$now),
  );
}

my sub tpam (|c) { tpa(|c).made; }

# tests

my DateTime $match;
my DateTime $try;

# spec_base

$match = tpam( "now" );
ok $match eqv $now, "now";


$match = tpam( "today" );
$try = $now.Date.DateTime;
ok $match eqv $try, "today";

$match = tpam( "tomorrow" );
$try = $now.Date.later(:1day).DateTime;
ok $match eqv $try, "tomorrow";

$match = tpam( "wed" );
$try = Date.new(2017,6,27).later(:1day).DateTime;
ok $match eqv $try, "wed";
$match = tpam( "mon" );
$try = Date.new(2017,6,27).earlier(:1day).later(:1week).DateTime;
ok $match eqv $try, "mon";

todo "fix next day_name logic";
$match = tpam( "tue" );
$try = Date.new(2017,6,27).DateTime;
ok $match eqv $try, "tue";
# dd $match; dd $try;


$match = tpam( "now + 23 min", now => DateTime.new(1258462020) );
$try = DateTime.new(1258462020).later(:23minute);
# ok $match eqv $try, "120869";
dd $match; dd $try;

done-testing;<commit_msg>enable a test<commit_after>
use v6.c;
use Test;

use Time::Spec::at;
use Time::Spec::at::Grammar;
use Time::Spec::at::Actions;

# set a consistent $now for testing

my $now = DateTime.now;
diag $now;

# helper functions

my sub tpa ($str, :$now = $UNIT::now) {
  Time::Spec::at::Grammar::At.parse(
    $str,
    actions => Time::Spec::at::Actions::AtActions.new(:$now),
  );
}

my sub tpam (|c) { tpa(|c).made; }

# tests

my DateTime $match;
my DateTime $try;

# spec_base

$match = tpam( "now" );
ok $match eqv $now, "now";


$match = tpam( "today" );
$try = $now.Date.DateTime;
ok $match eqv $try, "today";

$match = tpam( "tomorrow" );
$try = $now.Date.later(:1day).DateTime;
ok $match eqv $try, "tomorrow";

$match = tpam( "wed" );
$try = Date.new(2017,6,27).later(:1day).DateTime;
ok $match eqv $try, "wed";
$match = tpam( "mon" );
$try = Date.new(2017,6,27).earlier(:1day).later(:1week).DateTime;
ok $match eqv $try, "mon";

todo "fix next day_name logic";
$match = tpam( "tue" );
$try = Date.new(2017,6,27).DateTime;
ok $match eqv $try, "tue";
# dd $match; dd $try;


$match = tpam( "now + 23 min", now => DateTime.new(1258462020) );
$try = DateTime.new(1258462020).later(:23minute);
ok $match eqv $try, "now + 23 min";
dd $match; dd $try;

done-testing;
{'fraction_non_alphanumeric': 0.21428571428571427, 'fraction_numerical': 0.04285714285714286, 'mean_word_length': 4.639821029082774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '53566', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1053, 'n_words': 269}