toString for Single/Double

This commit is contained in:
Tony Garnock-Jones 2019-06-24 10:44:58 +01:00
parent 48f8024056
commit 4d4cd6f417
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "preserves",
"version": "0.0.15",
"version": "0.0.16",
"description": "Experimental data serialization format",
"homepage": "https://gitlab.com/tonyg/preserves",
"license": "MIT",

View File

@ -74,6 +74,10 @@ function Float(value) {
_Float.call(this, value);
}
Float.prototype.toString = function () {
return '' + this.value;
};
Float.prototype.hashCode = function () {
return this.value | 0; // TODO: something better?
};

View File

@ -0,0 +1,21 @@
"use strict";
const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-immutable'));
const Immutable = require('immutable');
const { is, Single, Double, fromJS } = require('../src/index.js');
describe('Single', () => {
it('should print reasonably', () => {
expect(Single(123.45).toString()).to.equal("123.45");
});
});
describe('Double', () => {
it('should print reasonably', () => {
expect(Double(123.45).toString()).to.equal("123.45");
});
});