Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1a2e739
Fixed Issue #2042
assem2002 Mar 6, 2024
1adbddc
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
9fbd33e
Fix Warning :UnInitialized Vec
assem2002 Mar 6, 2024
0e14c0a
Fixed Issue #2042
assem2002 Mar 6, 2024
abcd34a
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
d7869b1
Fixed Issue #2042
assem2002 Mar 6, 2024
fa18fa7
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
7f85dc2
Default Arguments Implemented
assem2002 Mar 20, 2024
649b079
Default_argumets_implemented -removed other branch edit
assem2002 Mar 20, 2024
2902eea
setting loc makes a serious problem with complex()
assem2002 Mar 20, 2024
d3734db
handled function call without apearent argument passed
assem2002 Mar 20, 2024
f8b7c97
removed print statement usedin debugging
assem2002 Mar 20, 2024
c4ac4f3
added proper handling for nullptr values (they won't break the code a…
assem2002 Mar 20, 2024
1f3d26f
minor edit
assem2002 Mar 20, 2024
2cf7f4f
handled problem in creating c code (c dosen't support default arguments)
assem2002 Mar 21, 2024
35b5faa
Apply suggestions from code review
assem2002 Mar 24, 2024
a4d4d9c
applied code review changes (by Shaikh Ubaid)
assem2002 Mar 27, 2024
8ec5b38
added integration test for function default arguments
assem2002 Mar 27, 2024
3bb336c
added the 'def_func_01.py' to cmake testing list
assem2002 Mar 27, 2024
c7ff531
searching in symbol table for default arguments
assem2002 Apr 28, 2024
3423d9b
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 Apr 29, 2024
8748b42
Fixed Issue #2042
assem2002 Mar 6, 2024
be236f8
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
c286d39
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
b34a32b
added test_00
assem2002 Apr 29, 2024
11d1015
solved minor problem with previous commits
assem2002 Apr 29, 2024
ee07640
fixed some indentations in def_func_01.py test file
assem2002 Apr 29, 2024
fe4f162
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 Apr 30, 2024
ae0f7a0
Fixed Issue #2042
assem2002 Mar 6, 2024
233eddd
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
b86819a
Fixed issue #2042 - dispatched the type of list and dict
assem2002 Mar 6, 2024
d912b71
added semantic error for insufficient arguments + some edits
assem2002 May 2, 2024
4860230
resolved minor problems
assem2002 May 2, 2024
7ca1987
minor edit
assem2002 May 2, 2024
0fee905
Update src/lpython/semantics/python_ast_to_asr.cpp
assem2002 May 2, 2024
fc1d61c
added reference tests
assem2002 May 2, 2024
262041a
minor edit
assem2002 May 2, 2024
b8a14b1
minor edit
assem2002 May 2, 2024
a474734
Update integration_tests/CMakeLists.txt
assem2002 May 3, 2024
2549f0b
typo edits
assem2002 May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added integration test for function default arguments
  • Loading branch information
assem2002 authored and ubaidsk committed May 4, 2024
commit 8ec5b38157613fddb035bf69e37f8c3bcd41d6c0
68 changes: 68 additions & 0 deletions integration_tests/def_func_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from lpython import i32,i64

def factorial_1(x: i32, y:i32 =1) ->i32 :
if x <= 1:
return y
return x * factorial_1(x-1)

def factorial_2(x: i32, y:i32=3 ,z:i32 =2) ->i32:
if x ==4:
return x * y * z
return x * factorial_2(x-1)

def default_func(x : str ="Hello" ,y : str = " ", z : str = "World") ->str:
return x + y + z


def even_positons(iterator : i32 , to_add : str = "?")-> str:
if (iterator == 10): return ""

if iterator%2 == 0 :
return to_add + even_positons(iterator+1,"X")

return to_add +even_positons(iterator+1)



def test_all():

test_01 : i32 = factorial_1(5,0)
print("test_01 is =>",test_01)
assert test_01 == 120

test_02 : i32 = factorial_1(1,5555)
print("test_02 is =>",test_02)
assert test_02 == 5555

test_03 : i32 =factorial_2(5,99999,99999)
print("test_03 is =>",test_03)
assert test_03 == 120

test_04 : i32 = factorial_2(4,-1,100)
print("test_04 is =>",test_04)
assert test_04 == -400

test_05 :str = default_func()
print("test_05 is =>",test_05)
assert test_05 == "Hello World"

test_06 :str = default_func(y = "|||",x="Hi")
print("test_06 is =>",test_06)
assert test_06 == "Hi|||World"

test_07 : str = even_positons(0)
print("test_07 is =>",test_07)
assert test_07 == "?X?X?X?X?X"

test_08 : str = even_positons(0,"W")
print("test_08 is =>",test_08)
assert test_08 == "WX?X?X?X?X"

test_all()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test, @assem2002 do you mind using appropriate and consistent spacing for example my_func(x: i32 = 10, y: str = "abc") and print("test_09 is =>", test_09) .