#ticket #1513 added asin() support

This commit is contained in:
Martin Ettl 2010-04-02 21:02:39 +02:00
commit f36af278d0
6 changed files with 20 additions and 22 deletions

View File

@ -55,11 +55,11 @@ double MathLib::toDoubleNumber(const std::string &str)
{
return std::strtoul(str.c_str(), '\0', 16);
}
// nullcheck
else if (str == "-0" || str == "-0.0" || str == "-0."
|| str == "+0" || str == "+0.0" || str == "+0.")
return 0.0;
// otherwise, convert to double
// nullcheck
else if (str == "-0" || str == "-0.0" || str == "-0."
|| str == "+0" || str == "+0.0" || str == "+0.")
return 0.0;
// otherwise, convert to double
std::istringstream istr(str.c_str());
double ret;
istr >> ret;

View File

@ -230,11 +230,8 @@ void Tokenizer::createTokens(std::istream &code)
// Read one byte at a time from code and create tokens
for (char ch = (char)code.get(); code.good(); ch = (char)code.get())
{
// We are not handling UTF and stuff like that. Code is supposed to plain simple text.
if (ch < 0)
continue;
// char/string..
// multiline strings are not handled. The preprocessor should handle that for us.
if (ch == '\'' || ch == '\"')
{
std::string line;
@ -247,9 +244,6 @@ void Tokenizer::createTokens(std::istream &code)
// Append token..
line += c;
if (c == '\n')
++lineno;
// Special sequence '\.'
if (special)
special = false;

View File

@ -71,7 +71,11 @@ public:
/**
* Create tokens from code.
* @param code input stream for code, same as what tokenize()
* The code must be preprocessed first:
* - multiline strings are not handled.
* - UTF in the code are not handled.
* - comments are not handled.
* @param code input stream for code
*/
void createTokens(std::istream &code);

View File

@ -116,9 +116,9 @@ private:
ASSERT_EQUALS(100 , MathLib::toLongNumber("+10.0E+1"));
ASSERT_EQUALS(-1 , MathLib::toLongNumber("-10.0E-1"));
// -----------------
// to double number:
// -----------------
// -----------------
// to double number:
// -----------------
ASSERT_EQUALS(10.0 , MathLib::toDoubleNumber("10"));
ASSERT_EQUALS(1000.0, MathLib::toDoubleNumber("10E+2"));
ASSERT_EQUALS(100.0 , MathLib::toDoubleNumber("1.0E+2"));
@ -135,7 +135,7 @@ private:
ASSERT_EQUALS(0.0 , MathLib::toDoubleNumber("+0."));
ASSERT_EQUALS(0.0 , MathLib::toDoubleNumber("-0.0"));
ASSERT_EQUALS(0.0 , MathLib::toDoubleNumber("+0.0"));
}
void isint()

View File

@ -2169,7 +2169,7 @@ private:
void mathfunctionCall1()
{
// log|log10
// log|log10
check("void foo()\n"
"{\n"
" std::cout << log(-2) << std::endl;\n"
@ -2230,7 +2230,7 @@ private:
"}");
TODO_ASSERT_EQUALS("", errout.str());
// acos
// acos
check("void foo()\n"
"{\n"
" std::cout << acos(1) << std::endl;\n"

View File

@ -43,9 +43,9 @@ protected:
void assertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual);
// the vars expected and actual need to be of type double, in order to avoid overflow of unsigned int
// e.g: ASSERT_EQUALS(-100.0, MathLib::toDoubleNumber("-1.0E+2")); whould not work without this.
void assertEquals(const char *filename, int linenr, double expected, double actual);
// the vars expected and actual need to be of type double, in order to avoid overflow of unsigned int
// e.g: ASSERT_EQUALS(-100.0, MathLib::toDoubleNumber("-1.0E+2")); whould not work without this.
void assertEquals(const char *filename, int linenr, double expected, double actual);
void todoAssertEquals(const char *filename, int linenr, const std::string &expected, const std::string &actual);
void todoAssertEquals(const char *filename, int linenr, unsigned int expected, unsigned int actual);