toString for Single/Double
This commit is contained in:
parent
48f8024056
commit
4d4cd6f417
|
@ -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",
|
||||
|
|
|
@ -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?
|
||||
};
|
||||
|
|
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue