Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erlang binary additions + bugfixes related to Symbol === #387

Merged
merged 10 commits into from Sep 7, 2017

Conversation

@vans163
Copy link
Contributor

vans163 commented Sep 5, 2017

Knocks out some things here #306, note some functions are partially complete.

result = Functions.map_to_object(map, []);
t.deepEqual(result, { s_key: 'value', s_anotherKey: 'value2' });
});*/

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Newline required at end of file but not found.

@@ -23,12 +23,28 @@ test('split_at', (t) => {
t.deepEqual(Functions.split_at('😀abélkm', 4).values, ['😀abé', 'lkm']);
});

//TODO: Fix these tests
/*test('map_to_object/1', (t) => {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Expected exception block, space or tab after '/*' in comment.

@@ -23,12 +23,28 @@ test('split_at', (t) => {
t.deepEqual(Functions.split_at('😀abélkm', 4).values, ['😀abé', 'lkm']);
});

//TODO: Fix these tests

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Expected exception block, space or tab after '//' in comment.

test('split/2', (t) => {
let result = Core.binary.split('abcd', 'b');
t.deepEqual(result, ['a', 'cd']);
});

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Newline required at end of file but not found.

});

test('split/2', (t) => {
let result = Core.binary.split('abcd', 'b');

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

'result' is never reassigned. Use 'const' instead.

key = key.toString();
} else if (
(type_keys === Symbol('string') || symbols !== Symbol('undefined')) &&
typeof key === 'symbol'
(opt_keys === Symbol.for('string') || opt_symbols !== Symbol.for('undefined'))

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Trailing spaces not allowed.

part,
replace,
split,
};

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Newline required at end of file but not found.

//TODO: Support more options, global is implied
//TODO: pattern cannot be list of strings
function split(subject, pattern, options=[]) {
return subject.split(pattern)

This comment has been minimized.

//TODO: Support more options, global is implied
//TODO: pattern cannot be list of strings
function split(subject, pattern, options=[]) {
return subject.split(pattern)

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Expected indentation of 2 spaces but found 4.

Read more about it here.


//TODO: Support more options, global is implied
//TODO: pattern cannot be list of strings
function split(subject, pattern, options=[]) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 5, 2017

Infix operators must be spaced.

});

test('is_defined/2', (t) => {
let result = Core.binary.at('abc', 0);

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

'result' is never reassigned. Use 'const' instead.

t.deepEqual(result, '123');

result = Core.proplists.get_value('abcd', [new Core.Tuple('abc', '123')], "xyz");
t.deepEqual(result, "xyz");

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Strings must use singlequote.

Read more about it here.

let result = Core.proplists.get_value('abc', [new Core.Tuple('abc', '123')], "xyz");
t.deepEqual(result, '123');

result = Core.proplists.get_value('abcd', [new Core.Tuple('abc', '123')], "xyz");

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Strings must use singlequote.

Read more about it here.

});

test('get_value/3', (t) => {
let result = Core.proplists.get_value('abc', [new Core.Tuple('abc', '123')], "xyz");

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Strings must use singlequote.

Read more about it here.

@@ -0,0 +1,26 @@
import test from 'ava';

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

'ava' should be listed in the project's dependencies, not devDependencies.

@@ -1,10 +1,13 @@
import ErlangTypes from 'erlang-types';

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

'ErlangTypes' is defined but never used.

}

//TODO: Support more options, global is implied
//TODO: pattern cannot be list of strings

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Expected exception block, space or tab after '//' in comment.

return subject.replace(regex, replacement);
}

//TODO: Support more options, global is implied

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Expected exception block, space or tab after '//' in comment.

function replace(subject, pattern, replacement, options=[]) {
const opt_global = proplists.get_value(Symbol.for('global'), options);

var regex;

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unexpected var, use let or const instead.


//TODO: Support more options
//TODO: pattern cannot be list of strings
function replace(subject, pattern, replacement, options=[]) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Infix operators must be spaced.

var pos;
[pos, len] = posOrTuple.values;
return subject.substr(pos, len);
} else {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unnecessary 'else' after 'return'.

function part(subject, posOrTuple, len = null) {
if (len === null) {
var pos;
[pos, len] = posOrTuple.values;

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Avoid variable reassignments of function parameters

function list_to_bin(bytelist) {
return erlang.list_to_binary(bytelist);
}

function part(subject, posOrTuple, len = null) {
if (len === null) {
var pos;

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unexpected var, use let or const instead.

function list_to_bin(bytelist) {
return erlang.list_to_binary(bytelist);
}

function part(subject, posOrTuple, len = null) {
if (len === null) {
var pos;

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

All 'var' declarations must be at the top of the function scope.

@vans163 vans163 mentioned this pull request Sep 6, 2017
new Map([[Symbol.for('nest1'), 'valuenest1']]),
new Map([[Symbol.for('nest2'), 'valuenest2']])
]]]));
});

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Newline required at end of file but not found.

new Core.Tuple(Symbol.for('recurse_array'), true)]);
t.deepEqual(result, new Map([[Symbol.for('key'), [
new Map([[Symbol.for('nest1'), 'valuenest1']]),
new Map([[Symbol.for('nest2'), 'valuenest2']])

This comment has been minimized.

obj = {};
obj[Symbol.for('key')] = [{nest1: 'valuenest1'},{nest2: 'valuenest2'}];
result = Functions.object_to_map(obj, [
new Core.Tuple(Symbol.for('keys'), Symbol.for('atom')),

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Trailing spaces not allowed.

t.deepEqual(result, new Map([[Symbol.for('key'), 'value']]));

obj = {};
obj[Symbol.for('key')] = [{nest1: 'valuenest1'},{nest2: 'valuenest2'}];

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

A space is required before '}'.

t.deepEqual(result, new Map([[Symbol.for('key'), 'value']]));

obj = {};
obj[Symbol.for('key')] = [{nest1: 'valuenest1'},{nest2: 'valuenest2'}];

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

A space is required after '{'.

return map;

} else if (object instanceof Array && opt_recurse_array) {
return object.map(function(ele) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unexpected function expression.

return map;

} else if (object instanceof Array && opt_recurse_array) {
return object.map(function(ele) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unexpected unnamed function.

});
return map;

} else if (object instanceof Array && opt_recurse_array) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Block must not be padded by blank lines.


if (object.constructor === Object) {
let map = new Map();
Reflect.ownKeys(object).forEach(key => {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Expected parentheses around arrow function argument having a body with curly braces.

const opt_recurse_array = proplists.get_value(Symbol.for('recurse_array'), options) === true;

if (object.constructor === Object) {
let map = new Map();

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

'map' is never reassigned. Use 'const' instead.

@sourcelevel-bot
Copy link

sourcelevel-bot bot commented Sep 6, 2017

Ebert has finished reviewing this Pull Request and has found:

  • 39 possible new issues (including those that may have been commented here).

But beware that this branch is 2 commits behind the elixirscript:master branch, and a review of an up to date branch would produce more accurate results.

You can see more details about this review at https://ebertapp.io/github/elixirscript/elixirscript/pulls/387.

Takes the given object and returns a map
Options include [{:keys, :atom}, {:recurse_array, true}]

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

There should be no more than 1 consecutive blank lines.


//TODO: Support more options, global is implied
//TODO: pattern cannot be list of strings
function split(subject, pattern, options = []) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

'options' is assigned a value but never used.

function replace(subject, pattern, replacement, options = []) {
const opt_global = proplists.get_value(Symbol.for('global'), options);

var regex;

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Unexpected var, use let or const instead.


function last(subject) {
if (subject.length == 0) {
throw new Error(`Binary is of length 0`);

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Strings must use singlequote.

Read more about it here.

}

function last(subject) {
if (subject.length == 0) {

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Bad equality comparison: Expected '===' and instead saw '=='.


function copy(subject, n = 1) {
return subject.repeat(n);
}

function first(subject) {
if (subject.length == 0) {
throw new Error(`Binary is of length 0`);

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Strings must use singlequote.

Read more about it here.

@@ -91,27 +91,56 @@ defmodule ElixirScript.Translate.Forms.JS do
{ast, state}
end

def compile({{:., _, [ElixirScript.JS, :map_to_object]}, _, [object]}, state) do
def compile({{:., _, [ElixirScript.JS, :map_to_object]}, _, [map]}, state) do

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Functions should have a @SPEC type specification.

]
)

{ast, state}
end

def compile({{:., _, [ElixirScript.JS, :map_to_object]}, _, [object, options]}, state) do
def compile({{:., _, [ElixirScript.JS, :map_to_object]}, _, [map, options]}, state) do

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Functions should have a @SPEC type specification.

{ast, state}
end

def compile({{:., _, [ElixirScript.JS, :object_to_map]}, _, [object]}, state) do

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Functions should have a @SPEC type specification.

{ast, state}
end

def compile({{:., _, [ElixirScript.JS, :object_to_map]}, _, [object, options]}, state) do

This comment has been minimized.

@sourcelevel-bot

sourcelevel-bot bot Sep 6, 2017

Functions should have a @SPEC type specification.

@bryanjos bryanjos merged commit b74c6e9 into elixirscript:master Sep 7, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
ebert Ebert has found 39 possible new issues.
Details
@bryanjos
Copy link
Collaborator

bryanjos commented Sep 7, 2017

Thanks for all of the work here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.