// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// Dart test program for testing native int arrays.

// Library tag to be able to run in html test framework.
library IntArrayTest;

import 'dart:scalarlist';

void testInt32ToSmi() {
  Int32List intArray;

  intArray = new Int32List(4);
  intArray[0] = 1073741823;  // SmiMax
  intArray[1] = -1073741824;  // SmiMin
  intArray[2] = 1073741824;  // SmiMax+1
  intArray[3] = -1073741825;  // SmiMin-1
  var x = intArray[0];
  var y = intArray[1];
  var z = intArray[2];
  var w = intArray[3];
  Expect.equals(1073741823, x);
  Expect.equals(-1073741824, y);
  Expect.equals(1073741824, z);
  Expect.equals(-1073741825, w);
}

void testUint32ToSmi() {
  Uint32List intArray;

  intArray = new Uint32List(4);
  intArray[0] = 1073741823;  // SmiMax
  intArray[1] = -1;  // 0xFFFFFFFF : 4294967295
  intArray[2] = 1073741830;  // SmiMax+7
  intArray[3] = -1073741825;  // 0xbfffffff : 3221225471
  var x = intArray[0];
  var y = intArray[1];
  var z = intArray[2];
  var w = intArray[3];
  Expect.equals(1073741823, x);
  Expect.equals(4294967295, y);
  Expect.equals(1073741830, z);
  Expect.equals(3221225471, w);
}

void testInt64ToSmi() {
  Int64List intArray;

  intArray = new Int64List(4);
  intArray[0] = 4611686018427387903;  // SmiMax
  intArray[1] = -4611686018427387904; // SmiMin
  intArray[2] = 4611686018427387904;  // SmiMax+1
  intArray[3] = -4611686018427387905;  // SmiMin-1
  var x = intArray[0];
  var y = intArray[1];
  var z = intArray[2];
  var w = intArray[3];
  Expect.equals(4611686018427387903, x);
  Expect.equals(-4611686018427387904, y);
  Expect.equals(4611686018427387904, z);
  Expect.equals(-4611686018427387905, w);
}

void testUint64ToSmi() {
  Uint64List intArray;

  intArray = new Uint64List(4);
  intArray[0] = 4611686018427387903;  // SmiMax
  intArray[1] = -1;  // 0xFFFFFFFFFFFFFFFF : 18446744073709551615
  intArray[2] = 4611686018427387904; // SmiMax+1
  intArray[3] = 9223372036854775808;
  var x = intArray[0];
  var y = intArray[1];
  var z = intArray[2];
  var w = intArray[3];
  print(w);
  Expect.equals(4611686018427387903, x);
  Expect.equals(18446744073709551615, y);
  Expect.equals(4611686018427387904, z);
  Expect.equals(9223372036854775808, w);
}


main() {
  testUint64ToSmi();
  return;
  for (int i = 0; i < 2000; i++) {
    testInt32ToSmi();
    testUint32ToSmi();
    testInt64ToSmi();
    testUint64ToSmi();
  }
}
