From 319f9e4de98237ab835553e30efa56e275590115 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 20 May 2011 16:01:50 -0600 Subject: [PATCH] Fix issues with trim() and with unit tests relying on certain line endings. --- include/chaiscript/dispatchkit/dispatchkit.hpp | 6 +++--- include/chaiscript/language/chaiscript_prelude.hpp | 4 ++-- unittests/function_introspection.chai | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index cf567a2..c87acd6 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -807,8 +807,8 @@ namespace chaiscript const std::vector lhsparamtypes = lhs->get_param_types(); const std::vector rhsparamtypes = rhs->get_param_types(); - const int lhssize = lhsparamtypes.size(); - const int rhssize = rhsparamtypes.size(); + const size_t lhssize = lhsparamtypes.size(); + const size_t rhssize = rhsparamtypes.size(); const Type_Info boxed_type = user_type(); const Type_Info boxed_pod_type = user_type(); @@ -843,7 +843,7 @@ namespace chaiscript - for (int i = 1; i < lhssize && i < rhssize; ++i) + for (size_t i = 1; i < lhssize && i < rhssize; ++i) { const Type_Info lt = lhsparamtypes[i]; const Type_Info rt = rhsparamtypes[i]; diff --git a/include/chaiscript/language/chaiscript_prelude.hpp b/include/chaiscript/language/chaiscript_prelude.hpp index c65b73c..04a4178 100644 --- a/include/chaiscript/language/chaiscript_prelude.hpp +++ b/include/chaiscript/language/chaiscript_prelude.hpp @@ -305,10 +305,10 @@ def string::find_last_not_of(list) : is_type(list, "string") { \n\ int(find_last_not_of(this, list, -1)); \n\ } \n\ def string::ltrim() { \n\ - drop_while(this, fun(x) { x == ' ' || x == '\t' }); \n\ + drop_while(this, fun(x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'}); \n\ } \n\ def string::rtrim() { \n\ - reverse(drop_while(reverse(this), fun(x) { x == ' ' || x == '\t' })); \n\ + reverse(drop_while(reverse(this), fun(x) { x == ' ' || x == '\t' || x == '\r' || x == '\n'})); \n\ } \n\ def string::trim() { \n\ ltrim(rtrim(this)); \n\ diff --git a/unittests/function_introspection.chai b/unittests/function_introspection.chai index bd8bc0b..5ad76fc 100644 --- a/unittests/function_introspection.chai +++ b/unittests/function_introspection.chai @@ -10,7 +10,7 @@ def test_function(a) // test_function tests assert_equal(test_function.get_arity(), 1); -assert_equal(test_function.get_annotation(), "#Test Function Description\n"); +assert_equal(trim(test_function.get_annotation()), "#Test Function Description"); assert_equal(test_function.get_contained_functions().size(), 0); assert_equal(test_function.get_param_types().size(), 2);