text:
goog.module('goog.testing.assertsTest');
goog.setTestOnly();

const Deferred = goog.require('goog.async.Deferred');
const GoogPromise = goog.require('goog.Promise');
const IterIterator = goog.require('goog.iter.Iterator');
const StructsMap = goog.require('goog.structs.Map');
const StructsSet = goog.require('goog.structs.Set');
const TestCase = goog.require('goog.testing.TestCase');
const asserts = goog.require('goog.testing.asserts');
const dom = goog.require('goog.dom');
const googArray = goog.require('goog.array');
const googIter = goog.require('goog.iter');
const product = goog.require('goog.userAgent.product');
const testSuite = goog.require('goog.testing.testSuite');
const throwException = goog.require('goog.async.throwException');

const SUPPORTS_TYPED_ARRAY =
    typeof Uint8Array === 'function' && typeof Uint8Array.of === 'function';

const implicitlyTrue = [true, 1, -1, ' ', 'string', Infinity, new Object()];

const implicitlyFalse = [false, 0, '', null, undefined, NaN];

/**
 * Runs test suite (function) for a `Thenable` implementation covering
 * rejection.
 * @param {boolean} swallowUnhandledRejections
 * @param {function(function(function(?), function(?))): !IThenable<?>} factory
 * @suppress {strictMissingProperties} suppression added to enable type checking
 */
async function internalTestAssertRejects(swallowUnhandledRejections, factory) {
  try {
    // TODO(user): Stop the unhandled rejection handler from firing
    // rather than swallowing the errors.
    if (swallowUnhandledRejections) {
      GoogPromise.setUnhandledRejectionHandler(() => {});
    }

    let e;
    e = await assertRejects(
        'valid IThenable constructor throws Error', factory(() => {
          throw new Error('test0');
        }));
    assertEquals('test0', e.message);

    e = await assertRejects(
        'valid IThenable constructor throws string error', factory(() => {
          throw 'test1';
        }));
    assertEquals('test1', e);

    e = await assertRejects(
        'valid IThenable rejects Error', factory((_, reject) => {
          reject(new Error('test2'));
        }));
    assertEquals('test2', e.message);

    e = await assertRejects(
        'valid IThenable rejects string error', factory((_, reject) => {
          reject('test3');
        }));
    assertEquals('test3', e);

    e = await assertRejects(
        'assertRejects should fail with a resolved thenable', (async () => {
          await assertRejects(factory((resolve) => resolve(undefined)));
          fail('should always throw.');
        })());
    assertEquals(
        'IThenable passed into assertRejects did not reject', e.message);
    // Record this as an expected assertion: go/failonunreportedasserts
    TestCase.invalidateAssertionException(/** @type {?} */ (e));
  } finally {
    // restore the default exception handler.
    GoogPromise.setUnhandledRejectionHandler(throwException);
  }
}

function stringForWindowIEHelper() {
  /**
   * @suppress {strictMissingProperties} suppression added to enable type
   * checking
   */
  window.stringForWindowIEResult = _displayStringForValue(window);
}

testSuite({
  testAssertTrue() {
    assertTrue(true);
    assertTrue('Good assertion', true);
    assertThrowsJsUnitException(() => {
      assertTrue(false);
    }, 'Call to assertTrue(boolean) with false');
    assertThrowsJsUnitException(() => {
      assertTrue('Should be true', false);
    }, 'Should be true\nCall to assertTrue(boolean) with false');
    assertThrowsJsUnitException(() => {
      assertTrue(null);
    }, 'Bad argument to assertTrue(boolean): <null>');
    assertThrowsJsUnitException(() => {
      assertTrue(undefined);
    }, 'Bad argument to assertTrue(boolean): <undefined>');
  },

  testAssertFalse() {
    assertFalse(false);
    assertFalse('Good assertion', false);
    assertThrowsJsUnitException(() => {
      assertFalse(true);
    }, 'Call to assertFalse(boolean) with true');
    assertThrowsJsUnitException(() => {
      assertFalse('Should be false', true);
    }, 'Should be false\nCall to assertFalse(boolean) with true');
    assertThrowsJsUnitException(() => {
      assertFalse(null);
    }, 'Bad argument to assertFalse(boolean): <null>');
    assertThrowsJsUnitException(() => {
      assertFalse(undefined);
    }, 'Bad argument to assertFalse(boolean): <undefined>');
  },

  testAssertEqualsWithString() {
    assertEquals('a', 'a');
    assertEquals('Good assertion', 'a', 'a');
    assertThrowsJsUnitException(() => {
      assertEquals('a', 'b');
    }, 'Expected <a> (String) but was <b> (String)');
    assertThrowsJsUnitException(() => {
      assertEquals('Bad assertion', 'a', 'b');
    }, 'Bad assertion\nExpected <a> (String) but was <b> (String)');
  },

  testAssertEqualsWithInteger() {
    assertEquals(1, 1);
    assertEquals('Good assertion', 1, 1);
    assertThrowsJsUnitException(() => {
      assertEquals(1, 2);
    }, 'Expected <1> (Number) but was <2> (Number)');
    assertThrowsJsUnitException(() => {
      assertEquals('Bad assertion', 1, 2);
    }, 'Bad assertion\nExpected <1> (Number) but was <2> (Number)');
  },

  testAssertNotEquals() {
    assertNotEquals('a', 'b');
    assertNotEquals('a', 'a', 'b');
    assertThrowsJsUnitException(() => {
      assertNotEquals('a', 'a');
    }, 'Expected not to be <a> (String)');
    assertThrowsJsUnitException(() => {
      assertNotEquals('a', 'a', 'a');
    }, 'a\nExpected not to be <a> (String)');
  },

  testAssertNull() {
    assertNull(null);
    assertNull('Good assertion', null);
    assertThrowsJsUnitException(() => {
      assertNull(true);
    }, 'Expected <null> but was <true> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNull('Should be null', false);
    }, 'Should be null\nExpected <null> but was <false> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNull(undefined);
    }, 'Expected <null> but was <undefined>');
    assertThrowsJsUnitException(() => {
      assertNull(1);
    }, 'Expected <null> but was <1> (Number)');
  },

  testAssertNullOrUndefined() {
    assertNullOrUndefined(null);
    assertNullOrUndefined(undefined);
    assertNullOrUndefined('Good assertion', null);
    assertNullOrUndefined('Good assertion', undefined);
    assertThrowsJsUnitException(() => {
      assertNullOrUndefined(true);
    }, 'Expected <null> or <undefined> but was <true> (Boolean)');
    assertThrowsJsUnitException(
        () => {
          assertNullOrUndefined('Should be null', false);
        },
        'Should be null\n' +
            'Expected <null> or <undefined> but was <false> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNullOrUndefined(0);
    }, 'Expected <null> or <undefined> but was <0> (Number)');
  },

  testAssertNotNull() {
    assertNotNull(true);
    assertNotNull('Good assertion', true);
    assertNotNull(false);
    assertNotNull(undefined);
    assertNotNull(1);
    assertNotNull('a');
    assertThrowsJsUnitException(() => {
      assertNotNull(null);
    }, 'Expected not to be <null>');
    assertThrowsJsUnitException(() => {
      assertNotNull('Should not be null', null);
    }, 'Should not be null\nExpected not to be <null>');
  },

  testAssertUndefined() {
    assertUndefined(undefined);
    assertUndefined('Good assertion', undefined);
    assertThrowsJsUnitException(() => {
      assertUndefined(true);
    }, 'Expected <undefined> but was <true> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertUndefined('Should be undefined', false);
    }, 'Should be undefined\nExpected <undefined> but was <false> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertUndefined(null);
    }, 'Expected <undefined> but was <null>');
    assertThrowsJsUnitException(() => {
      assertUndefined(1);
    }, 'Expected <undefined> but was <1> (Number)');
  },

  testAssertNotUndefined() {
    assertNotUndefined(true);
    assertNotUndefined('Good assertion', true);
    assertNotUndefined(false);
    assertNotUndefined(null);
    assertNotUndefined(1);
    assertNotUndefined('a');
    assertThrowsJsUnitException(() => {
      assertNotUndefined(undefined);
    }, 'Expected not to be <undefined>');
    assertThrowsJsUnitException(() => {
      assertNotUndefined('Should not be undefined', undefined);
    }, 'Should not be undefined\nExpected not to be <undefined>');
  },

  testAssertNotNullNorUndefined() {
    assertNotNullNorUndefined(true);
    assertNotNullNorUndefined('Good assertion', true);
    assertNotNullNorUndefined(false);
    assertNotNullNorUndefined(1);
    assertNotNullNorUndefined(0);
    assertNotNullNorUndefined('a');
    assertThrowsJsUnitException(() => {
      assertNotNullNorUndefined(undefined);
    }, 'Expected not to be <undefined>');
    assertThrowsJsUnitException(() => {
      assertNotNullNorUndefined('Should not be undefined', undefined);
    }, 'Should not be undefined\nExpected not to be <undefined>');
    assertThrowsJsUnitException(() => {
      assertNotNullNorUndefined(null);
    }, 'Expected not to be <null>');
    assertThrowsJsUnitException(() => {
      assertNotNullNorUndefined('Should not be null', null);
    }, 'Should not be null\nExpected not to be <null>');
  },

  testAssertNonEmptyString() {
    assertNonEmptyString('hello');
    assertNonEmptyString('Good assertion', 'hello');
    assertNonEmptyString('true');
    assertNonEmptyString('false');
    assertNonEmptyString('1');
    assertNonEmptyString('null');
    assertNonEmptyString('undefined');
    assertNonEmptyString('\n');
    assertNonEmptyString(' ');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString('');
    }, 'Expected non-empty string but was <> (String)');
    assertThrowsJsUnitException(
        () => {
          assertNonEmptyString('Should be non-empty string', '');
        },
        'Should be non-empty string\n' +
            'Expected non-empty string but was <> (String)');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(true);
    }, 'Expected non-empty string but was <true> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(false);
    }, 'Expected non-empty string but was <false> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(1);
    }, 'Expected non-empty string but was <1> (Number)');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(null);
    }, 'Expected non-empty string but was <null>');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(undefined);
    }, 'Expected non-empty string but was <undefined>');
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(['hello']);
    }, 'Expected non-empty string but was <hello> (Array)');
    // Different browsers return different values/types in the failure
    // message so don't bother checking if the message is exactly as
    // expected.
    assertThrowsJsUnitException(() => {
      assertNonEmptyString(dom.createTextNode('hello'));
    });
  },

  testAssertNaN() {
    assertNaN(NaN);
    assertNaN('Good assertion', NaN);
    assertThrowsJsUnitException(() => {
      assertNaN(1);
    }, 'Expected NaN but was <1> (Number)');
    assertThrowsJsUnitException(() => {
      assertNaN('Should be NaN', 1);
    }, 'Should be NaN\nExpected NaN but was <1> (Number)');
    assertThrowsJsUnitException(() => {
      assertNaN(true);
    }, 'Expected NaN but was <true> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNaN(false);
    }, 'Expected NaN but was <false> (Boolean)');
    assertThrowsJsUnitException(() => {
      assertNaN(null);
    }, 'Expected NaN but was <null>');
    assertThrowsJsUnitException(() => {
      assertNaN('');
    }, 'Expected NaN but was <> (String)');

    // TODO(user): These assertions fail. We should decide on the
    // semantics of assertNaN
    // assertThrowsJsUnitException(function() { assertNaN(undefined); },
    //    'Expected NaN');
    // assertThrowsJsUnitException(function() { assertNaN('a'); },
    //    'Expected NaN');
  },

  testAssertNotNaN() {
    assertNotNaN(1);
    assertNotNaN('Good assertion', 1);
    assertNotNaN(true);
    assertNotNaN(false);
    assertNotNaN('');
    assertNotNaN(null);

    // TODO(user): These assertions fail. We should decide on the
    // semantics of assertNotNaN
    // assertNotNaN(undefined);
    // assertNotNaN('a');

    assertThrowsJsUnitException(() => {
      assertNotNaN(Number.NaN);
    }, 'Expected not NaN');
    assertThrowsJsUnitException(() => {
      assertNotNaN('Should not be NaN', Number.NaN);
    }, 'Should not be NaN\nExpected not NaN');
  },

  testAssertObjectEquals() {
    const obj1 = [{'a': 'hello', 'b': 'world'}];
    const obj2 = [{'a': 'hello', 'c': 'dear', 'b': 'world'}];

    // Check with obj1 and obj2 as first and second arguments respectively.
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj1, obj2);
    });

    // Check with obj1 and obj2 as second and first arguments respectively.
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj2, obj1);
    });

    // Test if equal objects are considered equal.
    const obj3 = [{'b': 'world', 'a': 'hello'}];
    assertObjectEquals(obj1, obj3);
    assertObjectEquals(obj3, obj1);

    // Test with a case where one of the members has an undefined value.
    const obj4 = [{'a': 'hello', 'b': undefined}];
    const obj5 = [{'a': 'hello'}];

    // Check with obj4 and obj5 as first and second arguments respectively.
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj4, obj5);
    });

    // Check with obj5 and obj4 as first and second arguments respectively.
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj5, obj4);
    });

    // Check with identical Trusted Types instances.
    if (typeof window.trustedTypes !== 'undefined') {
      const policy = trustedTypes.createPolicy('testAssertObjectEquals', {
        createHTML: (s) => {
          return s;
        }
      });

      const tt1 = policy.createHTML('hello');
      const tt2 = policy.createHTML('hello');
      assertObjectEquals(tt1, tt2);
    }
  },

  testAssertObjectNotEquals() {
    const obj1 = [{'a': 'hello', 'b': 'world'}];
    const obj2 = [{'a': 'hello', 'c': 'dear', 'b': 'world'}];

    // Check with obj1 and obj2 as first and second arguments respectively.
    assertObjectNotEquals(obj1, obj2);

    // Check with obj1 and obj2 as second and first arguments respectively.
    assertObjectNotEquals(obj2, obj1);

    // Test if equal objects are considered equal.
    const obj3 = [{'b': 'world', 'a': 'hello'}];
    let error = assertThrowsJsUnitException(() => {
      assertObjectNotEquals(obj1, obj3);
    });
    assertContains('Objects should not be equal', error.message);
    error = assertThrowsJsUnitException(() => {
      assertObjectNotEquals(obj3, obj1);
    });
    assertContains('Objects should not be equal', error.message);

    // Test with a case where one of the members has an undefined value.
    const obj4 = [{'a': 'hello', 'b': undefined}];
    const obj5 = [{'a': 'hello'}];

    // Check with obj4 and obj5 as first and second arguments respectively.
    assertObjectNotEquals(obj4, obj5);

    // Check with obj5 and obj4 as first and second arguments respectively.
    assertObjectNotEquals(obj5, obj4);

    assertObjectNotEquals(new Map([['a', '1']]), new Map([['b', '1']]));
    assertObjectNotEquals(new Set(['a', 'b']), new Set(['a']));

    if (SUPPORTS_TYPED_ARRAY) {
      assertObjectNotEquals(
          new Uint32Array([1, 2, 3]), new Uint32Array([1, 4, 3]));
    }

    // Check with different Trusted Types instances.
    if (typeof window.trustedTypes !== 'undefined') {
      const policy = trustedTypes.createPolicy('testAssertObjectNotEquals', {
        createHTML: (s) => {
          return s;
        }
      });

      const tt1 = policy.createHTML('hello');
      const tt2 = policy.createHTML('world');
      assertObjectNotEquals(tt1, tt2);
    }
  },

  testAssertObjectEquals2() {
    // NOTE: (0 in [undefined]) is true on FF but false on IE.
    // (0 in {'0': undefined}) is true on both.
    // grrr.
    assertObjectEquals('arrays should be equal', [undefined], [undefined]);
    assertThrowsJsUnitException(() => {
      assertObjectEquals([undefined, undefined], [undefined]);
    });
    assertThrowsJsUnitException(() => {
      assertObjectEquals([undefined], [undefined, undefined]);
    });
  },

  testAssertObjectEquals3() {
    // Check that objects that contain identical Map objects compare
    // as equals. We can't do a negative test because on browsers that
    // implement __iterator__ we can't check the values of the iterated
    // properties.
    const obj1 = [
      {'a': 'hi', 'b': new StructsMap('hola', 'amigo', 'como', 'estas?')},
      14,
      'yes',
      true,
    ];
    const obj2 = [
      {'a': 'hi', 'b': new StructsMap('hola', 'amigo', 'como', 'estas?')},
      14,
      'yes',
      true,
    ];
    assertObjectEquals('Objects should be equal', obj1, obj2);

    const obj3 = {'a': [1, 2]};
    const obj4 = {'a': [1, 2, 3]};
    // inner arrays should not be equal
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj3, obj4);
    });
    // inner arrays should not be equal
    assertThrowsJsUnitException(() => {
      assertObjectEquals(obj4, obj3);
    });
  },

  testAssertObjectEqualsSet() {
    // verify that Sets compare equal, when run in an environment that
    // supports iterators
    const set1 = new StructsSet();
    const set2 = new StructsSet();

    set1.add('a');
    set1.add('b');
    set1.add(13);

    set2.add('a');
    set2.add('b');
    set2.add(13);

    assertObjectEquals('sets should be equal', set1, set2);

    set2.add('hey');
    assertThrowsJsUnitException(() => {
      assertObjectEquals(set1, set2);
    });
  },

  testAssertObjectEqualsMap() {
    class FooClass {}

    const map1 = new Map([
      ['foo', 'bar'],
      [1, 2],
      [FooClass, 'bar'],
    ]);
    const map2 = new Map([
      ['foo', 'bar'],
      [1, 2],
      [FooClass, 'bar'],
    ]);

    assertObjectEquals('maps should be equal', map1, map2);

    map1.set('hi', 'hey');
    assertThrowsJsUnitException(() => {
      assertObjectEquals(map1, map2);
    });
  },

  testAssertObjectEqualsTypedArrays() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11

    assertObjectEquals(
        'Float32Arrays should be equal', Float32Array.of(1, 2, 3),
        Float32Array.of(1, 2, 3));
    assertObjectEquals(
        'Float64Arrays should be equal', Float64Array.of(1, 2, 3),
        Float64Array.of(1, 2, 3));
    assertObjectEquals(
        'Int8Arrays should be equal', Int8Array.of(1, 2, 3),
        Int8Array.of(1, 2, 3));
    assertObjectEquals(
        'Int16Arrays should be equal', Int16Array.of(1, 2, 3),
        Int16Array.of(1, 2, 3));
    assertObjectEquals(
        'Int32Arrays should be equal', Int32Array.of(1, 2, 3),
        Int32Array.of(1, 2, 3));
    assertObjectEquals(
        'Uint8Arrays should be equal', Uint8Array.of(1, 2, 3),
        Uint8Array.of(1, 2, 3));
    assertObjectEquals(
        'Uint8ClampedArrays should be equal', Uint8ClampedArray.of(1, 2, 3),
        Uint8ClampedArray.of(1, 2, 3));
    assertObjectEquals(
        'Uint16Arrays should be equal', Uint16Array.of(1, 2, 3),
        Uint16Array.of(1, 2, 3));
    assertObjectEquals(
        'Uint32Arrays should be equal', Uint32Array.of(1, 2, 3),
        Uint32Array.of(1, 2, 3));

    assertThrowsJsUnitException(() => {
      assertObjectNotEquals(Uint8Array.of(1, 2), Uint8Array.of(1, 2));
    });
  },

  testAssertObjectEqualsTypedArrayDifferentBacking() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11

    const buf1 = new ArrayBuffer(3 * Uint16Array.BYTES_PER_ELEMENT);
    const buf2 = new ArrayBuffer(4 * Uint16Array.BYTES_PER_ELEMENT);
    const arr1 = new Uint16Array(buf1, 0, 3);
    const arr2 = new Uint16Array(buf2, Uint16Array.BYTES_PER_ELEMENT, 3);
    for (let i = 0; i < arr1.length; ++i) {
      arr1[i] = arr2[i] = i * 2 + 1;
    }
    assertObjectEquals(
        'TypedArrays with different backing buffer lengths should be equal',
        Uint16Array.of(1, 3, 5), Uint16Array.of(0, 1, 3, 5, 7).subarray(1, 4));
  },

  testAssertObjectEqualsArrayBufferContents() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11
    assertObjectEquals(
        'Same ArrayBuffer contents should be equal',
        Uint16Array.of(1, 2, 3).buffer, Uint16Array.of(1, 2, 3).buffer);
  },

  testAssertObjectNotEqualsMutatedTypedArray() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11

    const arr1 = Int8Array.of(2, -5, 7);
    const arr2 = Int8Array.from(arr1);
    assertObjectEquals('TypedArrays should be equal', arr1, arr2);
    ++arr1[1];
    assertObjectNotEquals('Mutated TypedArray should not be equal', arr1, arr2);
  },

  testAssertObjectNotEqualsDifferentTypedArrays() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11

    assertObjectNotEquals(
        'Float32Array and Float64Array should not be equal',
        Float32Array.of(1, 2, 3), Float64Array.of(1, 2, 3));
    assertObjectNotEquals(
        'Float32Array and Int32Array should not be equal',
        Float32Array.of(1, 2, 3), Int32Array.of(1, 2, 3));
    assertObjectNotEquals(
        'Int8Array and Int16Array should not be equal', Int8Array.of(1, 2, 3),
        Int16Array.of(1, 2, 3));
    assertObjectNotEquals(
        'Int16Array and Uint16Array should not be equal',
        Int16Array.of(1, 2, 3), Uint16Array.of(1, 2, 3));
    assertObjectNotEquals(
        'Int32Array and Uint8Array should not be equal', Int8Array.of(1, 2, 3),
        Uint8Array.of(1, 2, 3));
    assertObjectNotEquals(
        'Uint8Array and Uint8ClampedArray should not be equal',
        Uint8Array.of(1, 2, 3), Uint8ClampedArray.of(1, 2, 3));

    assertThrowsJsUnitException(() => {
      assertObjectEquals(Uint8Array.of(1, 2), Uint16Array.of(1, 2));
    });
  },

  testAssertObjectBigIntTypedArrays() {
    if (typeof BigInt64Array !== 'function')
      return;  // not supported pre-ES2020

    // Check equality.
    assertObjectEquals(
        'BigInt64Arrays should be equal',
        BigInt64Array.of(BigInt(1), BigInt(2), BigInt(3)),
        BigInt64Array.of(BigInt(1), BigInt(2), BigInt(3)));
    assertObjectEquals(
        'BigUint64Arrays should be equal',
        BigUint64Array.of(BigInt(1), BigInt(2), BigInt(3)),
        BigUint64Array.of(BigInt(1), BigInt(2), BigInt(3)));

    // Check mutation.
    const arr1 = BigInt64Array.of(BigInt(2), BigInt(-5), BigInt(7));
    /** @suppress {checkTypes} suppression added to enable type checking */
    const arr2 = BigInt64Array.from(arr1);
    assertObjectEquals('BigInt64Arrays should be equal', arr1, arr2);
    ++arr1[1];
    assertObjectNotEquals(
        'Mutated BigInt64Array should not be equal', arr1, arr2);

    // Check different types are not equal.
    assertObjectNotEquals(
        'BigInt64Array and BigUint64Array should not equal',
        BigInt64Array.of(BigInt(1), BigInt(2), BigInt(3)),
        BigUint64Array.of(BigInt(1), BigInt(2), BigInt(3)));
  },

  testAssertObjectNotEqualsTypedArrayContents() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11
    assertObjectNotEquals(
        'Different Uint16Array contents should not equal',
        Uint16Array.of(1, 2, 3), Uint16Array.of(1, 3, 2));
    assertObjectNotEquals(
        'Different Float32Array contents should not equal',
        Float32Array.of(1.2, 2.4, 3.8), Float32Array.of(1.2, 2.3, 3.8));

    assertThrowsJsUnitException(() => {
      assertObjectEquals(Uint8Array.of(1, 2), Uint8Array.of(3, 2));
    });
  },

  testAssertObjectNotEqualsArrayBufferContents() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11
    assertObjectNotEquals(
        'Different ArrayBuffer contents should not equal',
        Uint16Array.of(1, 3, 2).buffer, Uint16Array.of(1, 2, 3).buffer);
    assertObjectNotEquals(
        'Different ArrayBuffer contents should not equal',
        Uint16Array.of(1, 2, 3, 4).buffer, Uint16Array.of(1, 2, 3).buffer);
  },

  testAssertObjectNotEqualsTypedArrayOneExtra() {
    if (!SUPPORTS_TYPED_ARRAY) return;  // not supported in IE<11
    assertObjectNotEquals(
        'Uint8ClampedArray with extra element should not equal',
        Uint8ClampedArray.of(1, 2, 3), Uint8ClampedArray.of(1, 2, 3, 4));
    assertObjectNotEquals(
        'Float32Array with extra element should not equal',
        Float32Array.of(1, 2, 3), Float32Array.of(1, 2, 3, 4));
  },

  testAssertObjectEqualsIterNoEquals() {
    // an object with an iterator but no equals() and no map_ cannot
    // be compared
    /** @constructor @struct */
    function Thing() {
      this.what = [];
    }
    Thing.prototype.add = function(n, v) {
      this.what.push(`${n}@${v}`);
    };
    Thing.prototype.get = function(n) {
      const m = new RegExp(
          `^${n}` +
              '@(.*)$',
          '');
      for (let i = 0; i < this.what.length; ++i) {
        const match = this.what[i].match(m);
        if (match) {
          return match[1];
        }
      }
      return null;
    };
    Thing.prototype.__iterator__ = function() {
      const iter = new IterIterator;
      /**
       * @suppress {strictMissingProperties} suppression added to enable
       * type checking
       */
      iter.index = 0;
      /**
       * @suppress {strictMissingProperties} suppression added to enable
       * type checking
       */
      iter.thing = this;
      /**
       * @return {!IIterableResult<string>}
       * @override
       */
      iter.next = function() {
        if (this.index < this.thing.what.length) {
          return googIter.createEs6IteratorYield(
              this.thing.what[this.index++].split('@')[0]);
        } else {
          return googIter.ES6_ITERATOR_DONE;
        }
      };

      return iter;
    };

    const thing1 = new Thing();
    /** @suppress {checkTypes} suppression added to enable type checking */
    thing1.name = 'thing1';
    const thing2 = new Thing();
    /** @suppress {checkTypes} suppression added to enable type checking */
    thing2.name = 'thing2';
    thing1.add('red', 'fish');
    thing1.add('blue', 'fish');

    thing2.add('red', 'fish');
    thing2.add('blue', 'fish');

    assertThrowsJsUnitException(() => {
      assertObjectEquals(thing1, thing2);
    });
  },

  testAssertObjectEqualsWithDates() {
    const date = new Date(2010, 0, 1);
    const dateWithMilliseconds = new Date(2010, 0, 1, 0, 0, 0, 1);
    assertObjectEquals(new Date(2010, 0, 1), date);
    assertThrowsJsUnitException(
        goog.partial(assertObjectEquals, date, dateWithMilliseconds));
  },

  testAssertObjectEqualsWithCustomComparatorErrorMessage() {
    class A {}

    asserts.registerComparator(
        A.prototype, (a, b, cmp) => 'pretty error message');
    let exception = assertThrowsJsUnitException(() => {
      assertObjectEquals(new A(), new A());
    });
    assertEquals('pretty error message', exception.message);
    exception = assertThrowsJsUnitException(() => {
      assertObjectEquals({a: new A()}, {a: new A()});
    });
    assertContains('a: pretty error message', exception.message);
  },

  testAssertObjectEqualsSparseArrays() {
    const arr1 = [, 2, , 4];
    const arr2 = [1, 2, 3, 4, 5];

    // Sparse arrays should not be equal
    assertThrowsJsUnitException(() => {
      assertObjectEquals(arr1, arr2);
    });

    // Sparse arrays should not be equal
    assertThrowsJsUnitException(() => {
      assertObjectEquals(arr2, arr1);
    });

    let a1 = [];
    let a2 = [];
    a2[1.8] = undefined;
    // Empty slots only equal `undefined` for natural-number array keys`
    assertThrowsJsUnitException(() => {
      assertObjectEquals(a1, a2);
    });

    a1 = [];
    a2 = [];
    a2[-999] = undefined;
    // Empty slots only equal `undefined` for natural-number array keys`
    assertThrowsJsUnitException(() => {
      assertObjectEquals(a1, a2);
    });
  },

  testAssertObjectEqualsSparseArrays2() {
    // On IE6-8, the expression "1 in [4,undefined]" evaluates to false,
    // but true on other browsers. FML. This test verifies a regression
    // where IE reported that arr4 was not equal to arr1 or arr2.
    const arr1 = [1, , 3];
    const arr2 = [1, undefined, 3];
    const arr3 = googArray.clone(arr1);
    const arr4 = [];
    arr4.push(1, undefined, 3);

    // Assert that all those arrays are equivalent pairwise.
    const arrays = [arr1, arr2, arr3, arr4];
    for (let i = 0; i < arrays.length; i++) {
      for (let j = 0; j < arrays.length; j++) {
        assertArrayEquals(arrays[i], arrays[j]);
      }
    }
  },

  testAssertObjectEqualsNestedPropertyMessage() {
    assertThrowsJsUnitException(() => {
      assertObjectEquals(
          {a: 'abc', b: 4, array: [1, 2, 3, {nested: [2, 3, 4]}]},
          {a: 'bcd', b: '4', array: [1, 5, 3, {nested: [2, 3, 4, 5]}]});
    }, `Expected <[object Object]> (Object) but was <[object Object]> (Object)
   a: Expected <abc> (String) but was <bcd> (String)
   b: Expected <4> (Number) but was <4> (String)
   array[1]: Expected <2> (Number) but was <5> (Number)
   array[3].nested: Expected 3-element array but got a 4-element array`);
  },

  testAssertObjectEqualsRootDifference() {
    assertThrowsJsUnitException(() => {
      assertObjectEquals([1], [1, 2]);
    }, `Expected <1> (Array) but was <1,2> (Array)
   Expected 1-element array but got a 2-element array`);

    assertThrowsJsUnitException(() => {
      assertObjectEquals('a', 'b');
    }, 'Expected <a> (String) but was <b> (String)');

    assertThrowsJsUnitException(() => {
      assertObjectEquals([], {});
    }, 'Expected <> (Array) but was <[object Object]> (Object)');
  },

  testAssertObjectEqualsArraysWithExtraProps() {
    const arr1 = [1];
    const arr2 = [1];
    /**
     * @suppress {strictMissingProperties} suppression added to enable type
     * checking
     */
    arr2.foo = 3;

    assertThrowsJsUnitException(() => {
      assertObjectEquals(arr1, arr2);
    });

    assertThrowsJsUnitException(() => {
      assertObjectEquals(arr2, arr1);
    });
  },

  testAssertSameElementsOnArray() {
    assertSameElements([1, 2], [2, 1]);
    assertSameElements('Good assertion', [1, 2], [2, 1]);
    assertSameElements('Good assertion with duplicates', [1, 1, 2], [2, 1, 1]);
    assertThrowsJsUnitException(() => {
      assertSameElements([1, 2], [1]);
    }, 'Expected 2 elements: [1,2], got 1 elements: [1]');
    assertThrowsJsUnitException(() => {
      assertSameElements('Should match', [1, 2], [1]);
    }, 'Should match\nExpected 2 elements: [1,2], got 1 elements: [1]');
    assertThrowsJsUnitException(() => {
      assertSameElements([1, 2], [1, 3]);
    }, 'Expected [1,2], got [1,3]');
    assertThrowsJsUnitException(() => {
      assertSameElements('Should match', [1, 2], [1, 3]);
    }, 'Should match\nExpected [1,2], got [1,3]');
    assertThrowsJsUnitException(() => {
      assertSameElements([1, 1, 2], [2, 2, 1]);
    }, 'Expected [1,1,2], got [2,2,1]');
  },

  testAssertSameElementsOnArrayLike() {
    assertSameElements({0: 0, 1: 1, length: 2}, {length: 2, 1: 1, 0: 0});
    assertThrowsJsUnitException(() => {
      assertSameElements({0: 0, 1: 1, length: 2}, {0: 0, length: 1});
    }, 'Expected 2 elements: [0,1], got 1 elements: [0]');
  },

  testAssertSameElementsOnStructsSet() {
    assertSameElements({0: 0, 1: 1, length: 2}, new StructsSet([0, 1]));
    assertThrowsJsUnitException(() => {
      assertSameElements({0: 0, 1: 1, length: 2}, new StructsSet([0]));
    }, 'Expected 2 elements: [0,1], got 1 elements: [0]');
  },

  testAssertSameElementsWithBadArguments() {
    const ex = assertThrowsJsUnitException(
        /** @suppress {checkTypes} */
        () => {
          assertSameElements([], new StructsMap());
        });
    assertContains('actual', ex.toString());
    assertContains('array-like or iterable', ex.toString());
  },

  testAssertSameElementsWithIterables() {
    const s = new Set([1, 2, 3]);
    assertSameElements({0: 3, 1: 2, 2: 1, length: 3}, s);
    assertSameElements(s, {0: 3, 1: 2, 2: 1, length: 3});
    assertSameElements([], new Set());
    assertSameElements(new Set(), []);

    assertThrowsJsUnitException(
        () => assertSameElements([1, 1], new Set([1, 1])));
    assertThrowsJsUnitException(
        () => assertSameElements(new Set([1, 1]), [1, 1]));

    assertThrowsJsUnitException(
        () => assertSameElements([1, 3], new Set([1, 2])));
    assertThrowsJsUnitException(
        () => assertSameElements(new Set([1, 2]), [1, 3]));
  },

  testAssertEvaluatesToTrue() {
    assertEvaluatesToTrue(true);
    assertEvaluatesToTrue('', true);
    assertEvaluatesToTrue('Good assertion', true);
    assertThrowsJsUnitException(() => {
      assertEvaluatesToTrue(false);
    }, 'Expected to evaluate to true');
    assertThrowsJsUnitException(() => {
      assertEvaluatesToTrue('Should be true', false);
    }, 'Should be true\nExpected to evaluate to true');
    for (let i = 0; i < implicitlyTrue.length; i++) {
      assertEvaluatesToTrue(
          String('Test ' + implicitlyTrue[i] + ' [' + i + ']'),
          implicitlyTrue[i]);
    }
    for (let i = 0; i < implicitlyFalse.length; i++) {
      assertThrowsJsUnitException(() => {
        assertEvaluatesToTrue(implicitlyFalse[i]);
      }, 'Expected to evaluate to true');
    }
  },

  testAssertEvaluatesToFalse() {
    assertEvaluatesToFalse(false);
    assertEvaluatesToFalse('Good assertion', false);
    assertThrowsJsUnitException(() => {
      assertEvaluatesToFalse(true);
    }, 'Expected to evaluate to false');
    assertThrowsJsUnitException(() => {
      assertEvaluatesToFalse('Should be false', true);
    }, 'Should be false\nExpected to evaluate to false');
    for (let i = 0; i < implicitlyFalse.length; i++) {
      assertEvaluatesToFalse(
          String('Test ' + implicitlyFalse[i] + ' [' + i + ']'),
          implicitlyFalse[i]);
    }
    for (let i = 0; i < implicitlyTrue.length; i++) {
      assertThrowsJsUnitException(() => {
        assertEvaluatesToFalse(implicitlyTrue[i]);
      }, 'Expected to evaluate to false');
    }
  },

  testAssertHTMLEquals() {
    // TODO
  },

  testAssertHashEquals() {
    assertHashEquals({a: 1, b: 2}, {b: 2, a: 1});
    assertHashEquals('Good assertion', {a: 1, b: 2}, {b: 2, a: 1});
    assertHashEquals({a: undefined}, {a: undefined});
    // Missing key.
    assertThrowsJsUnitException(() => {
      assertHashEquals({a: 1, b: 2}, {a: 1});
    }, 'Expected hash had key b that was not found');
    assertThrowsJsUnitException(() => {
      assertHashEquals('Should match', {a: 1, b: 2}, {a: 1});
    }, 'Should match\nExpected hash had key b that was not found');
    assertThrowsJsUnitException(() => {
      assertHashEquals({a: undefined}, {});
    }, 'Expected hash had key a that was not found');
    // Not equal key.
    assertThrowsJsUnitException(() => {
      assertHashEquals({a: 1}, {a: 5});
    }, 'Value for key a mismatch - expected = 1, actual = 5');
    assertThrowsJsUnitException(() => {
      assertHashEquals('Should match', {a: 1}, {a: 5});
    }, 'Should match\nValue for key a mismatch - expected = 1, actual = 5');
    assertThrowsJsUnitException(() => {
      assertHashEquals({a: undefined}, {a: 1});
    }, 'Value for key a mismatch - expected = undefined, actual = 1');
    // Extra key.
    assertThrowsJsUnitException(() => {
      assertHashEquals({a: 1}, {a: 1, b: 1});
    }, 'Actual hash had key b that was not expected');
    assertThrowsJsUnitException(() => {
      assertHashEquals('Should match', {a: 1}, {a: 1, b: 1});
    }, 'Should match\nActual hash had key b that was not expected');
  },

  testAssertRoughlyEquals() {
    assertRoughlyEquals(1, 1, 0);
    assertRoughlyEquals('Good assertion', 1, 1, 0);
    assertRoughlyEquals(1, 1.1, 0.11);
    assertRoughlyEquals(1.1, 1, 0.11);
    assertThrowsJsUnitException(() => {
      assertRoughlyEquals(1, 1.1, 0.05);
    }, 'Expected 1, but got 1.1 which was more than 0.05 away');
    assertThrowsJsUnitException(() => {
      assertRoughlyEquals('Close enough', 1, 1.1, 0.05);
    }, 'Close enough\nExpected 1, but got 1.1 which was more than 0.05 away');
  },

  testAssertContainsForArrays() {
    assertContains(1, [1, 2, 3]);
    assertContains('Should contain', 1, [1, 2, 3]);
    assertThrowsJsUnitException(() => {
      assertContains(4, [1, 2, 3]);
    }, 'Expected \'1,2,3\' to contain \'4\'');
    assertThrowsJsUnitException(() => {
      assertContains('Should contain', 4, [1, 2, 3]);
    }, 'Should contain\nExpected \'1,2,3\' to contain \'4\'');
    // assertContains uses ===.
    const o = new Object();
    assertContains(o, [o, 2, 3]);
    assertThrowsJsUnitException(() => {
      assertContains(o, [1, 2, 3]);
    }, 'Expected \'1,2,3\' to contain \'[object Object]\'');
  },

  testAssertNotContainsForArrays() {
    assertNotContains(4, [1, 2, 3]);
    assertNotContains('Should not contain', 4, [1, 2, 3]);
    assertThrowsJsUnitException(() => {
      assertNotContains(1, [1, 2, 3]);
    }, 'Expected \'1,2,3\' not to contain \'1\'');
    assertThrowsJsUnitException(() => {
      assertNotContains('Should not contain', 1, [1, 2, 3]);
    }, 'Should not contain\nExpected \'1,2,3\' not to contain \'1\'');
    // assertNotContains uses ===.
    const o = new Object();
    assertNotContains({}, [o, 2, 3]);
    assertThrowsJsUnitException(() => {
      assertNotContains(o, [o, 2, 3]);
    }, 'Expected \'[object Object],2,3\' not to contain \'[object Object]\'');
  },

  testAssertContainsForStrings() {
    assertContains('ignored msg', 'abc', 'zabcd');
    assertContains('abc', 'abc');
    assertContains('', 'abc');
    assertContains('', '');
    assertThrowsJsUnitException(() => {
      assertContains('msg', 'abc', 'bcd');
    }, 'msg\nExpected \'bcd\' to contain \'abc\'');
    assertThrowsJsUnitException(() => {
      assertContains('a', '');
    }, 'Expected \'\' to contain \'a\'');
  },

  testAssertNotContainsForStrings() {
    assertNotContains('ignored msg', 'abc', 'bcd');
    assertNotContains('a', '');
    assertThrowsJsUnitException(() => {
      assertNotContains('msg', 'abc', 'zabcd');
    }, 'msg\nExpected \'zabcd\' not to contain \'abc\'');
    assertThrowsJsUnitException(() => {
      assertNotContains('abc', 'abc');
    }, 'Expected \'abc\' not to contain \'abc\'');
    assertThrowsJsUnitException(() => {
      assertNotContains('', 'abc');
    }, 'Expected \'abc\' not to contain \'\'');
  },

  /**
   * Tests `assertContains` and 'assertNotContains` with an arbitrary type
   * that has a custom `indexOf`.
   */
  testAssertContainsAndAssertNotContainsOnCustomObjectWithIndexof() {
    const valueContained = {toString: () => 'I am in'};
    const valueNotContained = {toString: () => 'I am out'};
    const container = {
      indexOf: (value) => value === valueContained ? 1234 : -1,
      toString: () => 'I am a container',
    };
    assertContains('ignored message', valueContained, container);
    assertNotContains('ignored message', valueNotContained, container);
    assertThrowsJsUnitException(() => {
      assertContains('msg', valueNotContained, container);
    }, 'msg\nExpected \'I am a container\' to contain \'I am out\'');
    assertThrowsJsUnitException(() => {
      assertNotContains('msg', valueContained, container);
    }, 'msg\nExpected \'I am a container\' not to contain \'I am in\'');
  },

  testAssertRegExp() {
    const a = 'I like turtles';
    assertRegExp(/turtles$/, a);
    assertRegExp('turtles$', a);
    assertRegExp('Expected subject to be about turtles', /turtles$/, a);
    assertRegExp('Expected subject to be about turtles', 'turtles$', a);

    const b = 'Hello';
    assertThrowsJsUnitException(() => {
      assertRegExp(/turtles$/, b);
    }, 'Expected \'Hello\' to match RegExp /turtles$/');
    assertThrowsJsUnitException(() => {
      assertRegExp('turtles$', b);
    }, 'Expected \'Hello\' to match RegExp /turtles$/');
  },

  testAssertThrows() {
    assertThrowsJsUnitException(() => {
      assertThrows(
          'assertThrows should not pass with null param',
          /** @type {?} */ (null));
    });

    assertThrowsJsUnitException(() => {
      assertThrows(
          'assertThrows should not pass with undefined param',
          /** @type {?} */ (undefined));
    });

    assertThrowsJsUnitException(() => {
      assertThrows(
          'assertThrows should not pass with number param',
          /** @type {?} */ (1));
    });

    assertThrowsJsUnitException(() => {
      assertThrows(
          'assertThrows should not pass with string param',
          /** @type {?} */ ('string'));
    });

    assertThrowsJsUnitException(() => {
      assertThrows(
          'assertThrows should not pass with object param',
          /** @type {?} */ ({}));
    });

    let error;
    try {
      error = assertThrows('valid function throws Error', () => {
        throw new Error('test');
      });
    } catch (e) {
      fail('assertThrows incorrectly doesn\'t detect a thrown exception');
    }
    assertEquals('error message', 'test', error.message);

    let stringError;
    try {
      stringError = assertThrows('valid function throws string error', () => {
        throw 'string error test';
      });
    } catch (e) {
      fail('assertThrows doesn\'t detect a thrown string exception');
    }
    assertEquals('string error', 'string error test', stringError);
  },

  testAssertThrowsThrowsIfJsUnitException() {
    // Asserts that assertThrows will throw a JsUnitException if the method
    // passed to assertThrows throws a JsUnitException of its own.
    // assertThrows should not be used for catching JsUnitExceptions.
    const e = assertThrowsJsUnitException(() => {
      assertThrows(() => {
        // We need to invalidate this exception so it's not flagged as a
        // legitimate failure by the test framework. The only way to get at
        // the exception thrown by assertTrue is to catch it so we can
        // invalidate it. We then need to rethrow it so the surrounding
        // assertThrows behaves as expected.
        try {
          assertTrue(false);
        } catch (ex) {
          TestCase.getActiveTestCase().invalidateAssertionException(ex);
          throw ex;
        }
      });
    });
    assertContains(
        'Function passed to assertThrows caught a JsUnitException', e.message);
  },

  testAssertThrowsJsUnitException() {
    let error = assertThrowsJsUnitException(() => {
      assertTrue(false);
    });
    assertEquals('Call to assertTrue(boolean) with false', error.message);

    error = assertThrowsJsUnitException(() => {
      assertThrowsJsUnitException(() => {
        throw new Error('fail');
      });
    });
    assertEquals(
        'Call to fail()\nExpected a JsUnitException, ' +
            'got \'Error: fail\' instead',
        error.message);

    error = assertThrowsJsUnitException(() => {
      assertThrowsJsUnitException(() => {});
    });
    assertEquals('Expected a failure', error.message);
  },

  testAssertNotThrows() {
    if (product.SAFARI) {
      // TODO(user): Disabled so we can get the rest of the Closure
      // test suite running in a continuous build. Will investigate later.
      return;
    }

    assertThrowsJsUnitException(() => {
      assertNotThrows(
          'assertNotThrows should not pass with null param',
          /** @type {?} */ (null));
    });

    assertThrowsJsUnitException(() => {
      assertNotThrows(
          'assertNotThrows should not pass with undefined param',
          /** @type {?} */ (undefined));
    });

    assertThrowsJsUnitException(() => {
      assertNotThrows(
          'assertNotThrows should not pass with number param',
          /** @type {?} */ (1));
    });

    assertThrowsJsUnitException(() => {
      assertNotThrows(
          'assertNotThrows should not pass with string param',
          /** @type {?} */ ('string'));
    });

    assertThrowsJsUnitException(() => {
      assertNotThrows(
          'assertNotThrows should not pass with object param',
          /** @type {?} */ ({}));
    });

    let result;
    try {
      result = assertNotThrows('valid function', () => 'some value');
    } catch (e) {
      // Shouldn't be here: throw exception.
      fail('assertNotThrows returned failure on a valid function');
    }
    assertEquals(
        'assertNotThrows should return the result of the function.',
        'some value', result);

    assertThrowsJsUnitException(() => {
      assertNotThrows('non valid error throwing function', () => {
        throw new Error('a test error exception');
      });
    });
  },

  async testAssertRejects_nonThenables() {
    assertThrowsJsUnitException(() => {
      assertRejects(
          'assertRejects should not pass with null param',
          /** @type {?} */ (null));
    });

    assertThrowsJsUnitException(() => {
      assertRejects(
          'assertRejects should not pass with undefined param',
          /** @type {?} */ (undefined));
    });

    assertThrowsJsUnitException(() => {
      assertRejects(
          'assertRejects should not pass with number param',
          /** @type {?} */ (1));
    });

    assertThrowsJsUnitException(() => {
      assertRejects(
          'assertRejects should not pass with string param',
          /** @type {?} */ ('string'));
    });

    assertThrowsJsUnitException(() => {
      assertRejects(
          'assertRejects should not pass with object param with no then property',
          /** @type {?} */ ({}));
    });
  },

  testAssertRejects_deferred() {
    return internalTestAssertRejects(true, (fn) => {
      const d = new Deferred();
      try {
        fn((val) => d.callback(), (err) => d.errback(err));
      } catch (e) {
        d.errback(e);
      }
      return d;
    });
  },

  testAssertRejects_googPromise() {
    return internalTestAssertRejects(true, (fn) => new GoogPromise(fn));
  },

  testAssertRejects_promise() {
    return internalTestAssertRejects(false, (fn) => new Promise(fn));
  },

  testAssertRejects_asyncFunction_awaitingGoogPromise() {
    return internalTestAssertRejects(true, async (fn) => {
      await new GoogPromise(fn);
    });
  },

  testAssertRejects_asyncFunction_awaitingPromise() {
    return internalTestAssertRejects(false, async (fn) => {
      await new Promise(fn);
    });
  },

  testAssertRejects_asyncFunction_thatThrows() {
    return internalTestAssertRejects(false, async (fn) => {
      fn(() => {}, (err) => {
        throw err;
      });
    });
  },

  testAssertArrayEquals() {
    let a1 = [0, 1, 2];
    let a2 = [0, 1, 2];
    assertArrayEquals('Arrays should be equal', a1, a2);

    // Should have thrown because args are not arrays
    assertThrowsJsUnitException(() => {
      assertArrayEquals(true, true);
    });

    a1 = [0, undefined, 2];
    a2 = [0, , 2];
    // The following test fails unexpectedly. The bug is tracked at
    // http://code.google.com/p/closure-library/issues/detail?id=419
    // assertThrows(
    //     'assertArrayEquals distinguishes undefined items from sparse
    //     arrays', function() {
    //       assertArrayEquals(a1, a2);
    //     });

    // For the record. This behavior will probably change in the future.
    assertArrayEquals(
        'Bug: sparse arrays and undefined items are not distinguished',
        [0, undefined, 2], [0, , 2]);

    // The array elements should be compared with ===
    assertThrowsJsUnitException(() => {
      assertArrayEquals([0], ['0']);
    });

    // Arrays with different length should be different
    assertThrowsJsUnitException(() => {
      assertArrayEquals([0, undefined], [0]);
    });

    a1 = [0];
    a2 = [0];
    a2[-1] = -1;
    assertArrayEquals('Negative indexes are ignored', a1, a2);

    a1 = [0];
    a2 = [0];
    a2[/** @type {?} */ ('extra')] = 1;
    assertArrayEquals(
        'Extra properties are ignored. Use assertObjectEquals to compare them.',
        a1, a2);

    assertArrayEquals(
        'An example where assertObjectEquals would fail in IE.', ['x'],
        'x'.match(/x/g));
  },

  testAssertObjectsEqualsDifferentArrays() {
    // Should throw because args are different
    assertThrowsJsUnitException(() => {
      const a1 = ['className1'];
      const a2 = ['className2'];
      assertObjectEquals(a1, a2);
    });
  },

  testAssertObjectsEqualsNegativeArrayIndexes() {
    const a2 = [0];
    a2[-1] = -1;
    // The following test fails unexpectedly. The bug is tracked at
    // http://code.google.com/p/closure-library/issues/detail?id=418
    // assertThrows('assertObjectEquals compares negative indexes',
    // function() {
    //   assertObjectEquals(a1, a2);
    // });
  },

  testAssertObjectsEqualsDifferentTypeSameToString() {
    assertThrowsJsUnitException(() => {
      const a1 = 'className1';
      const a2 = ['className1'];
      assertObjectEquals(a1, a2);
    });

    assertThrowsJsUnitException(() => {
      const a1 = ['className1'];
      const a2 = {'0': 'className1'};
      assertObjectEquals(a1, a2);
    });

    assertThrowsJsUnitException(() => {
      const a1 = ['className1'];
      const a2 = [['className1']];
      assertObjectEquals(a1, a2);
    });
  },

  testAssertObjectsRoughlyEquals() {
    assertObjectRoughlyEquals({'a': 1}, {'a': 1.2}, 0.3);
    assertThrowsJsUnitException(
        () => {
          assertObjectRoughlyEquals({'a': 1}, {'a': 1.2}, 0.1);
        },
        'Expected <[object Object]> (Object) but was <[object Object]> ' +
            '(Object)\n   a: Expected <1> (Number) but was <1.2> (Number) which ' +
            'was more than 0.1 away');
  },

  testAssertObjectRoughlyEqualsWithStrings() {
    // Check that objects with string properties are compared properly.
    const obj1 = {'description': [{'colName': 'x1'}]};
    const obj2 = {'description': [{'colName': 'x2'}]};
    assertThrowsJsUnitException(
        () => {
          assertObjectRoughlyEquals(obj1, obj2, 0.00001);
        },
        'Expected <[object Object]> (Object)' +
            ' but was <[object Object]> (Object)' +
            '\n   description[0].colName: Expected <x1> (String) but was <x2> (String)');
    assertThrowsJsUnitException(() => {
      assertObjectRoughlyEquals('x1', 'x2', 0.00001);
    }, 'Expected <x1> (String) but was <x2> (String)');
  },

  testFindDifferences_equal() {
    assertNull(asserts.findDifferences(true, true));
    assertNull(asserts.findDifferences(null, null));
    assertNull(asserts.findDifferences(undefined, undefined));
    assertNull(asserts.findDifferences(1, 1));
    assertNull(asserts.findDifferences([1, 'a'], [1, 'a']));
    assertNull(asserts.findDifferences([[1, 2], [3, 4]], [[1, 2], [3, 4]]));
    assertNull(asserts.findDifferences([{a: 1, b: 2}], [{b: 2, a: 1}]));
    assertNull(asserts.findDifferences(null, null));
    assertNull(asserts.findDifferences(undefined, undefined));
    assertNull(asserts.findDifferences(
        new Map([['a', 1], ['b', 2]]), new Map([['b', 2], ['a', 1]])));
    assertNull(
        asserts.findDifferences(new Set(['a', 'b']), new Set(['b', 'a'])));
  },

  testFindDifferences_customNoOpPredicate_equal() {
    const findDifferences = (a, b) => asserts.findDifferences(
        a, b, () => asserts.EQUALITY_PREDICATE_CANT_PROCESS);
    assertNull(findDifferences(true, true));
    assertNull(findDifferences(null, null));
    assertNull(findDifferences(undefined, undefined));
    assertNull(findDifferences(1, 1));
    assertNull(findDifferences([1, 'a'], [1, 'a']));
    assertNull(findDifferences([[1, 2], [3, 4]], [[1, 2], [3, 4]]));
    assertNull(findDifferences([{a: 1, b: 2}], [{b: 2, a: 1}]));
    assertNull(findDifferences(null, null));
    assertNull(findDifferences(undefined, undefined));
    assertNull(findDifferences(
        new Map([['a', 1], ['b', 2]]), new Map([['b', 2], ['a', 1]])));
    assertNull(findDifferences(new Set(['a', 'b']), new Set(['b', 'a'])));
  },

  testFindDifferences_unequal() {
    assertNotNull(asserts.findDifferences(true, false));
    assertNotNull(asserts.findDifferences([{a: 1, b: 2}], [{a: 2, b: 1}]));
    assertNotNull(asserts.findDifferences([{a: 1}], [{a: 1, b: [2]}]));
    assertNotNull(asserts.findDifferences([{a: 1, b: [2]}], [{a: 1}]));

    assertNotNull(
        'Second map is missing key "a"; first map is missing key "b"',
        asserts.findDifferences(new Map([['a', 1]]), new Map([['b', 2]])));
    assertNotNull(
        'Value for key "a" differs by value',
        asserts.findDifferences(new Map([['a', '1']]), new Map([['a', '2']])));
    assertNotNull(
        'Value for key "a" differs by type',
        asserts.findDifferences(new Map([['a', '1']]), new Map([['a', 1]])));

    assertNotNull(
        'Second set is missing key "a"',
        asserts.findDifferences(new Set(['a', 'b']), new Set(['b'])));
    assertNotNull(
        'First set is missing key "b"',
        asserts.findDifferences(new Set(['a']), new Set(['a', 'b'])));
    assertNotNull(
        'Values have different types"',
        asserts.findDifferences(new Set(['1']), new Set([1])));
  },

  testFindDifferences_customNoOpPredicate_unequal() {
    const findDifferences = (a, b) => asserts.findDifferences(
        a, b, () => asserts.EQUALITY_PREDICATE_CANT_PROCESS);
    assertNotNull(findDifferences(true, false));
    assertNotNull(findDifferences([{a: 1, b: 2}], [{a: 2, b: 1}]));
    assertNotNull(findDifferences([{a: 1}], [{a: 1, b: [2]}]));
    assertNotNull(findDifferences([{a: 1, b: [2]}], [{a: 1}]));

    assertNotNull(
        'Second map is missing key "a"; first map is missing key "b"',
        findDifferences(new Map([['a', 1]]), new Map([['b', 2]])));
    assertNotNull(
        'Value for key "a" differs by value',
        findDifferences(new Map([['a', '1']]), new Map([['a', '2']])));
    assertNotNull(
        'Value for key "a" differs by type',
        findDifferences(new Map([['a', '1']]), new Map([['a', 1]])));

    assertNotNull(
        'Second set is missing key "a"',
        findDifferences(new Set(['a', 'b']), new Set(['b'])));
    assertNotNull(
        'First set is missing key "b"',
        findDifferences(new Set(['a']), new Set(['a', 'b'])));
    assertNotNull(
        'Values have different types"',
        findDifferences(new Set(['1']), new Set([1])));
  },

  testFindDifferences_arrays_nonNaturalKeys_notConfsuedForSparseness() {
    let actual;
    let expected;

    actual = [];
    actual[1.8] = undefined;
    expected = [];
    assertNotNull(asserts.findDifferences(actual, expected));

    actual = [];
    actual[-1] = undefined;
    expected = [];
    assertNotNull(asserts.findDifferences(actual, expected));
  },

  testFindDifferences_objectsAndNull() {
    assertNotNull(asserts.findDifferences({a: 1}, null));
    assertNotNull(asserts.findDifferences(null, {a: 1}));
    assertNotNull(asserts.findDifferences(null, []));
    assertNotNull(asserts.findDifferences([], null));
    assertNotNull(asserts.findDifferences([], undefined));
  },

  testFindDifferences_basicCycle() {
    const a = {};
    const b = {};
    a.self = a;
    b.self = b;
    assertNull(asserts.findDifferences(a, b));

    a.unique = 1;
    assertNotNull(asserts.findDifferences(a, b));
  },

  testFindDifferences_crossedCycle() {
    const a = {};
    const b = {};
    a.self = b;
    b.self = a;
    assertNull(asserts.findDifferences(a, b));

    a.unique = 1;
    assertNotNull(asserts.findDifferences(a, b));
  },

  testFindDifferences_asymmetricCycle() {
    const a = {};
    const b = {};
    const c = {};
    const d = {};
    const e = {};
    a.self = b;
    b.self = a;
    c.self = d;
    d.self = e;
    e.self = c;
    assertNotNull(asserts.findDifferences(a, c));
  },

  testFindDifferences_basicCycleArray() {
    const a = [];
    const b = [];
    a[0] = a;
    b[0] = b;
    assertNull(asserts.findDifferences(a, b));

    a[1] = 1;
    assertNotNull(asserts.findDifferences(a, b));
  },

  testFindDifferences_crossedCycleArray() {
    const a = [];
    const b = [];
    a[0] = b;
    b[0] = a;
    assertNull(asserts.findDifferences(a, b));

    a[1] = 1;
    assertNotNull(asserts.findDifferences(a, b));
  },

  testFindDifferences_asymmetricCycleArray() {
    const a = [];
    const b = [];
    const c = [];
    const d = [];
    const e = [];
    a[0] = b;
    b[0] = a;
    c[0] = d;
    d[0] = e;
    e[0] = c;
    assertNotNull(asserts.findDifferences(a, c));
  },

  testFindDifferences_multiCycles() {
    const a = {};
    a.cycle1 = a;
    a.test = {cycle2: a};

    const b = {};
    b.cycle1 = b;
    b.test = {cycle2: b};
    assertNull(asserts.findDifferences(a, b));
  },

  testFindDifferences_binaryTree() {
    function createBinTree(depth, root) {
      if (depth == 0) {
        return {root: root};
      } else {
        const node = {};
        node.left = createBinTree(depth - 1, root || node);
        node.right = createBinTree(depth - 1, root || node);
        return node;
      }
    }

    // TODO(gboyer,user): This test does not terminate with the current
    // algorithm. Can be enabled when (if) the algorithm is improved.
    // assertNull(goog.testing.asserts.findDifferences(
    //    createBinTree(5, null), createBinTree(5, null)));
    assertNotNull(asserts.findDifferences(
        createBinTree(4, null), createBinTree(5, null)));
  },

  testFindDifferences_customEquality() {
    const A = class {};
    const B = class extends A {};
    const C = class extends A {};
    const D = class extends C {};

    // Asserts that the result of findDifferences on a and b results in the
    // given failure. Because findDifferences will not output the actual failure
    // message for root types, we have to parse the failure message for types
    // with paths.
    const assertFindDifferencesFailure = (a, b, failure) => assertEquals(
        failure,
        asserts.findDifferences([a], [b])
            .split('\n')[1]  // There will be one failure, on the 0th element.
            .split(':')[1]   // We want the message on the RHS of the index.
            .substring(1)    // Skip the leading space.
    );

    // Test registration of one comparator. All subtypes of A should use this
    // comparator.
    const aDifferences = 'hello';
    asserts.registerComparator(A.prototype, (a, b, cmp) => aDifferences);
    assertFindDifferencesFailure(new A(), new A(), aDifferences);
    assertFindDifferencesFailure(new B(), new C(), aDifferences);
    assertFindDifferencesFailure(new C(), new B(), aDifferences);
    assertFindDifferencesFailure(new C(), new A(), aDifferences);

    // Test registration of two comparators on subtypes. We should only use
    // the comparator for B if _both_ arguments are B.
    const bDifferences = 'goodbye';
    asserts.registerComparator(B.prototype, (a, b, cmp) => bDifferences);
    assertFindDifferencesFailure(new A(), new A(), aDifferences);
    assertFindDifferencesFailure(new B(), new C(), aDifferences);
    assertFindDifferencesFailure(new C(), new B(), aDifferences);
    assertFindDifferencesFailure(new B(), new B(), bDifferences);

    // Test registration of comparators on disjoint types. We should use the
    // comparator for C on its subclass D, and use A otherwise.
    const cDifferences = 'hello again';
    asserts.registerComparator(C.prototype, (a, b, cmp) => cDifferences);
    assertFindDifferencesFailure(new C(), new D(), cDifferences);
    assertFindDifferencesFailure(new B(), new D(), aDifferences);
    assertFindDifferencesFailure(new A(), new D(), aDifferences);

    // Test that we can clear out these comparators correctly. Note that if
    // a test above fails, we can end up with some prototypes still in our
    // global registration list, but because the classes are anonymous, they
    // cannot break other code.
    asserts.clearCustomComparator(B.prototype);
    asserts.clearCustomComparator(C.prototype);
    assertFindDifferencesFailure(new C(), new D(), aDifferences);
    asserts.clearCustomComparator(A.prototype);
  },

  testStringSamePrefix() {
    assertThrowsJsUnitException(
        () => {
          assertEquals('abcdefghi', 'abcdefghx');
        },
        'Expected <abcdefghi> (String) but was <abcdefghx> (String)\n' +
            'Difference was at position 8. Expected [...ghi] vs. actual [...ghx]');
  },

  testStringSameSuffix() {
    assertThrowsJsUnitException(
        () => {
          assertEquals('xbcdefghi', 'abcdefghi');
        },
        'Expected <xbcdefghi> (String) but was <abcdefghi> (String)\n' +
            'Difference was at position 0. Expected [xbc...] vs. actual [abc...]');
  },

  testStringLongComparedValues() {
    assertThrowsJsUnitException(
        () => {
          assertEquals(
              'abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz',
              'abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz');
        },
        'Expected\n' +
            '<abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz> (String)\n' +
            'but was\n' +
            '<abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz> (String)\n' +
            'Difference was at position 40. Expected [...kkklmnopqrstuvwxyz] vs. actual [...kklmnopqrstuvwxyz]');
  },

  testStringLongDiff() {
    assertThrowsJsUnitException(
        () => {
          assertEquals(
              'abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz',
              'abc...xyz');
        },
        'Expected\n' +
            '<abcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxyz> (String)\n' +
            'but was\n' +
            '<abc...xyz> (String)\n' +
            'Difference was at position 3. Expected\n' +
            '[...bcdefghijkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkklmnopqrstuvwxy...]\n' +
            'vs. actual\n' +
            '[...bc...xy...]');
  },

  testStringDissimilarShort() {
    assertThrowsJsUnitException(() => {
      assertEquals('x', 'y');
    }, 'Expected <x> (String) but was <y> (String)');
  },

  testStringDissimilarLong() {
    assertThrowsJsUnitException(() => {
      assertEquals('xxxxxxxxxx', 'yyyyyyyyyy');
    }, 'Expected <xxxxxxxxxx> (String) but was <yyyyyyyyyy> (String)');
  },

  testAssertElementsEquals() {
    assertElementsEquals([1, 2], [1, 2]);
    assertElementsEquals([1, 2], {0: 1, 1: 2, length: 2});
    assertElementsEquals('Good assertion', [1, 2], [1, 2]);
    assertThrowsJsUnitException(
        () => {
          assertElementsEquals('Message', [1, 2], [1]);
        },
        'length mismatch: Message\n' +
            'Expected <2> (Number) but was <1> (Number)');
  },

  testDisplayStringForValue() {
    assertEquals('<hello> (String)', _displayStringForValue('hello'));
    assertEquals('<1> (Number)', _displayStringForValue(1));
    assertEquals('<null>', _displayStringForValue(null));
    assertEquals('<undefined>', _displayStringForValue(undefined));
    assertEquals('<hello,,,,1> (Array)', _displayStringForValue([
                   'hello', /* array hole */, undefined, null, 1
                 ]));
  },

  testDisplayStringForValue_exception() {
    assertEquals(
        '<toString failed: foo message> (Object)', _displayStringForValue({
          toString: function() {
            throw new Error('foo message');
          },
        }));
  },

  testDisplayStringForValue_cycle() {
    const cycle = ['cycle'];
    cycle.push(cycle);
    assertTrue(
        'Computing string should terminate and result in a reasonable length',
        _displayStringForValue(cycle).length < 1000);
  },

  testToArrayForIterable() {
    const s = new Set([3]);
    /** @suppress {visibility} suppression added to enable type checking */
    const arr = asserts.toArray_(s);
    assertEquals(3, arr[0]);
  },
});


text:
package com.microsoft.azure.management.compute.v2017_12_01;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * Defines values for ComponentNames.
 */
public enum ComponentNames {
    /** Enum value Microsoft-Windows-Shell-Setup. */
    MICROSOFT_WINDOWS_SHELL_SETUP("Microsoft-Windows-Shell-Setup");

    /** The actual serialized value for a ComponentNames instance. */
    private String value;

    ComponentNames(String value) {
        this.value = value;
    }

    /**
     * Parses a serialized value to a ComponentNames instance.
     *
     * @param value the serialized value to parse.
     * @return the parsed ComponentNames object, or null if unable to parse.
     */
    @JsonCreator
    public static ComponentNames fromString(String value) {
        ComponentNames[] items = ComponentNames.values();
        for (ComponentNames item : items) {
            if (item.toString().equalsIgnoreCase(value)) {
                return item;
            }
        }
        return null;
    }

    @JsonValue
    @Override
    public String toString() {
        return this.value;
    }
}

redpajama_set_name: RedPajamaGithub


text:
var express = require('express');
var router = express.Router();
var resource = require('../resource.js');

// Render listing
router.get('/', function(req, res) {
	resource.getResourceList(res)
});

// Render form for new entry
router.get('/new', function(req, res) {
    res.render('newresource', {title: 'New Resource'})
});

// Process new entry
router.post('/', function(req,res){
    resource.insertResource({ name: req.body.name, counter: req.body.counter }, res, function () {resource.getResourceList(res)});
});

// Delete entry
router.post('/delete', function(req, res) {
    resource.deleteResource(req.body.resourceid, res, function () {
        res.redirect('/resources')
    });
});

// Render edit form
router.get('/edit', function(req, res) {
    resource.editResource(req.query.resourceid, res);
});

// Process edit form
router.post('/edit', function(req,res){
    resource.updateResource({ _id: req.body.resourceid}, {name: req.body.name, counter: req.body.counter }, res, function () {res.redirect('/resources')});
});

// Export router
module.exports = router;


text:
class ChangeFieldsFromStreamReviews < ActiveRecord::Migration
    def self.up
    	add_column :stream_reviews, :author_id, :integer
    	add_column :stream_reviews, :text_diff, :text
    end

    def self.down
      drop_table :stream_reviews
    end
end


text:
""" Simulation-based analysis of the specificity of statistical tests

The p-values of statistical tests of association should be distributed
uniformly over the [0, 1] interval whenever no effect is simulated,
which is the case in this script.

However, when the noise covariance matrix has some latent structure,
for some tests the control can be biased, resulting into a uniform p-values
distribution.

Author: Bertrand Thirion, Fabian Pedregosa, 2015.
"""
import matplotlib.pyplot as plt

import numpy as np
from sklearn import preprocessing, linear_model

from scipy.stats import spearmanr, percentileofscore
from sklearn import preprocessing, linear_model
from utils import load_data, square_pdist

do_save = False
n_iter = 1000
# perform a permutation test and return the p-value.
# This will be repeated n_iter times to find the distributed of p-values.
# the seed is given as argument to make sure that
# the data for the different runs is indeed different
# (something that is not obvious otherwise because of multiprocessing)

n_samples, n_features, n_draws = 24, 200, 1000
model = 'monotonous'
heteroscedastic=True

def compute_pval_rsa(seed):
    stim, voxels = load_data(n_samples, n_features, model=model, seed=seed,
                             heteroscedastic=heteroscedastic)

    # compute similarity
    stim_ = stim
    if stim.shape[1] == 1:
        stim_ = np.hstack((stim, - stim))

    stim_similarity = square_pdist(stim_)  # np.corrcoef(stim_)
    voxels_similarity = square_pdist(voxels)  # np.corrcoef(voxels)

    # indices to extract lower triangular part of a matrix
    lw_idx = np.triu_indices(n_samples, k=1)

    stim_vsim = stim_similarity[lw_idx]
    voxels_vsim = voxels_similarity[lw_idx]

    # compute the statistic
    # T = np.corrcoef(stim_vsim, voxels_vsim)[0, 1]
    T = spearmanr(voxels_vsim, stim_vsim)[0]
    T_perm = []
    for i in range(n_draws):
        # permute the labels
        perm = np.random.permutation(n_samples)
        # voxels_vsim_perm = np.corrcoef(voxels[perm])[lw_idx]
        voxels_vsim_perm = square_pdist(voxels[perm])[lw_idx]
        # compute the test statistic
        # T_perm.append(np.corrcoef(voxels_vsim_perm, stim_vsim)[0, 1])
        T_perm.append(spearmanr(voxels_vsim_perm, stim_vsim)[0])

    pval = 1 - percentileofscore(np.array(T_perm), T) / 100.
    return pval

def compute_pval_ls(seed):
    np.random.seed(seed)
    stim, voxels = load_data(n_samples, n_features, model=model, seed=seed,
                             heteroscedastic=heteroscedastic)

    clf = linear_model.LinearRegression()
    pred = clf.fit(stim, voxels).predict(stim)
    T = np.linalg.norm(pred - voxels, 'fro')
    T_perm = []
    for _ in range(n_draws):
        # permute the labels
        perm = np.random.permutation(n_samples)
        stim_perm = stim[perm]
        pred_perm = clf.fit(stim_perm, voxels).predict(stim_perm)
        # compute the test statistic
        T_i = np.linalg.norm(pred_perm - voxels, 'fro')
        T_perm.append(T_i)
    pval = percentileofscore(T_perm, T) / 100.
    return pval

# compute permuted p-values in parallel
from joblib import Parallel, delayed
all_pval_rsa = Parallel(n_jobs=2)(delayed(compute_pval_rsa)(seed)
                                  for seed in range(n_iter))
np.save('pval_rsa.npy', all_pval_rsa)

# compute permuted p-values in parallel
all_pval_ls = Parallel(n_jobs=2)(delayed(compute_pval_ls)(seed)
                                 for seed in range(n_iter))
np.save('pval_ls.npy', all_pval_ls)

bins = 20
ref = n_iter / bins
plt.figure(figsize=(6, 2))
plt.subplot(121)
all_pval_rsa = np.load('pval_rsa.npy')
plt.title('Distribution of p-values for RSA')
plt.hist(all_pval_rsa, bins=bins, color='g')
plt.plot([0, 1], [ref, ref], 'r', linewidth=2)
plt.subplot(122)
all_pval_ls = np.load('pval_ls.npy')
plt.title('Distribution of p-values for LS')
plt.hist(all_pval_ls, bins=bins, color='g')
plt.plot([0, 1], [ref, ref], 'r', linewidth=2)
if do_save:
    plt.savefig('rsa_specificity_hetero.png')

plt.show()


text:
'use strict';

module.exports = {
  normalizeEntityName: function() {
    // this prevents an error when the entityName is
    // not specified (since that doesn't actually matter
    // to us
  },

  afterInstall: function() {
    return this.addBowerPackageToProject('ember-i18n');
  }
};


text:
package kikaha.mustache;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.experimental.Accessors;

@Getter
@Setter
@Accessors( fluent = true )
@NoArgsConstructor
public class MustacheTemplate {

	@NonNull
	String templateName;

	@NonNull
	Object paramObject;
}


text:
"use strict";

const HTMLElementImpl = require("./HTMLElement-impl").implementation;

class HTMLFontElementImpl extends HTMLElementImpl { }

module.exports = {
  implementation: HTMLFontElementImpl
};


text:
using Genus.Migrator.Model.Internal;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Genus.Migrator.Model.Builder
{
    public class TableBuilder:DbObjectBuider<TableBuilder>
    {
        private readonly Lazy<SortedDictionary<string,FieldBuilder>> _fields
            = new Lazy<SortedDictionary<string, FieldBuilder>>();
        private readonly Lazy<SortedDictionary<string,IndexBuilder>> _indexes
            = new Lazy<SortedDictionary<string, IndexBuilder>>();
        private readonly Lazy<SortedDictionary<Tuple<string,string,string>, AssociationBuilder>> _associations
            = new Lazy<SortedDictionary<Tuple<string, string, string>, AssociationBuilder>>();

        public TableBuilder()
        {
        }

        protected PrimaryKeyBuilder PrimaryKey { get; set; }

        protected Dictionary<ProviderName, string> WithDict { get; } = new Dictionary<ProviderName, string>();

        public PrimaryKeyBuilder HasKey(params string[] fields)
        {

            PrimaryKey = new PrimaryKeyBuilder(this, fields);
            return PrimaryKey;
        }

        public PrimaryKeyBuilder HasKey(params FieldBuilder[] fb)
        {
            PrimaryKey = new PrimaryKeyBuilder(fb);
            return PrimaryKey;
        }

        public TableBuilder Fields(params Action<TableBuilder>[] setupActions)
        {
            if (setupActions == null || setupActions.Length == 0)
                throw new ArgumentException("Fields is empty");
            foreach (var setupAction in setupActions)
            {
                setupAction(this);
            }
            return this;
        }

        internal FieldBuilder FindField(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentException("Name is empty");
            FieldBuilder builder;
            if (_fields.IsValueCreated && _fields.Value.TryGetValue(name, out builder))
                return builder;
            return null;
        }

        public FieldBuilder Field(string name, DbType? dbType=null, int? length=null)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentException("Name is empty");
            FieldBuilder builder = FindField(name);
            if (builder == null)
            {
                builder = new FieldBuilder(this);
                _fields.Value.Add(name, builder);
            }
            if (dbType.HasValue)
                builder.HasType(dbType.Value, length ?? -1);
            return builder;
        }

        public IndexBuilder Index(string name)
        {
            return IndexImplement(name, () => new IndexBuilder());
        }

        protected IndexBuilder IndexImplement(string name, Func<IndexBuilder> builderFactory)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentException("Name is empty");
            IndexBuilder builder;
            if (_indexes.IsValueCreated && _indexes.Value.TryGetValue(name, out builder))
                return builder;
            builder = builderFactory();
            _indexes.Value.Add(name, builder);
            return builder;
        }

        protected override void Validate(string clrName)
        {
            base.Validate(clrName);
            if (_fields.IsValueCreated == false)
                throw new InvalidOperationException($"Need fields for table {clrName}");
            foreach (var fieldBuilder in _fields.Value.Values)
            {
                fieldBuilder.Validate();
            }
        }

        public AssociationBuilder Association(string foreignKey, string principalTable, string principalKey)
            =>AssociationImplement(foreignKey, principalTable, principalKey, ()=>new AssociationBuilder());

        protected AssociationBuilder AssociationImplement(
            string foreignKey,
            string principalTable,
            string principalKey,
            Func<AssociationBuilder> builderFactory)
        {
            if (string.IsNullOrWhiteSpace(foreignKey))
                throw new ArgumentException("Need foreign key field name.");
            if (string.IsNullOrWhiteSpace(principalTable))
                throw new ArgumentException("Need refeference table name.");
            var key = new Tuple<string, string, string>(foreignKey, principalTable, principalKey);
            AssociationBuilder buider;
            if (_associations.IsValueCreated && _associations.Value.TryGetValue(key, out buider))
                return buider;
            buider = builderFactory();
            _associations.Value.Add(key, buider);
            return buider;
        }

        public TableBuilder With(ProviderName provider, string value)
        {
            if (WithDict.ContainsKey(provider))
                WithDict[provider] = value;
            else
                WithDict.Add(provider, value);
            return this;
        }

        internal ITable Build(string name, IModel model)
        {
            Validate(name);
            var table = new Table(name, model);
            if (string.IsNullOrWhiteSpace(Name)==false)
                table.DbName = Name;

            if (string.IsNullOrWhiteSpace(Schema) == false)
                table.Schema = Schema;

            var builder2field = _fields.Value.ToDictionary(_ => _.Value, _ => _.Value.Build(_.Key, table));
            table.Fields = builder2field.Values;

            if(PrimaryKey!=null)
                table.PrimaryKey = PrimaryKey.Build(table, fb => builder2field[fb]);

            table.With = new ReadOnlyDictionary<ProviderName, string>(WithDict);

            table.Indexes = _indexes.IsValueCreated
                ? _indexes.Value.Select(_ => _.Value.Build(_.Key, table)).ToArray()
                : Enumerable.Empty<IIndex>();
            return table;
        }

        internal void BuildAssociations(ITable itable, IModel model)
        {
            var table = itable as Table;
            if (table != null && _associations.IsValueCreated)
            {
                var associationsList = new List<IAssociation>(_associations.Value.Count);
                foreach (var item in _associations.Value)
                {
                    var fkField = itable.FindField(item.Key.Item1);
                    if (fkField == null)
                        throw new InvalidOperationException($"Field {item.Key.Item1} not found in table {itable.ClrName}");
                    var principalTable = model.FindTable(item.Key.Item2);
                    if (principalTable == null)
                        throw new InvalidOperationException($"Table {item.Key.Item2} not found");
                    IField principalKey;
                    if (string.IsNullOrWhiteSpace(item.Key.Item3))
                    {
                        if (principalTable.PrimaryKey == null || principalTable.PrimaryKey.Items.Any() == false)
                            throw new InvalidOperationException($"Primary key for table {principalTable.ClrName} not found");
                        if (principalTable.PrimaryKey.Items.Count() > 1)
                            throw new NotSupportedException($"{principalTable.ClrName}. Composite primary keys not supported");
                        principalKey = principalTable.PrimaryKey.Items.Single();
                    }
                    else {
                        principalKey = principalTable.FindField(item.Key.Item3);
                        if (principalKey == null)
                            throw new InvalidOperationException($"Field {principalKey} not found in table {principalTable.ClrName}");
                    }
                    var association = item.Value.Build(fkField, principalKey);
                    associationsList.Add(association);
                }
                table.Associations = new ReadOnlyCollection<IAssociation>(associationsList);
            }
            else
                table.Associations = Enumerable.Empty<IAssociation>();
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using HR_Department.Models.Tables;
using OG_MFTG.Models.DTO;

namespace OG_MFTG.DataLayer.Interfaces
{
    public interface IDailyTimeRecordRepository
    {
        Task<IEnumerable<DailyTimeRecord>> SelectAll();
        Task<DailyTimeRecord> SelectById(int? id);
        Task<int> Insert(DailyTimeRecord model);
        Task Delete(int? id);
        Task Update(DailyTimeRecord model);
        Task<DailyTimeRecord> SelectByEmployeeId(int? id);
        Task<int?> SelectByEmployeeNumber(string number);
        Task<IEnumerable<DailyTimeRecord>> SelectEmplyeeIdDateCreated(int? id, DateTime startDate, DateTime endDate);
        Task<Notification> GetEmplopyeeNotification(int? employeeId, int? timeCategoryId);
        Task<IEnumerable<DailyTimeDetails>> GetDailyTimeRecordTopFive(int? employeeId);
    }
}


text:
case $language in
	pt-br) echo -e "$green update $fcolor - Faz um Update" ;;
	*) echo -e "$green update $fcolor - Is an Update" ;;
esac


text:
package com.github.changeworld.redis.client.lettuce;

import com.github.changeworld.redis.client.BaseClient;
import com.lambdaworks.redis.RedisClient;
import com.lambdaworks.redis.RedisConnection;
/*
 * Spring Data Redis 1.x supports only the lettuce Version 3.x branch.
 * Without Spring Data Redis 1.x, you can use lettuce Version 4.x branch.
 * The following works only with Version 4.x.
import com.lambdaworks.redis.api.StatefulRedisConnection;
import com.lambdaworks.redis.api.sync.RedisStringCommands;
 */
import java.io.IOException;

/**
 * @author changeworld
 */

public class Client implements BaseClient {
    private RedisClient redisClient;
    private RedisConnection connection;

    public Client(RedisClient redisClient) {
        this.redisClient = redisClient;
        this.connection = getRedisClient().connect();
    }

    public RedisClient getRedisClient() {
        return this.redisClient;
    }

    public RedisConnection<String, String> getConnection() {
        return this.connection;
    }

    public void set(String key, String value) throws IOException {
        getConnection().set(key, value);
    }

    public String get(String key) throws IOException {
        return (String) getConnection().get(key);
    }

    public void del(String key) throws IOException {
        getConnection().del(key);
    }

    public void close() {
        getConnection().close();
        getRedisClient().shutdown();
    }
}

/*
 * Spring Data Redis 1.x supports only the lettuce Version 3.x branch.
 * Without Spring Data Redis 1.x, you can use lettuce Version 4.x branch.
 * The following works only with Version 4.x.
public class Client implements BaseClient {
    private RedisClient redisClient;
    private StatefulRedisConnection<String, String> connection;

    public Client(RedisClient redisClient) {
        this.redisClient = redisClient;
        this.connection = getRedisClient().connect();
    }

    public RedisClient getRedisClient() {
        return this.redisClient;
    }

    public StatefulRedisConnection<String, String> getConnection() {
        return this.connection;
    }

    @Override
    public void set(String key, String value) throws IOException {
        getConnection().sync().set(key, value);
    }

    @Override
    public String get(String key) throws IOException {
        return (String) getConnection().sync().get(key);
    }

    public void close() {
        getConnection().close();
        getRedisClient().shutdown();
    }
}
 */


text:
package gov.nih.nci.cabig.caaers.domain.report;

import gov.nih.nci.cabig.ctms.domain.AbstractMutableDomainObject;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * The Class NotificationAttachment.
 */
@Entity
@Table(name = "attachments")
@GenericGenerator(name = "id-generator", strategy = "native", parameters = { @Parameter(name = "sequence", value = "seq_attachments_id") })
public class NotificationAttachment extends AbstractMutableDomainObject {

    /** The content. */
    private byte[] content;

    /**
     * Gets the content.
     *
     * @return the content
     */
    @Lob
    public byte[] getContent() {
        return content;
    }

    /**
     * Sets the content.
     *
     * @param content the content to set
     */
    public void setContent(byte[] content) {
        this.content = content;
    }

}


text:
package org.hawkular.metrics.api.jaxrs.handler;

import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

import static org.hawkular.metrics.api.jaxrs.filter.TenantFilter.TENANT_HEADER_NAME;
import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.badRequest;
import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.noContent;
import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.serverError;
import static org.hawkular.metrics.api.jaxrs.util.ApiUtils.valueToResponse;
import static org.hawkular.metrics.core.api.MetricType.AVAILABILITY;

import java.net.URI;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import org.hawkular.metrics.api.jaxrs.handler.observer.MetricCreatedObserver;
import org.hawkular.metrics.api.jaxrs.handler.observer.ResultSetObserver;
import org.hawkular.metrics.api.jaxrs.model.ApiError;
import org.hawkular.metrics.api.jaxrs.model.Availability;
import org.hawkular.metrics.api.jaxrs.model.AvailabilityDataPoint;
import org.hawkular.metrics.api.jaxrs.model.MetricDefinition;
import org.hawkular.metrics.api.jaxrs.param.Duration;
import org.hawkular.metrics.api.jaxrs.param.Tags;
import org.hawkular.metrics.api.jaxrs.util.ApiUtils;
import org.hawkular.metrics.core.api.AvailabilityType;
import org.hawkular.metrics.core.api.Buckets;
import org.hawkular.metrics.core.api.Metric;
import org.hawkular.metrics.core.api.MetricId;
import org.hawkular.metrics.core.api.MetricType;
import org.hawkular.metrics.core.api.MetricsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import rx.Observable;

/**
 * @author Stefan Negrea
 *
 */
@Path("/availability")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Api(tags = "Availability")
public class AvailabilityHandler {
    private static final long EIGHT_HOURS = MILLISECONDS.convert(8, HOURS);

    @Inject
    private MetricsService metricsService;

    @HeaderParam(TENANT_HEADER_NAME)
    private String tenantId;

    @POST
    @Path("/")
    @ApiOperation(value = "Create availability metric. Same notes as creating gauge metric apply.")
    @ApiResponses(value = {
            @ApiResponse(code = 201, message = "Metric created successfully"),
            @ApiResponse(code = 400, message = "Missing or invalid payload", response = ApiError.class),
            @ApiResponse(code = 409, message = "Availability metric with given id already exists",
                    response = ApiError.class),
            @ApiResponse(code = 500, message = "Metric creation failed due to an unexpected error",
                    response = ApiError.class)
    })
    public void createAvailabilityMetric(
            @Suspended final AsyncResponse asyncResponse,
            @ApiParam(required = true) MetricDefinition metricDefinition,
            @Context UriInfo uriInfo
    ) {
        if(metricDefinition.getType() != null && MetricType.AVAILABILITY != metricDefinition.getType()) {
            asyncResponse.resume(badRequest(new ApiError("MetricDefinition type does not match " + MetricType
                    .AVAILABILITY.getText())));
        }
        URI location = uriInfo.getBaseUriBuilder().path("/availability/{id}").build(metricDefinition.getId());
        Metric<AvailabilityType> metric = new Metric<>(new MetricId<>(tenantId, AVAILABILITY, metricDefinition.getId()),
                metricDefinition.getTags(), metricDefinition.getDataRetention());
        metricsService.createMetric(metric).subscribe(new MetricCreatedObserver(asyncResponse, location));
    }

    @GET
    @Path("/{id}")
    @ApiOperation(value = "Retrieve single metric definition.", response = MetricDefinition.class)
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Metric's definition was successfully retrieved."),
            @ApiResponse(code = 204, message = "Query was successful, but no metrics definition is set."),
            @ApiResponse(code = 500, message = "Unexpected error occurred while fetching metric's definition.",
                         response = ApiError.class) })
    public void getAvailabilityMetric(@Suspended final AsyncResponse asyncResponse, @PathParam("id") String id) {

        metricsService.findMetric(new MetricId<>(tenantId, AVAILABILITY, id))
                .map(MetricDefinition::new)
                .map(metricDef -> Response.ok(metricDef).build())
                .switchIfEmpty(Observable.just(noContent()))
                .subscribe(asyncResponse::resume, t -> asyncResponse.resume(serverError(t)));
    }

    @GET
    @Path("/{id}/tags")
    @ApiOperation(value = "Retrieve tags associated with the metric definition.", response = String.class,
                  responseContainer = "Map")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Metric's tags were successfully retrieved."),
            @ApiResponse(code = 204, message = "Query was successful, but no metrics were found."),
            @ApiResponse(code = 500, message = "Unexpected error occurred while fetching metric's tags.",
                response = ApiError.class) })
    public void getMetricTags(
            @Suspended final AsyncResponse asyncResponse,
            @PathParam("id") String id
    ) {
        metricsService.getMetricTags(new MetricId<>(tenantId, AVAILABILITY, id)).subscribe(
                optional -> asyncResponse.resume(valueToResponse(optional)),
                t -> asyncResponse.resume(serverError(t)));
    }

    @PUT
    @Path("/{id}/tags")
    @ApiOperation(value = "Update tags associated with the metric definition.")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Metric's tags were successfully updated."),
            @ApiResponse(code = 500, message = "Unexpected error occurred while updating metric's tags.",
                response = ApiError.class) })
    public void updateMetricTags(
            @Suspended final AsyncResponse asyncResponse,
            @PathParam("id") String id,
            @ApiParam(required = true) Map<String, String> tags
    ) {
        Metric<AvailabilityType> metric = new Metric<>(new MetricId<>(tenantId, AVAILABILITY, id));
        metricsService.addTags(metric, tags).subscribe(new ResultSetObserver(asyncResponse));
    }

    @DELETE
    @Path("/{id}/tags/{tags}")
    @ApiOperation(value = "Delete tags associated with the metric definition.")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Metric's tags were successfully deleted."),
            @ApiResponse(code = 400, message = "Invalid tags", response = ApiError.class),
            @ApiResponse(code = 500, message = "Unexpected error occurred while trying to delete metric's tags.",
                response = ApiError.class) })
    public void deleteMetricTags(
            @Suspended final AsyncResponse asyncResponse,
            @PathParam("id") String id,
            @ApiParam("Tag list") @PathParam("tags") Tags tags
    ) {
        Metric<AvailabilityType> metric = new Metric<>(new MetricId<>(tenantId, AVAILABILITY, id));
        metricsService.deleteTags(metric, tags.getTags()).subscribe(new ResultSetObserver(asyncResponse));
    }

    @POST
    @Path("/{id}/data")
    @ApiOperation(value = "Add data for a single availability metric.")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Adding data succeeded."),
            @ApiResponse(code = 400, message = "Missing or invalid payload", response = ApiError.class),
            @ApiResponse(code = 500, message = "Unexpected error happened while storing the data",
                    response = ApiError.class)
    })
    public void addAvailabilityForMetric(
            @Suspended final AsyncResponse asyncResponse, @PathParam("id") String id,
            @ApiParam(value = "List of availability datapoints", required = true) List<AvailabilityDataPoint> data
    ) {
        Observable<Metric<AvailabilityType>> metrics = AvailabilityDataPoint.toObservable(tenantId, id, data);
        Observable<Void> observable = metricsService.addDataPoints(AVAILABILITY, metrics);
        observable.subscribe(new ResultSetObserver(asyncResponse));
    }

    @POST
    @Path("/data")
    @ApiOperation(value = "Add metric data for multiple availability metrics in a single call.")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Adding data succeeded."),
            @ApiResponse(code = 400, message = "Missing or invalid payload", response = ApiError.class),
            @ApiResponse(code = 500, message = "Unexpected error happened while storing the data",
                    response = ApiError.class)
    })
    public void addAvailabilityData(
            @Suspended final AsyncResponse asyncResponse,
            @ApiParam(value = "List of availability metrics", required = true)
            List<Availability> availabilities
    ) {
        Observable<Metric<AvailabilityType>> metrics = Availability.toObservable(tenantId, availabilities);
        Observable<Void> observable = metricsService.addDataPoints(AVAILABILITY, metrics);
        observable.subscribe(new ResultSetObserver(asyncResponse));
    }

    @GET
    @Path("/{id}/data")
    @ApiOperation(value = "Retrieve availability data.", notes = "When buckets or bucketDuration query parameter is " +
            "used, the time range between start and end will be divided in buckets of equal duration, and " +
            "availability statistics will be computed for each bucket.", response = AvailabilityDataPoint.class,
            responseContainer = "List")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Successfully fetched availability data."),
            @ApiResponse(code = 204, message = "No availability data was found."),
            @ApiResponse(code = 400, message = "buckets or bucketDuration parameter is invalid, or both are used.",
                response = ApiError.class),
            @ApiResponse(code = 500, message = "Unexpected error occurred while fetching availability data.",
                response = ApiError.class), })
    public void findAvailabilityData(
            @Suspended AsyncResponse asyncResponse,
            @PathParam("id") String id,
            @ApiParam(value = "Defaults to now - 8 hours") @QueryParam("start") final Long start,
            @ApiParam(value = "Defaults to now") @QueryParam("end") final Long end,
            @ApiParam(value = "Total number of buckets") @QueryParam("buckets") Integer bucketsCount,
            @ApiParam(value = "Bucket duration") @QueryParam("bucketDuration") Duration bucketDuration,
            @ApiParam(value = "Set to true to return only distinct, contiguous values")
            @QueryParam("distinct") @DefaultValue("false") Boolean distinct
    ) {
        long now = System.currentTimeMillis();
        Long startTime = start == null ? now - EIGHT_HOURS : start;
        Long endTime = end == null ? now : end;

        MetricId<AvailabilityType> metricId = new MetricId<>(tenantId, AVAILABILITY, id);

        if (bucketsCount == null && bucketDuration == null) {
            metricsService.findAvailabilityData(metricId, startTime, endTime, distinct)
                    .map(AvailabilityDataPoint::new)
                    .toList()
                    .map(ApiUtils::collectionToResponse)
                    .subscribe(asyncResponse::resume, t -> asyncResponse.resume(serverError(t)));
        } else if (bucketsCount != null && bucketDuration != null) {
            asyncResponse.resume(badRequest(new ApiError("Both buckets and bucketDuration parameters are used")));
        } else {
            Buckets buckets;
            try {
                if (bucketsCount != null) {
                    buckets = Buckets.fromCount(startTime, endTime, bucketsCount);
                } else {
                    buckets = Buckets.fromStep(startTime, endTime, bucketDuration.toMillis());
                }
            } catch (IllegalArgumentException e) {
                asyncResponse.resume(badRequest(new ApiError("Bucket: " + e.getMessage())));
                return;
            }

            metricsService.findAvailabilityStats(metricId, startTime, endTime, buckets)
                .map(ApiUtils::collectionToResponse)
                    .subscribe(asyncResponse::resume, t -> asyncResponse.resume(serverError(t)));
        }
    }
}


text:
Blue
====

# README #

### What is this repository for? ###

* Quick summary:

### How do I get set up? ###

* Summary of set up:
* Dependencies:
* Configuration:
* Database configuration:
* How to run tests:
* Deployment instructions:

### Contribution guidelines ###

* Writing tests:
* Code review:
* Other guidelines:

### Who do I talk to? ###

* Repo owner or admin:
* Other community or team contact:


text:
Shindo.tests('Fog::Compute[:linode] | linodenodebalancers requests', ['linode']) do

  @linodenodebalancers_format = Linode::Compute::Formats::BASIC.merge({
    'DATA' => [{
      'MONTHLY'     => Float,
      'HOURLY'      => Float,
      'CONNECTIONS' => Integer
    }]
  })

  tests('success') do

    tests('#avail_nodebalancers').formats(@linodenodebalancers_format) do
      pending if Fog.mocking?
      Fog::Compute[:linode].avail_nodebalancers.body
    end

  end

end


text:
/**
 * Selfbits API V2
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.0.0
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

import * as models from './models';

export interface NewRolePermissionArray extends Array<models.NewRolePermission> {
}


text:
package log

import (
	"os"

	"github.com/go-log/log"
	golog "github.com/go-log/log/log"
)

var (
	// the local logger
	logger log.Logger = golog.New()
)

// Log makes use of github.com/go-log/log.Log
func Log(v ...interface{}) {
	logger.Log(v...)
}

// Logf makes use of github.com/go-log/log.Logf
func Logf(format string, v ...interface{}) {
	logger.Logf(format, v...)
}

// Fatal logs with Log and then exits with os.Exit(1)
func Fatal(v ...interface{}) {
	Log(v...)
	os.Exit(1)
}

// Fatalf logs with Logf and then exits with os.Exit(1)
func Fatalf(format string, v ...interface{}) {
	Logf(format, v...)
	os.Exit(1)
}

// SetLogger sets the local logger
func SetLogger(l log.Logger) {
	logger = l
}