-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Added Operations: Octal #92
Conversation
- To Octal - From Octal
Hi @artemisbot, I know its only a small change, unfortunately we can't merge this just yet as we don't want to loose support for non ES6 browsers yet. That said... I know @n1474335 is currently working on #10 / #5 which will mean that we can use babel to convert back. Once that is sorted we can merge this! Whilst waiting for that, I don't know if you saw, but tlwr has introduced a lightweight test suite / #84. Adding a test or so around this could be useful to ensure we don't accidentally break compatibility with anything you've got planned with this in the future |
@m2951413 Sorry, don't know much at all about different ECMAScript versions - is the issue the arrow functions? If so I can just replace them, they're not necessary and just because it's how I would normally do it. |
Yes that is correct, the arrow function/fat arrow was my concern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for another great contribution. As @m2951413 has said, we can't merge this quite yet due to the ES6 support, however I wouldn't change it - let's use it as the first test case for Babel once I've committed my build process changes.
Regarding the highlighting, I don't think there's any way of getting it to work with the current highlighting system of offsets and lengths. This is something that we should work on to improve in future.
You've included good descriptions for these operations, perhaps you could use the examples in them as test cases?
src/js/operations/ByteRepr.js
Outdated
@@ -25,6 +25,11 @@ var ByteRepr = { | |||
* @constant | |||
* @default | |||
*/ | |||
OCT_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same as DELIM_OPTIONS
so I'd just use that instead of duplicating code.
src/js/core/Utils.js
Outdated
@@ -829,6 +829,38 @@ var Utils = { | |||
|
|||
|
|||
/** | |||
* Convert an byte array into a octal string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see why you've put this in Utils because that's what I've done with the bin and hex operations, however I think in this particular case it would make more sense to just put this code directly into the ByteRepr.runToOct
and ByteRepr.runFromOct
functions. It's probably not something that will be used elsewhere in the app, and if it is we can always break it out into Utils again.
src/js/config/OperationConfig.js
Outdated
@@ -392,7 +392,7 @@ var OperationConfig = { | |||
] | |||
}, | |||
"From Hex": { | |||
description: "Converts a hexadecimal byte string back into a its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>", | |||
description: "Converts a hexadecimal byte string back into its raw value.<br><br>e.g. <code>ce 93 ce b5 ce b9 ce ac 20 cf 83 ce bf cf 85 0a</code> becomes the UTF-8 encoded string <code>Γειά σου</code>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot!
I've taken a stab at test cases, as well as fixing the requested changes. However (even with changing the arrow functions to normal functions so it actually runs), very few of the tests will ever pass.
I'd be very appreciative if someone could point out what I'm doing wrong! |
I think the problem with your tests is that If you think this is unintuitive behaviour, perhaps we should consider modifying the test runner in future to allow testing individual operations instead of entire recipes. |
I've rectified some of those problems with it now (forgot how normal JS functions work :P) - however I'm still getting these two test fails with this config.
I'm particularly interested in the first one, since test doesn't give a full trace I can't tell where it's going wrong. |
Agree, it is a big blind spot that doesn't allow us to properly test output types. I can implement it such that tests have a recipe:
or just an operation and arguments:
It may also require @artemisbot right now the test runner is a bit janky (we can improve it now with #95), though once you do Your test
in |
@tlwr, those modifications to the test runner sound good. It's probably best that you wait until #95 is merged before making changes otherwise there will be conflicts. You should be able to look up the input and output types in The problem you've found in |
@artemisbot |
Right, I'll sort them tomorrow :) |
Worryingly, I'm still getting failures on the last two of my tests. Additionally, after running |
I'm still interested as to why the tests are failing - perhaps someone else can try running them because they never pass at all for me. Hopefully, then we can push them to master. |
I fixed the tests - it was entirely my fault. There were calls to The only thing I changed regarding your operations was the unnecessary cast to binary and back that you had in 'From Octal'. The input is already a It looks like Babel is correctly translating your arrow notation so things are working as expected! Thanks for another great contribution. |
[DOCS] Adds docs for Render.com deployment
Also, if anyone can figure out how to do highlighting for this, that'd be amazing. I was totally stumped by that on this one due to octal coming out at different lengths.