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

String indexing #36

Merged
merged 2 commits into from
Nov 13, 2011
Merged

String indexing #36

merged 2 commits into from
Nov 13, 2011

Conversation

brad
Copy link
Member

@brad brad commented Nov 13, 2011

Will this work for string indexing? Worked well for me. I was able to loop through a string using len() and echo individual characters accessed using [i].

@kintel
Copy link
Member

kintel commented Nov 13, 2011

To elaborate on tests:
I can do this myself, but it would be good training in writing patches which can be merged directly :)

A successful test of a feature like this would be to write an .scad script stress testing of the feature with different legal, illegal and border-line cases, then echo()'ing the results. The test file would go into tests/scad/misc/<mytest.scad>, and the test should be added to the echotest in tests/CMakeLists.txt.
Now, in tests:
$ cmake .
$ make
$ ctest -R echotest_mytest
[ should fail ]
$ cat echotest-output/echotest_mytest.txt
[ manually verify that the output is correct and fix any issues until it is ok ]
$ TEST_GENERATE=1 ctest -R echotest_mytest
[ should pass ]
$ ctest -R echotest_mytest
[ should pass ]
$ git add regression/echotest/mytest-expected.txt

@brad
Copy link
Member Author

brad commented Nov 13, 2011

Added some tests. Thanks for the detailed write up on the test framework, Marius. I was unable to "make all" (cgaltest complain about many undefined gl* references) but I did "make echotest" and was able to test that way.
I noticed one strange thing, but maybe it's by design. List indexing (vector and string) will accept any type of number and cast it to int. For example echo([0, 1][1.5]) prints "1". The cast rounds down to the nearest int. Is that by design?

@kintel
Copy link
Member

kintel commented Nov 13, 2011

Thanks!
OpenSCAD doesn't distinguish between floats and ints. Internally everything is a double. This may change, so it's good to have a test for it.

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

3 participants