Skip to content

Doctest required #142

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

Closed
itsvinayak opened this issue May 4, 2020 · 22 comments
Closed

Doctest required #142

itsvinayak opened this issue May 4, 2020 · 22 comments
Assignees
Labels
wontfix Will not be fixed or is a feature

Comments

@itsvinayak
Copy link
Member

it will be good if algorithms have Doctest's https://www.npmjs.com/package/doctest

@itsvinayak itsvinayak added feature Adds a new feature help wanted Needs to be worked on labels May 4, 2020
@cclauss
Copy link
Member

cclauss commented May 12, 2020

Which files in this repo currently have doctests?
It would be good to have a list of examples in this repo that contributors could review.

@itsvinayak
Copy link
Member Author

@cclauss currently none of the files have Doctest

@cclauss
Copy link
Member

cclauss commented May 12, 2020

Todos:

  • Add doctests to at least two algorithms in this repo BogoSort.js: Simplify Array.isSorted() and add doctests #171
  • Help at least one contributor to add doctests to a new algorithm contribution
  • Discuss how difficult it was to complete 1. and 2.
  • Decide if we should make doctests a requirement of new contributions to this repo.

@itsvinayak
Copy link
Member Author

more people of the community should discuss this issue

cclauss added a commit that referenced this issue May 12, 2020
As discussed at #164 (comment)

Also related to add doctests as discussed in #142
BurhanH added a commit to BurhanH/Javascript that referenced this issue May 18, 2020
* added DecimalToHex

* added luhn's checksum algorithm

* deleted checksums

* Update keyFinder.js

modified used the suitable identifier for the variables

* Update keyFinder.js

1. modified the identifiers and used the suitable identifiers for the variables
2. leave the loop when a key is match and found to increase the speed of searching in this stage of development
3. return the key number if founded, return 0 if found nothing

* Update keyFinder.js

a sub-function is used to assist the keyfinder to find the key

* Update keyFinder.js

Finally, there are several changes in the function keyFinder(str) that make it works well

* Update keyFinder.js

Add some key words to the wordbank to increase the chance of the matching.

* fixed and added test cases

* fixed alert

* Add wiggle sort

* adding Graph data structure

* Added SHA-1 and SHA-256 hashing algorithms (TheAlgorithms#83)

* Added SHA-1 and SHA-256 hashing algorithms

* Fixed typos in comments

* Removed redundant unsigned integer casting

* Added Jump Search to readme.md

* Added JumpSearch algorithm

* Update jumpSearch.js

* Added Semicolon to Avoid Auto Semicolon Insertion

This fixes a [recommendation on lgtm](https://lgtm.com/projects/g/TheAlgorithms/Javascript/snapshot/9fe2ca0492e0813c5e5486498c6b53a00c4a61e3/files/Sorts/bucketSort.js?sort=name&dir=ASC&mode=heatmap)

* Fixed Whitespace, Operators, and Quotes to Comply with JSLint

I modified the whitespace in the files and changed single quotes to double quotes.

I also changed some `==` and `!=` operators to `===` and `!==` to comply with JSLint.

* Create find_lcm.js

- Created find_lcm.js
- Created maths folder

* Create average_mean.js

* Create factorial.js

This program calculates and displays the factorial for a user-input number.

* Create abs.js

This script calculates absolute value.

* Made "use strict" Global

* Made "use strict" Global & Made JSLint Happy

* Kadane Algo is added

* Issue fixed

* GitHub Action to test Javascript

* Update nodejs.yml

* cd linear-algebra-javascript

* Create update_directory_md.yml

* updating DIRECTORY.md

* update_directory_md.yml: Remove GH Actions workaround

* Graph Theory

* Delete Graphs

* Graph

* Dijkstra Smallest Path

* DijkstraSmallestPath

after fixing some errors.

* Topological Sort 

directed graphs

* correcting name of file

* updating DIRECTORY.md

* doublylinkedlist

* add-doublylinkedlist

* add-doublylinkedlist

* change in Directory.md

* updating DIRECTORY.md

* update (#1)

* Graph Theory

* Delete Graphs

* Graph

* Dijkstra Smallest Path

* DijkstraSmallestPath

after fixing some errors.

* Topological Sort 

directed graphs

* correcting name of file

* updating DIRECTORY.md

* doublylinkedlist

* add-doublylinkedlist

* add-doublylinkedlist

* change in Directory.md

* updating DIRECTORY.md

Co-authored-by: Nur69 <[email protected]>
Co-authored-by: Stepfen Shawn <[email protected]>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: hmizz <[email protected]>

* Contributing guidelines

* npx standard --fix

* Update CONTRIBUTING.md

* Update README.md

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Update CONTRIBUTING.md

Co-authored-by: Christian Clauss <[email protected]>

* Add standard to our testing

Run in allow failures mode until the non-compliant files are fixed.

* npx standard || true

* Update README.md

* Fixing non compliant files (Ciphers, Conversions and Data Structures)

* Update nodejs.yml

* Data Structures/Graph

* sorts/

* fix broken link

* search/

* search/ (TheAlgorithms#143)

* factorial.js: Standardjs fixes

Related to TheAlgorithms#139

* /* global alert, prompt */

* find_lcm.js: Standardjs fixes

* abs.js: abs_val() --> absVal() for standardjs (TheAlgorithms#144)

* find_lcm.js: Standardjs fixes (TheAlgorithms#146)

* Update factorial.js

* SHA256.js: Standardjs fixes

* factorial.js: /* global prompt */

* Update nodejs.yml

* DijkstraSmallestPath.js: Standardjs fixes (TheAlgorithms#147)

* Fixed typo in CONTRIBUTING.md file (TheAlgorithms#148)

* Fixed typo in CONTRIBUTING.md file

* Update CONTRIBUTING.md

Co-authored-by: vinayak <[email protected]>

* math/

* sort/

* Add Pascal's triangle. (TheAlgorithms#149)

* Add Pascal's triangle.

* Update pascalTriangle.js

* Update pascalTriangle.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Javascript/linear-algebra-javascript

* Update nodejs.yml

* Update nodejs.yml

* Update nodejs.yml

* Trailing space ;-)

* Update README.md

* adding an implementation of a queue using 2 stacks (TheAlgorithms#137)

* adding an implementation of a queue using 2 stacks

* Update QueueUsing2Stacks.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Create palindrome algorithm (TheAlgorithms#134)

* Create palindrome algorithm

* Update Palindrome.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Create pull_request_template.md (TheAlgorithms#153)

* Create pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update pull_request_template.md

* Update README.md

* Update CONTRIBUTING.md

* added hcf finding algorithm (TheAlgorithms#104)

* added hcf finding algorith

* Update and rename find_hcf.js to FindHcf.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Create Fibonacci.js (TheAlgorithms#133)

* Create Fibonacci.js

* Update Fibonacci.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Javascript/Math: editing file name

* updating DIRECTORY.md

* Update nodejs.yml

* Update README.md

* editing file names

* updating DIRECTORY.md

* Quick Select Search (TheAlgorithms#131)

* HeapSort algorithm

* Create QuickSelect.js

* Algorithm to reverse a string.

* Update ReverseString.js

* Update Heapsort.js

* Update QuickSelect.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Update README.md

* Max heap implementation (TheAlgorithms#157)

* Added MaxHeap implementation

* Added MaxHeap implementation

* Added MaxHeap implementation

* Added MaxHeap implementation

* Delete package-lock.json

* Delete .gitignore

* updating DIRECTORY.md

* Renaming files according to naming convention (TheAlgorithms#158)

* updating DIRECTORY.md

* Fibonacci without recursion added (TheAlgorithms#159)

* changes made

* Update Fibonacci.js

* fib

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* format files

* updating DIRECTORY.md

* Add good_filepaths function in workflow script

* updating DIRECTORY.md

* Add md_prefix and print_path functions

* Add reverse words (TheAlgorithms#162)

* add reverse words

* Update ReverseWords.js

* Update ReverseWords.js

Co-authored-by: vinayak <[email protected]>

* updating DIRECTORY.md

* Add build_directory_md

* GitHub Action nodejs.yml upgrade to Node.js 14 (TheAlgorithms#165)

* JavaScript, not Javascript (TheAlgorithms#166)

* Rename script.js to UpdateDirectory.js

* updating DIRECTORY.md

* run: node UpdateDirectory.js

* run: node .github/workflows/UpdateDirectory.js

* updating DIRECTORY.md

* BogoSort.js: Simplify Array.isSorted() and add doctests

As discussed at TheAlgorithms#164 (comment)

Also related to add doctests as discussed in TheAlgorithms#142

* node -e "doctest('Sorts/BogoSort.js', {})"

* doctest --module Sorts Sorts/BogoSort.js

* Update nodejs.yml

* Update nodejs.yml

* npx doctest Sorts/BogoSort.js || true

* node_modules/doctest Sorts/BogoSort.js || true

* npx doctest Sorts/BogoSort.js

* updating DIRECTORY.md

* Ensure that build fail on bad test

* updating DIRECTORY.md

* Ready for review

* Add doctest to BucketSort.js

* updating DIRECTORY.md

* Update nodejs.yml

* updating DIRECTORY.md

* npx doctest Sorts/BogoSort.js Sorts/BucketSort.js

* updating DIRECTORY.md

* updating DIRECTORY.md

* Add Graph BFS algorithm (TheAlgorithms#169)

* Add Graph BFS algorithm

* updating DIRECTORY.md

* Fix failing tests

* updating DIRECTORY.md

* Fix further failing tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>

* updating DIRECTORY.md

* Re-orgainze files and folders in the repository (TheAlgorithms#172)

* Re-orgainze files and folders in the repository

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>

Co-authored-by: Alex Brown <[email protected]>
Co-authored-by: Wan Cheuk Lun <[email protected]>
Co-authored-by: Mohit Sharma <[email protected]>
Co-authored-by: Akarsh <[email protected]>
Co-authored-by: naor <[email protected]>
Co-authored-by: Anup Kumar Panwar <[email protected]>
Co-authored-by: Ravi Patel <[email protected]>
Co-authored-by: mavroian <[email protected]>
Co-authored-by: Libin Yang <[email protected]>
Co-authored-by: PatOnTheBack <[email protected]>
Co-authored-by: lakshyabatman <[email protected]>
Co-authored-by: Christian Clauss <[email protected]>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Nur69 <[email protected]>
Co-authored-by: Stepfen Shawn <[email protected]>
Co-authored-by: hmizz <[email protected]>
Co-authored-by: vinayak <[email protected]>
Co-authored-by: Juliano Nunes <[email protected]>
Co-authored-by: Muhammad Awais <[email protected]>
Co-authored-by: Nour B <[email protected]>
Co-authored-by: hmizz <[email protected]>
Co-authored-by: Novojit Saha <[email protected]>
Co-authored-by: Samarth Jain <[email protected]>
Co-authored-by: Satzyakiz <[email protected]>
Co-authored-by: Sahil Bansal <[email protected]>
Co-authored-by: Abhi Ramani <[email protected]>
Co-authored-by: John Law <[email protected]>
@nandanvasudevan
Copy link
Contributor

Can we update the package.json with DocTest?
It's really easy to use especially for everything in this repo.

cclauss added a commit that referenced this issue Aug 2, 2020
@cclauss
Copy link
Member

cclauss commented Aug 2, 2020

update the package.json with DocTest?

Done in 4cbdc9e

@nandanvasudevan
Copy link
Contributor

Decide if we should make doctests a requirement of new contributions to this repo.

I think we should.

Discuss how difficult it was to complete 1. and 2.

Shall I start writing a DocTest.md to help people add DocTests?

@remmaso
Copy link

remmaso commented Oct 2, 2020

In your document, open the “Insert” menu and then choose the “Drawing” command. In the Drawing window that opens, click the “Text Box” button on the toolbar at the top. Now, click and drag your mouse to create a text box in the space provided, and then add your desired tex

@marsonya
Copy link
Contributor

marsonya commented Oct 7, 2020

hey @itsvinayak, i would like to help with adding doctest across the codebase. i checked out the two doctest implementations by @cclauss. the implementation style is clear to me.

do i start adding pr referencing this issue for every file i implement doctest?

@cclauss
Copy link
Member

cclauss commented Oct 7, 2020

Open pull requests, not issues. It is OK to refer to this issue. Only one file per PR so they are easy to review and land.

@marsonya
Copy link
Contributor

marsonya commented Oct 7, 2020

understood. i will get to work right away.
thanks @cclauss

@itsvinayak
Copy link
Member Author

hey, @marsonya can you help me with this #461 issue

@marsonya
Copy link
Contributor

marsonya commented Oct 12, 2020

hey, @marsonya can you help me with this #461 issue

sure!
I will create a documentation for doctest.
Getting started right away.

Question.
Do I add the documentation to CONTRIBUTING.md or create a new file?

@itsvinayak
Copy link
Member Author

itsvinayak commented Oct 12, 2020

@marsonya thanks
Add it to CONTRIBUTING.md itself

@sukhpreetsekhon
Copy link
Contributor

raised PR for doctest #502. Please review. Thanks!

Khez added a commit to Khez/Javascript that referenced this issue Oct 30, 2020
Khez added a commit to Khez/Javascript that referenced this issue Oct 30, 2020
Khez added a commit to Khez/Javascript that referenced this issue Oct 30, 2020
@Khez
Copy link
Contributor

Khez commented Oct 31, 2020

@cclauss Can I keep on adding doctests in this format ? Already done a couple of the String files with #532 #533 #534

Anything I need to change going forward with the rest of the files ?

I saw some of the algorithms have .test.js files, do we update them to doctest ?

@marsonya
Copy link
Contributor

marsonya commented Nov 2, 2020

hey, @marsonya can you help me with this #461 issue

Apologies for the delay. I have added doctest contribution guidelines. Kindly take a look and let me know if it works or if it needs ant changes.
Here's the PR #546

marsonya added a commit that referenced this issue Jan 20, 2021
#142 #461 Adding Doctests to String/ReverseString.js
marsonya added a commit that referenced this issue Jan 20, 2021
#142 #461 Adding Doctests to String/ReverseWords.js
marsonya added a commit that referenced this issue Jan 22, 2021
#142 #461 Adding Doctests to String/ValidateEmail.js
@mhihasan
Copy link
Contributor

mhihasan commented Jun 7, 2021

Some files have jest tests. Should we remove those jest tests and add doctest instead? Because, current doctest version is throwing error on export statement, though next release might fix this

This was referenced Jun 8, 2021
@cclauss
Copy link
Member

cclauss commented Jun 8, 2021

Please do not remove tests. Contributors should have the freedom to choose to test with doctest or jest. Contibutors should not have the freedom to have no tests at all.

@raklaptudirm
Copy link
Member

@cclauss We still haven't settled on the issues of doctests failing because some files have none.

@Ameya101
Copy link

Add it in Contributing.md dont create a new file

@defaude
Copy link
Contributor

defaude commented Oct 5, 2021

@raklaptudirm I recommend we close this issue in favour of #742

@raklaptudirm raklaptudirm added wontfix Will not be fixed or is a feature and removed feature Adds a new feature help wanted Needs to be worked on labels Oct 5, 2021
Star-dev325 pushed a commit to Star-dev325/allio-javascript-tutorial-algorithm that referenced this issue Apr 1, 2022
mariannepara added a commit to mariannepara/JavaScript that referenced this issue Apr 20, 2022
ferranm99 added a commit to ferranm99/JavaScript--RWC that referenced this issue May 20, 2022
patrickm68 added a commit to patrickm68/JavaScript that referenced this issue Dec 1, 2022
vectorcrown pushed a commit to vectorcrown/javascript that referenced this issue Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Will not be fixed or is a feature
Projects
None yet
Development

No branches or pull requests