Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: recipes/next_prime.py

Issue 1421843006: Add simple depends_on API. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/recipes-py@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 from recipe_engine.recipe_api import Property
2 from recipe_engine import config
3 import math
4
5 DEPS = [
6 'recipe_engine/properties',
7 ]
8
9 PROPERTIES = {
10 'curr_prime': Property(kind=int),
11 }
12
13 RETURN_SCHEMA = config.ReturnSchema(
14 result=config.Single(int),
15 )
16
17 def is_prime(val):
18 if val % 2 == 0:
19 return False
20 for div in range(3, math.ceil(math.sqrt(val))):
21 if val % div == 0:
22 return False
23 return True
24
25 def RunSteps(api, curr_prime):
26 curr_prime += 2
27 while not is_prime(curr_prime):
28 curr_prime += 2
29
30 return RETURN_SCHEMA(result=curr_prime)
31
32 def GenTests(api):
33 yield (
34 api.test('basic') +
35 api.properties(curr_prime=3)
36 )
OLDNEW
« no previous file with comments | « recipes/list_primes.py ('k') | recipes/top.py » ('j') | recipes/top.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698