// Column Math Tests
// =================

@include test-module('Column Math') {

  // Is Symmetrical
  // --------------

  @include test('[function] is-symmetrical()') {
    $sym      : 12;
    $asym     : 1 2 4 1 2 1;
    $single   : (4,);

    // symmetrical
    $sym: is-symmetrical($sym);
    @include assert-true($sym,
      'Number is parsed as symmetrical grid.');

    // asymmetrical
    $asym: is-symmetrical($asym);
    @include assert-false($asym,
      'List is parsed as asymmetrical grid.');

    // single-item list
    $single: is-symmetrical($single);
    @include assert-false($single,
      'Single-item list is parsed as asymmetrical grid.');
  }

  // Susy Count
  // ----------

  @include test('[function] susy-count()') {
    $sym    : 12;
    $asym   : 1 2 4 1 2 1;

    // symmetrical
    $count: susy-count($sym);
    @include assert-equal($count, $sym,
      'Symmetrical grid-count is equal to columns setting.');

    // asymmetrical
    $count: susy-count($asym);
    $length: length($asym);
    @include assert-equal($count, $length,
      'Asymmetrical grid-count is equal to columns list length.');
  }

  // Susy Sum
  // --------

  @include test('[function] susy-sum() — symmetrical') {
    $columns: 9;
    $gutters: .5;

    // default (narrow)
    $sum: susy-sum($columns, $gutters);
    $narrow: 13;
    @include assert-equal($sum, $narrow,
      'Symmetrical sum properly adds columns and gutters.');

    // explicit (narrow)
    $sum: susy-sum($columns, $gutters, narrow);
    $narrow: 13;
    @include assert-equal($sum, $narrow,
      'Narrow sum properly adds columns and gutters.');

    // wide
    $sum: susy-sum($columns, $gutters, wide);
    $wide: $narrow + $gutters;
    @include assert-equal($sum, $wide,
      'Wide sum includes an extra gutter.');

    // wider
    $sum: susy-sum($columns, $gutters, wider);
    $wider: $narrow + ($gutters * 2);
    @include assert-equal($sum, $wider,
      'Wider sum includes two extra gutters.');
  }

  @include test('[function] susy-sum() — asymmetrical') {
    $columns: 1 2 3 1 2;
    $gutters: .25;

    // standard (narrow)
    $sum: susy-sum($columns, $gutters);
    $narrow: 10;
    @include assert-equal($sum, $narrow,
      'Asymmetrical sum properly adds columns and gutters.');

    // wide
    $sum: susy-sum($columns, $gutters, wide);
    $wide: $narrow + $gutters;
    @include assert-equal($sum, $wide,
      'Wide sum includes an extra gutter.');

    // wider
    $sum: susy-sum($columns, $gutters, wider);
    $wider: $narrow + ($gutters * 2);
    @include assert-equal($sum, $wider,
      'Wider sum includes two extra gutters.');
  }

  // Susy Slice
  // ----------

  @include test('[function] susy-slice()') {
    $span: 3;

    // symmetrical
    $context: 12;
    $test: susy-slice($span, 4, $context);
    @include assert-equal($test, $span,
      'Subset is equal to the span.');

    // asymmetrical
    $context: 1 2 3 1 2;
    $test: susy-slice($span, 2, $context);
    $expect: 2 3 1;
    @include assert-equal($test, $expect,
      'Subset is an extracted list of span length, starting at location.');

    // asymmetrical (no location)
    $test: susy-slice($span, null, $context);
    $expect: 1 2 3;
    @include assert-equal($test, $expect,
      'Asymmetrical context without location returns first-position subset.');
  }

  // Susy
  // ----

  @include test('[function] susy()') {
    $span: 3;
    $location: 2;

    // symmetrical
    $columns: 12;
    $gutters: 1/8;
    $test: susy($span, $location, $columns, $gutters);
    $expect: susy-sum($span, $gutters);
    @include assert-equal($test, $expect,
      'Symmetrical column-span-sum is equal to column-sum of span.');

    // asymmetrical
    $columns: 1 2 3 2 1 2 3;
    $gutters: 1/4;
    $test: susy($span, $location, $columns, $gutters);
    $expect: 7.5;
    @include assert-equal($test, $expect,
      'Asymmetrical column-span-sum fetches subset before calculating sum.');
  }

}

