
scope {
  //print(0.INT_MIN, 0.INT_MAX);
  assert 0.INT_MIN < 0;
  assert 0.INT_MAX > 0;
  var i = 0;
  assert 'integer' === typename i;
  assert 0 === i.compare(0);
  assert i.compare(1) < 0;
  assert i.compare(-1) > 0;
  assert 0.0 === i.toDouble();
  assert 0 !== i.toDouble();
  assert "0" === i.toJSONString();
  assert "0" === i.toString();
  assert "1" === 1.toString();
  i = 42;
  assert '*' === i.toUtf8Char();
}

scope {
  var d = 0.0;
  assert 'double' === typename d;
  assert 0 === d.compare(0);
  assert d.compare(1) < 0;
  assert d.compare(-1) > 0;
  assert 0 === d.toInt();
  assert 0.0 !== d.toInt();
  assert "0.0" === d.toJSONString();
  assert "0.0" === d.toString();
  assert "1.0" === 1.0.toString();
  assert 1 === 0.5.ceil();
  assert 0 === (-0.5).ceil(); // parens needed: dot has higher precedence than unary -.
  //assert 0 === 0.ceil(); // INTEGER 0 doesn't have ceil()
  assert 0 === 0.0.ceil();
}

scope {
  1.0.prototype.twice = proc(){ return this * 2 };
  assert 6.2 === 3.1.twice();
  assert 8.0 === (2.0*2).twice();
  //unset 0.0.prototype.twice; // unset doesn't like this, so...
  var d = 0.0;
  unset d.prototype.twice, d;
}
