function test_fieldnumber_constructor() {
  // No arguments
  var field = new Blockly.FieldNumber();
  assertEquals(field.getValue(), '0');

  // Unlike blockly, scratch-blocks doesn't store min, max, and precision.
  // TODO: Update this to check the restrictor, based on min, max, and precision.
  assertEquals(field.min_, undefined);
  assertEquals(field.max_, undefined);
  assertEquals(field.precision_, undefined);

  // Numeric values
  field = new Blockly.FieldNumber(1);
  assertEquals(field.getValue(), '1');
  field = new Blockly.FieldNumber(1.5);
  assertEquals(field.getValue(), '1.5');

  // String value
  field = new Blockly.FieldNumber('2');
  assertEquals(field.getValue(), '2');
  field = new Blockly.FieldNumber('2.5');
  assertEquals(field.getValue(), '2.5');

  // All values
  field = new Blockly.FieldNumber(
    /* value */ 0,
    /* min */ -128,
    /* max */ 127,
    /* precision */ 1);
  // Unlike blockly, scratch-blocks doesn't store min, max, and precision.
  assertEquals(field.getValue(), '0');
  assertEquals(field.min_, undefined);
  assertEquals(field.max_, undefined);
  assertEquals(field.precision_, undefined);

  // Bad value defaults to '0'
  field = new Blockly.FieldNumber('bad');
  assertEquals(field.getValue(), '0');
  field = new Blockly.FieldNumber(NaN);
  assertEquals(field.getValue(), '0');
}
@fileoverview Tests for Blockly.FieldNumber
@author Anm@anm.me (Andrew n marshall)