Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed May 21, 2024
1 parent 0399758 commit 4ce5124
Show file tree
Hide file tree
Showing 31 changed files with 116 additions and 150 deletions.
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/float$div.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {FLOAT} = require('../../../runtime/data')
const {data, FLOAT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/float$gt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {FLOAT} = require('../../../runtime/data')
const {data, FLOAT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/float$plus.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {FLOAT} = require('../../../runtime/data')
const {data, FLOAT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/float$times.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {FLOAT} = require('../../../runtime/data')
const {data, FLOAT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/int$div.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {INT} = require('../../../runtime/data')
const {data, INT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/int$gt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {INT} = require('../../../runtime/data')
const {data, INT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/int$plus.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {INT} = require('../../../runtime/data')
const {data, INT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/int$times.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const dataized = require('../../../runtime/dataized')
const object = require('../../../runtime/object')
const data = require('../../../runtime/data')
const {INT} = require('../../../runtime/data')
const {data, INT} = require('../../../runtime/data')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials')
const at_void = require('../../../runtime/attribute/at-void')

Expand Down
3 changes: 1 addition & 2 deletions eo2js-runtime/src/objects/org/eolang/io/stdout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const object = require('../../../../runtime/object.js')
const dataized = require('../../../../runtime/dataized')
const data = require('../../../../runtime/data')
const {STRING} = require('../../../../runtime/data')
const {data, STRING} = require('../../../../runtime/data')
const {LAMBDA} = require('../../../../runtime/attribute/specials')
const at_void = require('../../../../runtime/attribute/at-void');

Expand Down
2 changes: 1 addition & 1 deletion eo2js-runtime/src/objects/org/eolang/string$length.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const object = require('../../../runtime/object')
const {LAMBDA, RHO} = require('../../../runtime/attribute/specials');
const data = require('../../../runtime/data');
const {data} = require('../../../runtime/data');
const dataized = require('../../../runtime/dataized');

/**
Expand Down
8 changes: 5 additions & 3 deletions eo2js-runtime/src/runtime/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ const data = {
})
}
return object
},
}
}

module.exports = {
data,
INT: 'int',
STRING: 'string',
FLOAT: 'float',
BOOL: 'bool',
BYTES: 'bytes'
}

module.exports = data
4 changes: 2 additions & 2 deletions eo2js-runtime/src/runtime/error/ErError.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ErAbstract = require('./ErAbstract');
const dataized = require('../dataized');
const data = require('../data');
const {STRING} = require('../data');

/**
* This Error is thrown by the {@see error} object only.
Expand All @@ -22,7 +22,7 @@ class ErError extends ErAbstract {
* @return {string}
*/
static safeMessage(enclosure) {
return dataized(enclosure, data.STRING)
return dataized(enclosure, STRING)
}
}

Expand Down
3 changes: 0 additions & 3 deletions eo2js-runtime/src/runtime/trapped.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const trapped = function(callback) {
{
get: function(target, property, _) {
return target()[property]
},
apply: function(target, thisArg, arguments) {
return target().call(thisArg, ...arguments)
}
}
)
Expand Down
2 changes: 1 addition & 1 deletion eo2js-runtime/src/runtime/validated.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const ErFailure = require('./error/ErFailure');
const ErError = require('./error/ErError');
const data = require('./data');
const {data} = require('./data');

/**
* Validate given callback.
Expand Down
2 changes: 1 addition & 1 deletion eo2js-runtime/test/objects/org/eolang/error.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const error = require('../../../../temp/objects/org/eolang/error');
const data = require('../../../../temp/runtime/data');
const {data} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const ErError = require('../../../../temp/runtime/error/ErError');

Expand Down
12 changes: 3 additions & 9 deletions eo2js-runtime/test/objects/org/eolang/float$div.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const float$div = require('../../../../temp/objects/org/eolang/float$div');
const data = require('../../../../temp/runtime/data');
const {data, FLOAT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,21 +10,15 @@ describe('float$div', function() {
const div = float$div()
div.attrs[RHO] = at_rho(data.toObject(13.2))
assert.equal(
dataized(
div.with({'x': data.toObject(5.7)}),
data.FLOAT
),
dataized(div.with({'x': data.toObject(5.7)}), FLOAT),
13.2 / 5.7
)
})
it('should not fail on division by zero', function() {
const div = float$div()
div.attrs[RHO] = at_rho(data.toObject(13.2))
assert.doesNotThrow(
() => dataized(
div.with({'x': data.toObject(0.0)}),
data.FLOAT
)
() => dataized(div.with({'x': data.toObject(0.0)}), FLOAT)
)
});
})
12 changes: 3 additions & 9 deletions eo2js-runtime/test/objects/org/eolang/float$gt.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const float$gt = require('../../../../temp/objects/org/eolang/float$gt');
const data = require('../../../../temp/runtime/data');
const {data, BOOL} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,21 +10,15 @@ describe('float$gt', function() {
const gt = float$gt()
gt.attrs[RHO] = at_rho(data.toObject(7.2))
assert.equal(
dataized(
gt.with({'x': data.toObject(3.1)}),
data.BOOL
),
dataized(gt.with({'x': data.toObject(3.1)}), BOOL),
true
)
})
it('should not confirm that 10.4 > 20.1', function() {
const gt = float$gt()
gt.attrs[RHO] = at_rho(data.toObject(10.4))
assert.equal(
dataized(
gt.with({'x': data.toObject(20.1)}),
data.BOOL
),
dataized(gt.with({'x': data.toObject(20.1)}), BOOL),
false
)
})
Expand Down
7 changes: 2 additions & 5 deletions eo2js-runtime/test/objects/org/eolang/float$plus.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const float$plus = require('../../../../temp/objects/org/eolang/float$plus');
const data = require('../../../../temp/runtime/data');
const {data, FLOAT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,10 +10,7 @@ describe('int$plus', function() {
const plus = float$plus()
plus.attrs[RHO] = at_rho(data.toObject(7.1))
assert.equal(
dataized(
plus.with({'x': data.toObject(3.4)}),
data.FLOAT
),
dataized(plus.with({'x': data.toObject(3.4)}), FLOAT),
10.5
)
})
Expand Down
7 changes: 2 additions & 5 deletions eo2js-runtime/test/objects/org/eolang/float$times.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');
const data = require('../../../../temp/runtime/data');
const {data, FLOAT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const float$times = require('../../../../temp/objects/org/eolang/float$times');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
Expand All @@ -10,10 +10,7 @@ describe('float$times', function() {
const times = float$times()
times.attrs[RHO] = at_rho(data.toObject(5.5))
assert.equal(
dataized(
times.with({'x': data.toObject(12.1)}),
data.FLOAT
),
dataized(times.with({'x': data.toObject(12.1)}), FLOAT),
5.5 * 12.1
)
})
Expand Down
7 changes: 2 additions & 5 deletions eo2js-runtime/test/objects/org/eolang/int$div.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const int$div = require('../../../../temp/objects/org/eolang/int$div');
const data = require('../../../../temp/runtime/data');
const {data, INT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,10 +10,7 @@ describe('int$div', function() {
const div = int$div()
div.attrs[RHO] = at_rho(data.toObject(42))
assert.equal(
dataized(
div.with({'x': data.toObject(6)}),
data.INT
),
dataized(div.with({'x': data.toObject(6)}), INT),
7
)
})
Expand Down
12 changes: 3 additions & 9 deletions eo2js-runtime/test/objects/org/eolang/int$gt.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const int$gt = require('../../../../temp/objects/org/eolang/int$gt');
const data = require('../../../../temp/runtime/data');
const {data, BOOL} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,21 +10,15 @@ describe('int$gt', function() {
const gt = int$gt()
gt.attrs[RHO] = at_rho(data.toObject(7))
assert.equal(
dataized(
gt.with({'x': data.toObject(3)}),
data.BOOL
),
dataized(gt.with({'x': data.toObject(3)}), BOOL),
true
)
})
it('should not confirm that 10 > 20', function() {
const gt = int$gt()
gt.attrs[RHO] = at_rho(data.toObject(10))
assert.equal(
dataized(
gt.with({'x': data.toObject(20)}),
data.BOOL
),
dataized(gt.with({'x': data.toObject(20)}), BOOL),
false
)
})
Expand Down
7 changes: 2 additions & 5 deletions eo2js-runtime/test/objects/org/eolang/int$plus.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const int$plus = require('../../../../temp/objects/org/eolang/int$plus');
const data = require('../../../../temp/runtime/data');
const {data, INT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,10 +10,7 @@ describe('int$plus', function() {
const plus = int$plus()
plus.attrs[RHO] = at_rho(data.toObject(7))
assert.equal(
dataized(
plus.with({'x': data.toObject(3)}),
data.INT
),
dataized(plus.with({'x': data.toObject(3)}), INT),
10
)
})
Expand Down
7 changes: 2 additions & 5 deletions eo2js-runtime/test/objects/org/eolang/int$times.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const int$times = require('../../../../temp/objects/org/eolang/int$times');
const data = require('../../../../temp/runtime/data');
const {data, INT} = require('../../../../temp/runtime/data');
const dataized = require('../../../../temp/runtime/dataized');
const {RHO} = require('../../../../temp/runtime/attribute/specials');
const at_rho = require('../../../../temp/runtime/attribute/at-rho');
Expand All @@ -10,10 +10,7 @@ describe('int$times', function() {
const times = int$times()
times.attrs[RHO] = at_rho(data.toObject(3))
assert.equal(
dataized(
times.with({'x': data.toObject(4)}),
data.INT
),
dataized(times.with({'x': data.toObject(4)}), INT),
12
)
})
Expand Down
12 changes: 3 additions & 9 deletions eo2js-runtime/test/objects/org/eolang/io/stdout.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
const assert = require('assert');
const stdout = require('../../../../../temp/objects/org/eolang/io/stdout');
const data = require('../../../../../temp/runtime/data');
const {data, BOOL} = require('../../../../../temp/runtime/data');
const dataized = require('../../../../../temp/runtime/dataized');

describe('stdout', function() {
it('should be dataized to true', function() {
assert.ok(
dataized(
stdout().with({'text': data.toObject('Hello')}),
data.BOOL
)
dataized(stdout().with({'text': data.toObject('Hello')}), BOOL)
)
})
it('should log to output', function() {
const logs = []
const out = {log: (...args) => logs.push(...args)}
dataized(
stdout(out).with({'text': data.toObject('Hello, world!')}),
data.BOOL
)
dataized(stdout(out).with({'text': data.toObject('Hello, world!')}), BOOL)
assert.ok(logs.includes('Hello, world!'))
});
})
8 changes: 4 additions & 4 deletions eo2js-runtime/test/objects/org/eolang/try.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const assert = require('assert');
const tr = require('../../../../temp/objects/org/eolang/try');
const data = require('../../../../temp/runtime/data');
const {data, STRING, BOOL} = require('../../../../temp/runtime/data');
const object = require('../../../../temp/runtime/object');
const dataized = require('../../../../temp/runtime/dataized');
const attr = require('../../../../temp/runtime/attribute/attr');
Expand Down Expand Up @@ -77,13 +77,13 @@ const tryObj = function(main, final) {

describe('try', function() {
it(`should catch error via ${PHI}`, function() {
assert.equal(dataized(tryObj(broken(PHI)), data.STRING), message)
assert.equal(dataized(tryObj(broken(PHI)), STRING), message)
})
it(`should catch error via ${LAMBDA}`, function() {
assert.equal(dataized(tryObj(broken(LAMBDA)), data.STRING), message)
assert.equal(dataized(tryObj(broken(LAMBDA)), STRING), message)
})
it('should be dataized to body', function() {
assert.equal(dataized(tryObj(main()), data.BOOL), true)
assert.equal(dataized(tryObj(main()), BOOL), true)
})
it('should dataize "finally" attribute', function() {
const logs = []
Expand Down
Loading

0 comments on commit 4ce5124

Please sign in to comment.