-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from czgdp1807/list_01
Ported ``integration_tests/test_list_01.py`` from LPython and add support for ``std::vector`` in LC to compile it
- Loading branch information
Showing
3 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <vector> | ||
#include <iostream> | ||
|
||
std::vector<int32_t> fill_list_i32(int32_t size) { | ||
std::vector<int32_t> aarg = {0, 1, 2, 3, 4}; | ||
int32_t i; | ||
for( i = 0; i < size; i++) { | ||
aarg.push_back(i + 5); | ||
} | ||
return aarg; | ||
} | ||
|
||
#define assert(cond) if( !(cond) ) { \ | ||
exit(2); \ | ||
} \ | ||
|
||
void test_list_01() { | ||
std::vector<int32_t> a = {}; | ||
std::vector<double> f = {1.0, 2.0, 3.0, 4.0, 5.0}; | ||
int32_t i; | ||
|
||
a = fill_list_i32(10); | ||
|
||
for( i = 0; i < 10; i++ ) { | ||
f.push_back(float(i + 6)); | ||
} | ||
|
||
for( i = 0; i < 15; i++ ) { | ||
std::cout << f[i] << std::endl; | ||
} | ||
|
||
for( i = 0; i < 15; i++ ) { | ||
assert( (f[i] - double(a[i])) == 1.0 ); | ||
} | ||
|
||
for( i = 0; i < 15; i++ ) { | ||
f[i] = f[i] + double(i); | ||
} | ||
|
||
for( i = 0; i < 15; i++ ) { | ||
assert( (f[i] - double(a[i])) == (double(i) + 1.0) ); | ||
} | ||
} | ||
|
||
|
||
void tests() { | ||
test_list_01(); | ||
} | ||
|
||
int main() { | ||
tests(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters