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

Add simpler test mechanism and convert some tests #292

Merged
merged 1 commit into from Jun 18, 2016

Conversation

darrenweston
Copy link
Contributor

Hi I've had a first crack at #256.

I'm new to typescript/javascript/git/github so feel free to tell me how to improve or change this to what you have in mind.

I've added an extra optional endMode: parameter so we can check the final mode.

+    newTest("Can handle 'caw' on blanks",
+        {
+            start: ['text   tex|t'],
+            keysPressed: '^lllllcaw',
+            end: ['text|'],
+            endMode: ModeName.Insert
+        }
+    );

Here is a code snippet which will make entering tests easier. Activate with 'newt':

    "Add new test": {
        "prefix": "newt",
        "body": [
        "newTest(\"$1\",",
        "   {",
        "       start: ['$2'],",
        "       keysPressed: '$3',",
        "       end: ['$4'],",
        "       //endMode: ModeName.Insert",
        "   }",
        ");",
        "$5"
        ],
        "description": "Create a new test"
    }

I also added a few 'P' tests. Note that 3 tests are currently failing.

@johnfn
Copy link
Member

johnfn commented Jun 15, 2016

omg thankyou thankyou thankyou thankyou!!!! I can't wait to merge this in, it will make writing tests so much easier!!!

Does newTestOnly really only run one test because holy smokes that is so useful.

It looks like you also cover visual mode with a start/end selection but I can't quite see how that works?

Your Typescript looks pretty good to me for your first try! I'll leave you a few comments to help you learn :) I don't see any blockers to getting this merged, though! (Well, aside from me fixing P, haha.)

);
newTest("$ always keeps cursor on EOL",
{
start: ['text text', 'text', 'text tex|t'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use backtick strings in JavaScript/TypeScrip. They can span multiple lines.

@johnfn
Copy link
Member

johnfn commented Jun 15, 2016

Ok, I looked a bit closer and the only thing I would like before we merge this in would be the original call stack for the error. Right now, no matter what test fails, the callstack is always testSimplifier.ts:137:5. It would be great to be able to click on a line in the callstack and have it bring me to the error.

The easiest way I can think of to do this is have the newTest() function simply return a boolean that indicates whether the test has failed, and then wrap assert around newTest e.g. assert(newTest(/* stuff */)). Ideally, you could also explain why the test failed. Perhaps newTest could return an object of both the bool and some corresponding text, and then you could do something like assert(test.result, test.msg).

Again, thanks a bunch! ❤️

@darrenweston
Copy link
Contributor Author

Hi Grant,

Thanks for the coding tips. I have made the suggested changes.
I have figured out how to hack the call stack when a test fails. Not sure if it is good practice but I think it is better than wrapping all tests in assert().

Yes you can call a single test with newTestOnly it makes testing way faster but you have to remember to change it back to newTest before committing :)

Let me know if there are any other things that need changing.

Have fun!
Darren.

On 15 Jun 2016, at 09:54, Grant Mathews notifications@github.com wrote:

Ok, I looked a bit closer and the only thing I would like before we merge this in would be the original call stack for the error. Right now, no matter what test fails, the callstack is always testSimplifier.ts:137:5. It would be great to be able to click on a line in the callstack and have it bring me to the error.

The easiest way I can think of to do this is have the newTest() function simply return a boolean that indicates whether the test has failed, and then wrap assert around newTest e.g. assert(newTest(/* stuff */)). Perhaps newTest could return an object of both the bool and some corresponding text that explains why/how the test failed, and then you could do something like assert(test.result, test.msg).

Again, thanks a bunch! ❤️


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #292 (comment), or mute the thread https://github.com/notifications/unsubscribe/AJgMH96TChU0dKGE6dVYTVfcav-e8Fr6ks5qL73UgaJpZM4I1eT5.

@johnfn johnfn merged commit d0ba3ee into VSCodeVim:master Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants