How to use doStuff method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

test_providers_base.py

Source:test_providers_base.py Github

copy

Full Screen

1import pytest2from sopel.tests import rawlist3from sopel_help import providers4TMP_CONFIG = """5[core]6owner = testnick7nick = TestBot8enable = coretasks, help9"""10CHANNEL_LINE = ':Test!test@example.com PRIVMSG #channel :.help'11QUERY_LINE = ':Test!test@example.com PRIVMSG TestBot :.help'12@pytest.fixture13def tmpconfig(configfactory):14 return configfactory('test.cfg', TMP_CONFIG)15@pytest.fixture16def mockbot(tmpconfig, botfactory):17 return botfactory.preloaded(tmpconfig, preloads=['help'])18def test_get_reply_method_default(mockbot, triggerfactory):19 provider = providers.Base()20 wrapped = triggerfactory.wrapper(mockbot, CHANNEL_LINE)21 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)22 assert recipient == '#channel'23 reply('Test message.', recipient)24 assert wrapped.backend.message_sent == rawlist(25 "PRIVMSG #channel :Test: Test message.",26 )27def test_get_reply_method_default_private(mockbot, triggerfactory):28 provider = providers.Base()29 wrapped = triggerfactory.wrapper(mockbot, QUERY_LINE)30 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)31 reply('Test message.', recipient)32 assert wrapped.backend.message_sent == rawlist(33 "PRIVMSG Test :Test message.",34 )35def test_get_reply_method_query(mockbot, triggerfactory):36 mockbot.settings.help.reply_method = 'query'37 provider = providers.Base()38 wrapped = triggerfactory.wrapper(mockbot, CHANNEL_LINE)39 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)40 assert recipient == 'Test'41 reply('Test message.', recipient)42 assert wrapped.backend.message_sent == rawlist(43 "PRIVMSG Test :Test message.",44 )45def test_get_reply_method_query_private(mockbot, triggerfactory):46 mockbot.settings.help.reply_method = 'query'47 provider = providers.Base()48 wrapped = triggerfactory.wrapper(mockbot, QUERY_LINE)49 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)50 assert recipient == 'Test'51 reply('Test message.', recipient)52 assert wrapped.backend.message_sent == rawlist(53 "PRIVMSG Test :Test message.",54 )55def test_get_reply_method_notice(mockbot, triggerfactory):56 mockbot.settings.help.reply_method = 'notice'57 provider = providers.Base()58 wrapped = triggerfactory.wrapper(mockbot, CHANNEL_LINE)59 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)60 assert recipient == 'Test'61 reply('Test message.', recipient)62 assert wrapped.backend.message_sent == rawlist(63 "NOTICE Test :Test message.",64 )65def test_get_reply_method_notice_private(mockbot, triggerfactory):66 mockbot.settings.help.reply_method = 'notice'67 provider = providers.Base()68 wrapped = triggerfactory.wrapper(mockbot, QUERY_LINE)69 reply, recipient = provider.get_reply_method(wrapped, wrapped._trigger)70 assert recipient == 'Test'71 reply('Test message.', recipient)72 assert wrapped.backend.message_sent == rawlist(73 "PRIVMSG Test :Test message.",74 )75def test_generate_help_commands():76 provider = providers.Base()77 result = list(provider.generate_help_commands({78 'group_name': ['command_a', 'command_b'],79 }))80 assert result == [81 'GROUP_NAME command_a command_b',82 ]83def test_generate_help_commands_many_groups():84 provider = providers.Base()85 result = list(provider.generate_help_commands({86 'group_a': ['command_a_a', 'command_a_b'],87 'group_c': ['command_c_a', 'command_c_b'],88 'group_b': ['command_b_a', 'command_b_b'],89 }))90 assert result == [91 'GROUP_A command_a_a command_a_b',92 'GROUP_B command_b_a command_b_b',93 'GROUP_C command_c_a command_c_b',94 ]95def test_generate_help_commands_many_lines():96 provider = providers.Base()97 result = list(provider.generate_help_commands({98 'group_a': ['command_a_a', 'command_a_b'],99 'group_c': ['command_c_a', 'command_c_b'],100 'group_b': [101 'command_b_a', 'command_b_b', 'command_b_c', 'command_b_d',102 'command_b_e', 'command_b_f', 'command_b_g', 'command_b_h',103 ],104 }))105 assert result == [106 'GROUP_A command_a_a command_a_b',107 'GROUP_B command_b_a command_b_b command_b_c command_b_d\n'108 ' command_b_e command_b_f command_b_g command_b_h',109 'GROUP_C command_c_a command_c_b',110 ]111def test_generate_help_command_empty():112 provider = providers.Base()113 result = provider.generate_help_command('dostuff', [], [])114 assert len(result) == 3, '3-value tuple expected as a result'115 head, body, usages = result116 assert head == 'Command "dostuff" has no help.'117 assert body == []118 assert usages == []119def test_generate_help_command_head_only():120 provider = providers.Base()121 head, body, usages = provider.generate_help_command('dostuff', [122 'dostuff: do something very usefull for the user'123 ], [])124 assert head == 'dostuff: do something very usefull for the user'125 assert body == []126 assert usages == []127def test_generate_help_command_no_usages():128 provider = providers.Base()129 head, body, usages = provider.generate_help_command('dostuff', [130 'dostuff: do something very usefull for the user',131 'Use dostuff command when you need it most.'132 ], [])133 assert head == 'dostuff: do something very usefull for the user'134 assert body == [135 'Use dostuff command when you need it most.',136 ]137 assert usages == []138def test_generate_help_command_one_example():139 provider = providers.Base()140 head, body, usages = provider.generate_help_command('dostuff', [141 'dostuff: do something very usefull for the user',142 'Use dostuff command when you need it most.'143 ], [144 '.dostuff',145 ])146 assert head == 'dostuff: do something very usefull for the user'147 assert body == [148 'Use dostuff command when you need it most.',149 ]150 assert usages == [151 'e.g. .dostuff',152 ]153def test_generate_help_command_two_example():154 provider = providers.Base()155 head, body, usages = provider.generate_help_command('dostuff', [156 'dostuff: do something very usefull for the user',157 'Use dostuff command when you need it most.'158 ], [159 '.dostuff',160 '.dostuff foo',161 ])162 assert head == 'dostuff: do something very usefull for the user'163 assert body == [164 'Use dostuff command when you need it most.',165 ]166 assert usages == [167 'e.g. .dostuff or .dostuff foo',168 ]169def test_generate_help_command():170 provider = providers.Base()171 head, body, usages = provider.generate_help_command('dostuff', [172 'dostuff: do something very usefull for the user',173 'Use dostuff command when you need it most.'174 ], [175 '.dostuff',176 '.dostuff foo',177 '.dostuff foo bar',178 ])179 assert head == 'dostuff: do something very usefull for the user'180 assert body == [181 'Use dostuff command when you need it most.',182 ]183 assert usages == [184 'e.g. .dostuff, .dostuff foo or .dostuff foo bar',185 ]186def test_send_help_commands(mockbot, triggerfactory):187 provider = providers.Base()188 provider.setup(mockbot)189 wrapper = triggerfactory.wrapper(190 mockbot, ':Test!test@example.com PRIVMSG #channel :.help')191 test_lines = [192 'GROUP_A command_a_a command_a_b',193 'GROUP_B command_b_a command_b_b command_b_c command_b_d\n'194 ' command_b_e command_b_f command_b_g command_b_h',195 'GROUP_C command_c_a command_c_b',196 ]197 provider.send_help_commands(wrapper, wrapper._trigger, test_lines)198 assert mockbot.backend.message_sent == rawlist(199 "PRIVMSG #channel :Test: I'll send you a list of commands in private.",200 "PRIVMSG Test :GROUP_A command_a_a command_a_b",201 "PRIVMSG Test :GROUP_B command_b_a command_b_b command_b_c command_b_d",202 "PRIVMSG Test : command_b_e command_b_f command_b_g command_b_h",203 "PRIVMSG Test :GROUP_C command_c_a command_c_b",204 )205def test_help_commands(mockbot, triggerfactory):206 provider = providers.Base()207 provider.setup(mockbot)208 wrapper = triggerfactory.wrapper(209 mockbot, ':Test!test@example.com PRIVMSG #channel :.help')210 provider.help_commands(wrapper, wrapper._trigger)211 assert mockbot.backend.message_sent[0] == rawlist(212 "PRIVMSG #channel :Test: I'll send you a list of commands in private.",213 )[0]214def test_help_commands_private(mockbot, triggerfactory):215 provider = providers.Base()216 provider.setup(mockbot)217 wrapper = triggerfactory.wrapper(218 mockbot, ':Test!test@example.com PRIVMSG %s :.help' % mockbot.nick)219 provider.help_commands(wrapper, wrapper._trigger)220 assert mockbot.backend.message_sent[0] == rawlist(221 "PRIVMSG Test :Here is my list of commands:",222 )[0]223def test_help_command(mockbot, triggerfactory):224 provider = providers.Base()225 provider.setup(mockbot)226 wrapper = triggerfactory.wrapper(227 mockbot, ':Test!test@example.com PRIVMSG #channel :.help test')228 mockbot.doc['test'] = ([229 'The command test docstring.',230 'Second line of docstring.',231 ], [232 '.test', '.test arg', '.test else',233 ]234 )235 provider.help_command(wrapper, wrapper._trigger, 'test')236 assert mockbot.backend.message_sent == rawlist(237 "PRIVMSG #channel :Test: The command test docstring.",238 "PRIVMSG #channel :Second line of docstring.",239 "PRIVMSG #channel :e.g. .test, .test arg or .test else",240 )241def test_help_command_private(mockbot, triggerfactory):242 provider = providers.Base()243 provider.setup(mockbot)244 wrapper = triggerfactory.wrapper(245 mockbot, ':Test!test@example.com PRIVMSG TestBot :.help test')246 mockbot.doc['test'] = ([247 'The command test docstring.',248 'Second line of docstring.',249 ], [250 '.test', '.test arg', '.test else',251 ]252 )253 provider.help_command(wrapper, wrapper._trigger, 'test')254 assert mockbot.backend.message_sent == rawlist(255 "PRIVMSG Test :The command test docstring.",256 "PRIVMSG Test :Second line of docstring.",257 "PRIVMSG Test :e.g. .test, .test arg or .test else",258 )259def test_help_command_too_long(mockbot, triggerfactory):260 provider = providers.Base()261 provider.setup(mockbot)262 wrapper = triggerfactory.wrapper(263 mockbot, ':Test!test@example.com PRIVMSG #channel :.help test')264 mockbot.doc['test'] = ([265 'The command test docstring.',266 'Second line of docstring.',267 'Third line of docstring.',268 'Fourth line of docstring.',269 ], [270 '.test', '.test arg', '.test else',271 ]272 )273 provider.help_command(wrapper, wrapper._trigger, 'test')274 assert mockbot.backend.message_sent == rawlist(275 "PRIVMSG #channel :Test: The help for command test is too long; "276 "I'm sending it to you in a private message.",277 "PRIVMSG Test :The command test docstring.",278 "PRIVMSG Test :Second line of docstring.",279 "PRIVMSG Test :Third line of docstring.",280 "PRIVMSG Test :Fourth line of docstring.",281 "PRIVMSG Test :e.g. .test, .test arg or .test else",282 )283def test_help_command_too_long_settings(mockbot, triggerfactory):284 """Test settings can override message length in lines for command help."""285 mockbot.settings.help.line_threshold = 5286 provider = providers.Base()287 provider.setup(mockbot)288 wrapper = triggerfactory.wrapper(289 mockbot, ':Test!test@example.com PRIVMSG #channel :.help test')290 mockbot.doc['test'] = ([291 'The command test docstring.',292 'Second line of docstring.',293 'Third line of docstring.',294 'Fourth line of docstring.',295 ], [296 '.test', '.test arg', '.test else',297 ]298 )299 provider.help_command(wrapper, wrapper._trigger, 'test')300 assert mockbot.backend.message_sent == rawlist(301 "PRIVMSG #channel :Test: The command test docstring.",302 "PRIVMSG #channel :Second line of docstring.",303 "PRIVMSG #channel :Third line of docstring.",304 "PRIVMSG #channel :Fourth line of docstring.",305 "PRIVMSG #channel :e.g. .test, .test arg or .test else",...

Full Screen

Full Screen

zambies.py

Source:zambies.py Github

copy

Full Screen

1#!/usr/bin/python2#Zambies game made by Jake Hansen in 20143import pygame, sys, time, random4from pygame.locals import *5pygame.init()6screen=pygame.display.set_mode((800,600),0,32)7pygame.display.set_caption("ZAAAAMBIES!!!")8top=pygame.image.load("guntop.png").convert()9bottom=pygame.image.load("gunbottom.png").convert()10backg=pygame.image.load("zambiesbackg.jpg").convert()11ammo=pygame.image.load("ammocount.jpg").convert()12menu=pygame.image.load("menu.jpg").convert()13lose=pygame.image.load("z_death.jpg").convert()14win=pygame.image.load("z_win.jpg").convert()15easy=pygame.image.load("level_easy.jpg").convert()16medium=pygame.image.load("level_medium.jpg").convert()17hard=pygame.image.load("level_hard.jpg").convert()18health=pygame.image.load("z_health.jpg").convert()19reloading=pygame.image.load("z_reloading.jpg").convert()20bean=True21go=False22shoot=False23shots=1224rel_time=025class player:26 def __init__(self,urlives):27 self.urlives=urlives28class zambies:29 def __init__(self,life,speed):30 zx=random.randint(50,750)31 loop=True32 timer=533 hits=034 self.speed=speed35 self.hits=hits36 self.timer=timer37 self.life=life38 self.zx=zx39 self.loop=loop40 def dostuff(self):41 if self.loop==True:42 if self.timer<=203:43 self.timer+=milliseconds/self.speed44 pygame.draw.rect(screen,(0,200,0),Rect((self.zx-self.timer/2+self.timer*.055,100+self.timer*.3),(self.timer*.9,self.timer*.8)))45 pygame.draw.rect(screen,(0,0,0),Rect((self.zx-self.timer/2,100+self.timer),(self.timer,self.timer*1.5)))46 pygame.draw.rect(screen,(0,200,0),Rect(((self.zx-self.timer/2)-self.timer/5,100+self.timer+self.timer/5),(self.timer/3,self.timer/3)))47 pygame.draw.rect(screen,(0,200,0),Rect(((self.zx-self.timer/2)+self.timer*.85,100+self.timer+self.timer/5),(self.timer/3,self.timer/3)))48 pygame.draw.rect(screen,(240,0,0),Rect((self.zx-self.timer/4+self.timer*.055,100+self.timer*.55),(self.timer*.1,self.timer*.1)))49 pygame.draw.rect(screen,(240,0,0),Rect((self.zx-self.timer/-15+self.timer*.055,100+self.timer*.55),(self.timer*.1,self.timer*.1)))50 51 if shoot==True: 52 if mx>=self.zx-self.timer/2+self.timer*.055 and mx<=(self.zx-self.timer/2+self.timer*.055)+self.timer*.9 and my>=100+self.timer*.3 and my<=(100+self.timer*.3)+self.timer*.8:53 self.life-=254 elif mx>=(self.zx-self.timer/2)-self.timer/5 and mx<=((self.zx-self.timer/2)-self.timer/5)+self.timer and my>=100+self.timer and my<=(100+self.timer)+self.timer*1.5:55 self.life-=156 57 if self.life<=0:58 self.loop=False59 if self.timer>=203:60 milliseconds2=clock.tick()61 self.hits+=milliseconds2/40.62 if self.hits>=3.5:63 you.urlives-=164 self.hits=065while bean==True:66 mx,my=pygame.mouse.get_pos()67 68 screen.blit(menu,(0,0))69 70 time.sleep(0.005)71 pygame.display.update()72 for event in pygame.event.get():73 if event.type==QUIT:74 pygame.quit()75 sys.exit()76 77 if event.type==MOUSEBUTTONDOWN: 78 if mx>=375 and mx<=450 and my>=150 and my<=170:79 you=player(20)80 zam1=zambies(10,100.)81 zam2=zambies(9,100.)82 zam3=zambies(9,100.)83 zam4=zambies(10,80.)84 zam5=zambies(9,80.)85 zam6=zambies(10,90.)86 zam7=zambies(10,90.)87 zam8=zambies(10,80.)88 zam9=zambies(10,80.)89 zam10=zambies(12,70.)90 zam11=zambies(12,70.)91 zam12=zambies(12,60.)92 zam13=zambies(12,60.)93 zam14=zambies(12,55.)94 zam15=zambies(14,55.)95 zam16=zambies(14,50.)96 zam17=zambies(14,50.)97 zam18=zambies(14,40.)98 zam19=zambies(16,40.)99 zam20=zambies(16,40.)100 zam21=zambies(14,40.)101 zam22=zambies(14,35.)102 zam23=zambies(14,30.)103 zam24=zambies(14,30.)104 105 level=easy106 bean=False107 go=True108 elif mx>=375 and mx<=450 and my>=175 and my<=195:109 you=player(15)110 zam1=zambies(10,100.)111 zam2=zambies(10,100.)112 zam3=zambies(10,100.)113 zam4=zambies(10,80.)114 zam5=zambies(12,80.)115 zam6=zambies(12,90.)116 zam7=zambies(12,90.)117 zam8=zambies(12,80.)118 zam9=zambies(12,80.)119 zam10=zambies(14,70.)120 zam11=zambies(14,80.)121 zam12=zambies(14,60.)122 zam13=zambies(14,60.)123 zam14=zambies(14,50.)124 zam15=zambies(14,50.)125 zam16=zambies(15,50.)126 zam17=zambies(14,40.)127 zam18=zambies(14,40.)128 zam19=zambies(16,35.)129 zam20=zambies(16,35.)130 zam21=zambies(16,35.)131 zam22=zambies(16,30.)132 zam23=zambies(18,30.)133 zam24=zambies(18,30.)134 135 level=medium136 bean=False137 go=True138 elif mx>=375 and mx<=450 and my>=200 and my<=220:139 you=player(12)140 zam1=zambies(12,100.)141 zam2=zambies(12,100.)142 zam3=zambies(12,100.)143 zam4=zambies(12,70.)144 zam5=zambies(12,70.)145 zam6=zambies(14,90.)146 zam7=zambies(14,90.)147 zam8=zambies(14,80.)148 zam9=zambies(14,60.)149 zam10=zambies(14,60.)150 zam11=zambies(16,80.)151 zam12=zambies(16,50.)152 zam13=zambies(16,50.)153 zam14=zambies(16,40.)154 zam15=zambies(16,40.)155 zam16=zambies(16,40.)156 zam17=zambies(18,40.)157 zam18=zambies(18,40.)158 zam19=zambies(18,40.)159 zam20=zambies(18,35.)160 zam21=zambies(18,35.)161 zam22=zambies(20,35.)162 zam23=zambies(20,30.)163 zam24=zambies(20,28.)164 165 level=hard166 bean=False167 go=True168pygame.mouse.set_visible(0)169clock=pygame.time.Clock()170while go==True: 171 mx,my=pygame.mouse.get_pos()172 milliseconds=clock.tick()173 screen.blit(backg,(0,0))174 zam1.dostuff()175 zam2.dostuff()176 if zam1.loop==False and zam2.loop==False:177 zam3.dostuff()178 zam4.dostuff()179 zam5.dostuff()180 if zam3.loop==False and zam4.loop==False and zam5.loop==False:181 zam6.dostuff()182 zam7.dostuff()183 if zam6.loop==False and zam7.loop==False:184 zam8.dostuff()185 zam9.dostuff()186 zam10.dostuff()187 if zam8.loop==False and zam9.loop==False and zam10.loop==False:188 zam11.dostuff()189 zam12.dostuff()190 zam13.dostuff()191 if zam11.loop==False and zam12.loop==False and zam13.loop==False:192 zam14.dostuff()193 zam15.dostuff()194 zam16.dostuff()195 zam17.dostuff()196 if zam14.loop==False and zam15.loop==False and zam16.loop==False and zam17.loop==False:197 zam18.dostuff()198 zam19.dostuff()199 zam20.dostuff()200 if zam18.loop==False and zam19.loop==False and zam20.loop==False:201 zam21.dostuff()202 zam22.dostuff()203 zam23.dostuff()204 zam24.dostuff()205 if zam21.loop==False and zam22.loop==False and zam23.loop==False and zam24.loop==False:206 screen.blit(backg,(0,0))207 screen.blit(health,(0,0))208 screen.blit(level,(0,30))209 pygame.draw.rect(screen,(200,0,0),Rect((63,1),(you.urlives*10,15)))210 screen.blit(win,(295,200))211 pygame.display.update()212 time.sleep(1.75)213 pygame.quit()214 sys.exit()215 shoot=False216 for event in pygame.event.get():217 if event.type==QUIT:218 pygame.quit()219 sys.exit()220 if event.type==MOUSEBUTTONDOWN:221 if event.button==1 and shots>=1:222 pygame.draw.circle(screen,(150,0,0),(mx,my),20,0)223 shoot=True224 shots-=1225 226 if event.button==3 and shots!=12:227 shots=0228 229 elif event.type!=MOUSEBUTTONUP:230 shoot=False231 if you.urlives<=0:232 screen.blit(backg,(0,0))233 screen.blit(lose,(280,200))234 screen.blit(level,(0,30))235 pygame.display.update()236 time.sleep(1.75)237 pygame.quit()238 sys.exit()239 if shots<=0:240 rel_time+=milliseconds/1000.241 if rel_time>=.65:242 shots=12243 rel_time=0244 245 screen.blit(top,(mx-16,my))246 screen.blit(bottom,(mx-12,my+31))247 pygame.draw.rect(screen,(40,40,40),Rect((mx-15,my-10),(10,10)))248 pygame.draw.rect(screen,(40,40,40),Rect((mx+7,my-10),(10,10)))249 pygame.draw.rect(screen,(0,0,0),Rect((mx-2,my-5),(5,5)))250 screen.blit(health,(0,0))251 screen.blit(level,(0,30))252 if shots==12:253 screen.blit(ammo,(788,2))254 screen.blit(ammo,(773,2))255 screen.blit(ammo,(758,2))256 screen.blit(ammo,(743,2))257 screen.blit(ammo,(728,2))258 screen.blit(ammo,(713,2))259 screen.blit(ammo,(698,2))260 screen.blit(ammo,(683,2))261 screen.blit(ammo,(668,2))262 screen.blit(ammo,(653,2))263 screen.blit(ammo,(638,2))264 screen.blit(ammo,(623,2))265 elif shots==11:266 screen.blit(ammo,(788,2))267 screen.blit(ammo,(773,2))268 screen.blit(ammo,(758,2))269 screen.blit(ammo,(743,2))270 screen.blit(ammo,(728,2))271 screen.blit(ammo,(713,2))272 screen.blit(ammo,(698,2))273 screen.blit(ammo,(683,2))274 screen.blit(ammo,(668,2))275 screen.blit(ammo,(653,2))276 screen.blit(ammo,(638,2))277 elif shots==10:278 screen.blit(ammo,(788,2))279 screen.blit(ammo,(773,2))280 screen.blit(ammo,(758,2))281 screen.blit(ammo,(743,2))282 screen.blit(ammo,(728,2))283 screen.blit(ammo,(713,2))284 screen.blit(ammo,(698,2))285 screen.blit(ammo,(683,2))286 screen.blit(ammo,(668,2))287 screen.blit(ammo,(653,2))288 elif shots==9:289 screen.blit(ammo,(788,2))290 screen.blit(ammo,(773,2))291 screen.blit(ammo,(758,2))292 screen.blit(ammo,(743,2))293 screen.blit(ammo,(728,2))294 screen.blit(ammo,(713,2))295 screen.blit(ammo,(698,2))296 screen.blit(ammo,(683,2))297 screen.blit(ammo,(668,2))298 elif shots==8:299 screen.blit(ammo,(788,2))300 screen.blit(ammo,(773,2))301 screen.blit(ammo,(758,2))302 screen.blit(ammo,(743,2))303 screen.blit(ammo,(728,2))304 screen.blit(ammo,(713,2))305 screen.blit(ammo,(698,2))306 screen.blit(ammo,(683,2))307 elif shots==7:308 screen.blit(ammo,(788,2))309 screen.blit(ammo,(773,2))310 screen.blit(ammo,(758,2))311 screen.blit(ammo,(743,2))312 screen.blit(ammo,(728,2))313 screen.blit(ammo,(713,2))314 screen.blit(ammo,(698,2))315 elif shots==6:316 screen.blit(ammo,(788,2))317 screen.blit(ammo,(773,2))318 screen.blit(ammo,(758,2))319 screen.blit(ammo,(743,2))320 screen.blit(ammo,(728,2))321 screen.blit(ammo,(713,2))322 elif shots==5:323 screen.blit(ammo,(788,2))324 screen.blit(ammo,(773,2))325 screen.blit(ammo,(758,2))326 screen.blit(ammo,(743,2))327 screen.blit(ammo,(728,2))328 elif shots==4:329 screen.blit(ammo,(788,2))330 screen.blit(ammo,(773,2))331 screen.blit(ammo,(758,2))332 screen.blit(ammo,(743,2))333 elif shots==3:334 screen.blit(ammo,(788,2))335 screen.blit(ammo,(773,2))336 screen.blit(ammo,(758,2))337 elif shots==2:338 screen.blit(ammo,(788,2))339 screen.blit(ammo,(773,2))340 elif shots==1:341 screen.blit(ammo,(788,2))342 elif shots==0:343 screen.blit(reloading,(695,2))344 345 pygame.draw.rect(screen,(200,0,0),Rect((63,1),(you.urlives*10,15)))346 time.sleep(0.005)...

Full Screen

Full Screen

test_required_types.py

Source:test_required_types.py Github

copy

Full Screen

...30 XFactory xFactory;31 INJECT(Y(XFactory xFactory))32 : xFactory(xFactory) {33 }34 void doStuff() {35 xFactory()->foo();36 }37 };38 fruit::Component<fruit::Required<XFactory>, Y> getYComponent() {39 return fruit::createComponent();40 }41 struct XImpl : public X {42 INJECT(XImpl()) = default;43 void foo() override {}44 };45 fruit::Component<XFactory> getXFactoryComponent() {46 return fruit::createComponent()47 .bind<X, XImpl>();48 }49 fruit::Component<Y> getComponent() {50 return fruit::createComponent()51 .install(getYComponent)52 .install(getXFactoryComponent);53 }54 int main() {55 fruit::Injector<Y> injector(getComponent);56 Y* y(injector);57 y->doStuff();58 }59 '''60 expect_success(COMMON_DEFINITIONS, source)61def test_required_annotated_success():62 source = '''63 struct X {64 virtual void foo() = 0;65 virtual ~X() = default;66 };67 using XFactory = std::function<std::unique_ptr<X>()>;68 using XFactoryAnnot = fruit::Annotated<Annotation1, XFactory>;69 struct Y {70 XFactory xFactory;71 INJECT(Y(ANNOTATED(Annotation1, XFactory) xFactory))72 : xFactory(xFactory) {73 }74 void doStuff() {75 xFactory()->foo();76 }77 };78 fruit::Component<fruit::Required<XFactoryAnnot>, Y> getYComponent() {79 return fruit::createComponent();80 }81 struct XImpl : public X {82 INJECT(XImpl()) = default;83 void foo() override {}84 };85 fruit::Component<XFactoryAnnot> getXFactoryComponent() {86 return fruit::createComponent()87 .bind<fruit::Annotated<Annotation1, X>, fruit::Annotated<Annotation1, XImpl>>();88 }89 fruit::Component<Y> getComponent() {90 return fruit::createComponent()91 .install(getYComponent)92 .install(getXFactoryComponent);93 }94 int main() {95 fruit::Injector<Y> injector(getComponent);96 Y* y(injector);97 y->doStuff();98 }99 '''100 expect_success(COMMON_DEFINITIONS, source)101def test_required_forward_declared_success():102 source = '''103 struct X;104 using XFactory = std::function<std::unique_ptr<X>()>;105 struct Y {106 XFactory xFactory;107 INJECT(Y(XFactory xFactory))108 : xFactory(xFactory) {109 }110 void doStuff();111 };112 fruit::Component<fruit::Required<XFactory>, Y> getYComponent() {113 return fruit::createComponent();114 }115 fruit::Component<XFactory> getXFactoryComponent();116 fruit::Component<Y> getComponent() {117 return fruit::createComponent()118 .install(getYComponent)119 .install(getXFactoryComponent);120 }121 int main() {122 fruit::Injector<Y> injector(getComponent);123 Y* y(injector);124 y->doStuff();125 }126 // We define X as late as possible, to make sure that all the above compiles even if X is only forward-declared.127 struct X {128 virtual void foo() = 0;129 virtual ~X() = default;130 };131 void Y::doStuff() {132 xFactory()->foo();133 }134 struct XImpl : public X {135 INJECT(XImpl()) = default;136 void foo() override {}137 };138 fruit::Component<XFactory> getXFactoryComponent() {139 return fruit::createComponent()140 .bind<X, XImpl>();141 }142 '''143 expect_success(COMMON_DEFINITIONS, source)144def test_required_annotated_forward_declared_success():145 source = '''146 struct X;147 using XFactory = std::function<std::unique_ptr<X>()>;148 using XFactoryAnnot = fruit::Annotated<Annotation1, XFactory>;149 struct Y {150 XFactory xFactory;151 INJECT(Y(ANNOTATED(Annotation1, XFactory) xFactory))152 : xFactory(xFactory) {153 }154 void doStuff();155 };156 fruit::Component<fruit::Required<XFactoryAnnot>, Y> getYComponent() {157 return fruit::createComponent();158 }159 fruit::Component<XFactoryAnnot> getXFactoryComponent();160 fruit::Component<Y> getComponent() {161 return fruit::createComponent()162 .install(getYComponent)163 .install(getXFactoryComponent);164 }165 int main() {166 fruit::Injector<Y> injector(getComponent);167 Y* y(injector);168 y->doStuff();169 }170 // We define X as late as possible, to make sure that all the above compiles even if X is only forward-declared.171 struct X {172 virtual void foo() = 0;173 virtual ~X() = default;174 };175 void Y::doStuff() {176 xFactory()->foo();177 }178 struct XImpl : public X {179 INJECT(XImpl()) = default;180 void foo() override {}181 };182 fruit::Component<XFactoryAnnot> getXFactoryComponent() {183 return fruit::createComponent()184 .bind<fruit::Annotated<Annotation1, X>, fruit::Annotated<Annotation1, XImpl>>();185 }186 '''187 expect_success(COMMON_DEFINITIONS, source)188def test_required_const_forward_declared_success():189 source = '''190 struct X;191 using XFactory = std::function<std::unique_ptr<X>()>;192 struct Y {193 XFactory xFactory;194 INJECT(Y(XFactory xFactory))195 : xFactory(xFactory) {196 }197 void doStuff();198 };199 fruit::Component<fruit::Required<const XFactory>, Y> getYComponent() {200 return fruit::createComponent();201 }202 fruit::Component<const XFactory> getXFactoryComponent();203 fruit::Component<Y> getComponent() {204 return fruit::createComponent()205 .install(getYComponent)206 .install(getXFactoryComponent);207 }208 int main() {209 fruit::Injector<Y> injector(getComponent);210 Y* y(injector);211 y->doStuff();212 }213 // We define X as late as possible, to make sure that all the above compiles even if X is only forward-declared.214 struct X {215 virtual void foo() = 0;216 virtual ~X() = default;217 };218 void Y::doStuff() {219 xFactory()->foo();220 }221 struct XImpl : public X {222 INJECT(XImpl()) = default;223 void foo() override {}224 };225 fruit::Component<const XFactory> getXFactoryComponent() {226 return fruit::createComponent()227 .bind<X, XImpl>();228 }229 '''230 expect_success(COMMON_DEFINITIONS, source)231def test_required_const_annotated_forward_declared_success():232 source = '''233 struct X;234 using XFactory = std::function<std::unique_ptr<X>()>;235 using ConstXFactoryAnnot = fruit::Annotated<Annotation1, const XFactory>;236 struct Y {237 XFactory xFactory;238 INJECT(Y(ANNOTATED(Annotation1, XFactory) xFactory))239 : xFactory(xFactory) {240 }241 void doStuff();242 };243 fruit::Component<fruit::Required<ConstXFactoryAnnot>, Y> getYComponent() {244 return fruit::createComponent();245 }246 fruit::Component<ConstXFactoryAnnot> getXFactoryComponent();247 fruit::Component<Y> getComponent() {248 return fruit::createComponent()249 .install(getYComponent)250 .install(getXFactoryComponent);251 }252 int main() {253 fruit::Injector<Y> injector(getComponent);254 Y* y(injector);255 y->doStuff();256 }257 // We define X as late as possible, to make sure that all the above compiles even if X is only forward-declared.258 struct X {259 virtual void foo() = 0;260 virtual ~X() = default;261 };262 void Y::doStuff() {263 xFactory()->foo();264 }265 struct XImpl : public X {266 INJECT(XImpl()) = default;267 void foo() override {}268 };269 fruit::Component<ConstXFactoryAnnot> getXFactoryComponent() {270 return fruit::createComponent()271 .bind<fruit::Annotated<Annotation1, X>, fruit::Annotated<Annotation1, XImpl>>();272 }273 '''274 expect_success(COMMON_DEFINITIONS, source)275if __name__== '__main__':276 main(__file__)

Full Screen

Full Screen

matrix.py

Source:matrix.py Github

copy

Full Screen

...38line14 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]39line15 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]40line16 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]41def doImage(line1,line2,line3,line4,line5,line6,line7,line8,line9,line10,line11,line12,line13,line14,line15,line16):42 doStuff(0,0,0,0,line8)43 doStuff(0,0,0,1,line12)44 doStuff(0,0,1,0,line4)45 doStuff(0,0,1,1,line14)46 doStuff(0,1,0,0,line6)47 doStuff(0,1,0,1,line10)48 doStuff(0,1,1,0,line2)49 doStuff(0,1,1,1,line15)50 doStuff(1,0,0,0,line7)51 doStuff(1,0,0,1,line11)52 doStuff(1,0,1,0,line3)53 doStuff(1,0,1,1,line13)54 doStuff(1,1,0,0,line5)55 doStuff(1,1,0,1,line9)56 doStuff(1,1,1,0,line1)57 doStuff(1,1,1,1,line16)58 59def cycleClock():60 CLK.high()61 CLK.low()62def writeState(pin, state):63 if state>=1:64 pin.high()65 else:66 pin.low()67 68def doStuff(a1, a2, a3, a4, line):69 writeState(A0, a1)70 writeState(A1, a2)71 writeState(A2, a3)72 writeState(A3, a4)73 cycleClock()74 writeState(AEin, 1)75 cycleClock()76 writeState(WEin, 1)77 78 cycleClock()79 writeState(WEin, 0)80 81 cycleClock()82 writeState(AEin, 0)...

Full Screen

Full Screen

matrix_serial.py

Source:matrix_serial.py Github

copy

Full Screen

...25uart = UART(0, 256000, parity=None, stop=1, bits=8, rx=Pin(17), tx=Pin(16))26uart.write("MATRIX TEST")27matrix=[]28def doImage(line1,line2,line3,line4,line5,line6,line7,line8,line9,line10,line11,line12,line13,line14,line15,line16):29 doStuff(0,0,0,0,line8)30 doStuff(0,0,0,1,line12)31 doStuff(0,0,1,0,line4)32 doStuff(0,0,1,1,line14)33 doStuff(0,1,0,0,line6)34 doStuff(0,1,0,1,line10)35 doStuff(0,1,1,0,line2)36 doStuff(0,1,1,1,line15)37 doStuff(1,0,0,0,line7)38 doStuff(1,0,0,1,line11)39 doStuff(1,0,1,0,line3)40 doStuff(1,0,1,1,line13)41 doStuff(1,1,0,0,line5)42 doStuff(1,1,0,1,line9)43 doStuff(1,1,1,0,line1)44 doStuff(1,1,1,1,line16)45 46def cycleClock():47 CLK.high()48 CLK.low()49def writeState(pin, state):50 if state==1:51 pin.high()52 else:53 pin.low()54 55def doStuff(a1, a2, a3, a4, line):56 writeState(A0, a1)57 writeState(A1, a2)58 writeState(A2, a3)59 writeState(A3, a4)60 cycleClock()61 writeState(AEin, 1)62 cycleClock()63 writeState(WEin, 1)64 65 cycleClock()66 writeState(WEin, 0)67 68 cycleClock()69 writeState(AEin, 0)...

Full Screen

Full Screen

super.py

Source:super.py Github

copy

Full Screen

1#! /usr/bin/env python32'''3Python `super` class is used to access the base class of a class.4'''5# The 'old way' was to call the parrent class directly, and pass an object - `self` explicitly6class OldBase:7 def dostuff(self):8 print('base doing stuff')9class OldDerived(OldBase):10 def dostuff(self):11 OldBase.dostuff(self)12 print('derived doing more stuff')13oldway = OldDerived()14oldway.dostuff()15# Using `super`16class Base:17 def dostuff(self):18 print('base doing stuff')19class Derived(Base):20 def dostuff(self):21 super(Derived, self).dostuff() # calls Base.dostuff(self)22 print('Derived doing more stuff')23class ShorterDerived(Base):24 def dostuff(self):25 super().dostuff() # calls Base.dostuff(self) - implicit arguments26 print('ShorterDerived doing stuff with shorter syntax')27# The shorter form is allowed within methods - the arguments are implicit.28# `super` can be used anywhere, but arguments are required outside of a method29sd = ShorterDerived()30super(sd.__class__, sd).dostuff() # prints 'base doing stuff'31# The second argument is also optional, when omitted `super` returns an unbounded type,32# this is usefull for class methods33class Pizza:34 def __init__(self, toppings):35 self.toppings = toppings36 def __repr__(self):37 return "Pizza with {}".format(' and '.join(self.toppings))38 @classmethod39 def recommend(cls):40 '''Recommend some pizza with arbitrary toppings,'''41 return cls(['spam', 'ham', 'eggs'])42class VikingPizza(Pizza):43 @classmethod44 def recommend(cls):45 '''Use same recommendation as super but add extra spam'''46 recommended = super(VikingPizza).recommend() # calls Pizza.recommend()47 recommended.toppings += ['spam']*548 return recommended49# for methods decorated with @classmethod `super` with no arguments is the same as...

Full Screen

Full Screen

500_build_addAbstract.py

Source:500_build_addAbstract.py Github

copy

Full Screen

1include("xx0_helpers.py")2def doStuff(s, numVertices, numEdges):3 dg = DG()4 dg.build().addAbstract(s)5 names = {}6 for v in dg.vertices:7 assert v.graph.name not in names8 names[v.graph.name] = v9 if numVertices is not None:10 assert dg.numVertices == numVertices11 assert len(names) == numVertices12 concat = ''.join(sorted(names))13 expect = ''.join(chr(ord('a') + i) for i in range(numVertices)) 14 assert expect == concat15 assert dg.numEdges == numEdges16 return dg, names17 18doStuff("a -> b", 2, 1)19doStuff("a <=> b", 2, 2)20doStuff("a + b -> a", 2, 1)21doStuff("2 a + b -> 3 c", 3, 1)22doStuff("a -> b b -> d + a d -> c c -> b", 4, 4)23# test null reactions24doStuff("a -> b b + c -> b + c c + d <=> c + d d -> e", 5, 4)25# test coefficient stuff26dg, names = doStuff("2a -> 2 b", None, 1)27assert dg.numVertices == 228assert list(sorted(names)) == ['2a', 'b']29msg = "Could not parse description of abstract derivations."30fail(lambda: DG().build().addAbstract(""), msg, err=InputError, isSubstring=True)31fail(lambda: DG().build().addAbstract("\x80"), msg, err=InputError, isSubstring=True)32fail(lambda: DG().build().addAbstract("42\x80"), msg, err=InputError, isSubstring=True)...

Full Screen

Full Screen

testthreading.py

Source:testthreading.py Github

copy

Full Screen

1import threading2import time3import PyTorch4import PyTorchHelpers5import numpy as np6#class MyClass(threading.Thread):7# def __init__(self, name):8# threading.Thread.__init__(self)9# self.name = name10# print('__init__', self.name)11# time.sleep(1)12## self.loop()13# def run(self):14# for i in range(30):15# print(self.name, i)16# time.sleep(1)17#pig = MyClass('pig')18#sheep = MyClass('sheep')19#dog = MyClass('dog')20#objs = []21#objs.append(pig)22#objs.append(sheep)23#objs.append(dog)24#for obj in objs:25# obj.start()26#for obj in objs:27# obj.join()28def dostuff(name):29 MyLuaClass = PyTorchHelpers.load_lua_class('testthreading.lua', 'MyLuaClass')30 print(name, 'dostuff start')31 obj = MyLuaClass(name)32 print('calling run', name)33 obj.run()34 print(name, 'dostuff done')35t = []36t.append(threading.Thread(target=dostuff, args=('pig',)))37t.append(threading.Thread(target=dostuff, args=('dog',)))38#t.append(threading.Thread(target=dostuff, args=('sheep',)))39for obj in t:40 obj.daemon = True41 obj.start()42#for obj in t:43# obj.join()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fastCheck = require("fast-check");2fastCheck.doStuff();3const fastCheck = require("fast-check");4fastCheck.doStuff();5const fastCheck = require("fast-check");6fastCheck.doStuff();7const fastCheck = require("fast-check");8fastCheck.doStuff();9const fastCheck = require("fast-check");10fastCheck.doStuff();11const fastCheck = require("fast-check");12fastCheck.doStuff();13const fastCheck = require("fast-check");14fastCheck.doStuff();15const fastCheck = require("fast-check");16fastCheck.doStuff();17const fastCheck = require("fast-check");18fastCheck.doStuff();19const fastCheck = require("fast-check");20fastCheck.doStuff();21const fastCheck = require("fast-check");22fastCheck.doStuff();23const fastCheck = require("fast-check");24fastCheck.doStuff();25const fastCheck = require("fast-check");26fastCheck.doStuff();27const fastCheck = require("fast-check");28fastCheck.doStuff();29const fastCheck = require("fast-check

Full Screen

Using AI Code Generation

copy

Full Screen

1const { doStuff } = require('fast-check-monorepo');2doStuff();3{4 "dependencies": {5 }6}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { doStuff } from 'fast-check-monorepo';2import { doStuff } from 'fast-check-monorepo';3import { doStuff } from 'fast-check-monorepo';4import { doStuff } from 'fast-check-monorepo';5import { doStuff } from 'fast-check-monorepo';6import { doStuff } from 'fast-check-monorepo';7import { doStuff } from 'fast-check-monorepo';8import { doStuff } from 'fast-check-monorepo';9import { doStuff } from 'fast-check-monorepo';10import { doStuff } from 'fast-check-monorepo';11import { doStuff } from 'fast-check-monorepo';12import { doStuff } from 'fast-check-monorepo';13import { doStuff } from 'fast-check-monorepo';14import { doStuff } from 'fast-check-monorepo';15import { doStuff } from 'fast-check-monorepo';16import { doStuff } from 'fast-check-monorepo';17import { doStuff } from 'fast-check-monorepo';

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2fc.doStuff();3const fc = require('fast-check');4fc.doStuff();5"resolutions": {6}7"scripts": {8}9"scripts": {10}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { doStuff } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.ts');2doStuff();3import { doStuff } from 'fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.ts';4doStuff();5I have tried to import the file in the following ways:6import { doStuff } from 'fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.ts';7import { doStuff } from 'fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic';8import { doStuff } from 'fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.ts';9import { doStuff } from 'fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.js';10However, none of them works. I also tried to use the following code to import the file:11const { doStuff } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.generic.ts');12SyntaxError: Cannot use import statement outside a module13I am not sure why jest is not able to import the file. The file is in the same directory as the test file. The test file is in the same directory as the package.json file. The package.json file is in the same directory as the node_modules folder. I tried to add the following code to jest.config.js file:14module.exports = {15};16I am not sure why jest is not able to import the file. Can anyone help me with this issue?

Full Screen

Using AI Code Generation

copy

Full Screen

1import { doStuff } from 'fast-check-monorepo';2describe('test', () => {3 it('should do stuff', () => {4 expect(doStuff()).toBe('stuff');5 });6});7module.exports = {8};9module.exports = function (config) {10 config.set({11 });12};13module.exports = function (config) {14 config.set({15 });16};17module.exports = function (config) {18 config.set({19 });20};21module.exports = {22};23module.exports = function (config) {24 config.set({25 });26};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');2const { doStuff } = new AsyncProperty();3doStuff();4const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');5const { doStuff } = new AsyncProperty();6doStuff();7const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');8const { doStuff } = new AsyncProperty();9doStuff();10const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');11const { doStuff } = new AsyncProperty();12doStuff();13const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');14const { doStuff } = new AsyncProperty();15doStuff();16const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');17const { doStuff } = new AsyncProperty();18doStuff();19const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');20const { doStuff } = new AsyncProperty();21doStuff();22const { AsyncProperty } = require('fast-check-monorepo/src/check/arbitrary/AsyncProperty.js');23const { doStuff } = new AsyncProperty();24doStuff();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful