Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion exercises/space-age/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Given an age in seconds, calculate how old someone would be on:

- Earth: orbital period 365.25 Earth days, or 31557600 seconds
- Mercury: orbital period 0.2408467 Earth years
- Venus: orbital period 0.61519726 Earth years
- Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds
- Mars: orbital period 1.8808158 Earth years
- Jupiter: orbital period 11.862615 Earth years
- Saturn: orbital period 29.447498 Earth years
Expand Down
16 changes: 8 additions & 8 deletions exercises/space-age/lib/example.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class SpaceAge {
/// A Mapping of planet as a `String` to corresponding class
Map<String, Planet> planets = {
"Earth": Earth(),
"Mercury": Mercury(),
"Venus": Venus(),
"Mars": Mars(),
"Jupiter": Jupiter(),
"Saturn": Saturn(),
"Uranus": Uranus(),
"Neptune": Neptune(),
'Earth': Earth(),
'Mercury': Mercury(),
'Venus': Venus(),
'Mars': Mars(),
'Jupiter': Jupiter(),
'Saturn': Saturn(),
'Uranus': Uranus(),
'Neptune': Neptune(),
};

/// Returns age in years on given [planet]
Expand Down
1 change: 1 addition & 0 deletions exercises/space-age/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: 'space_age'
version: 1.2.0
environment:
sdk: '>=2.0.0 <3.0.0'
dev_dependencies:
Expand Down
38 changes: 19 additions & 19 deletions exercises/space-age/test/space_age_test.dart
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import 'package:test/test.dart';
import 'package:space_age/space_age.dart';
import 'package:test/test.dart';

final SpaceAge spaceAge = SpaceAge();
final spaceAge = SpaceAge();

void main() {
group("SpaceAge", ageOnPlanetTests);
group('SpaceAge', ageOnPlanetTests);
}

void ageOnPlanetTests() {
test("age on Earth", () {
expect(spaceAge.age(planet: "Earth", seconds: 1000000000), equals(31.69));
test('age on Earth', () {
expect(spaceAge.age(planet: 'Earth', seconds: 1000000000), equals(31.69));
}, skip: false);

test("age on Mercury", () {
expect(spaceAge.age(planet: "Mercury", seconds: 2134835688), equals(280.88));
test('age on Mercury', () {
expect(spaceAge.age(planet: 'Mercury', seconds: 2134835688), equals(280.88));
}, skip: true);

test("age on Venus", () {
expect(spaceAge.age(planet: "Venus", seconds: 189839836), equals(9.78));
test('age on Venus', () {
expect(spaceAge.age(planet: 'Venus', seconds: 189839836), equals(9.78));
}, skip: true);

test("age on Mars", () {
expect(spaceAge.age(planet: "Mars", seconds: 2329871239), equals(39.25));
test('age on Mars', () {
expect(spaceAge.age(planet: 'Mars', seconds: 2129871239), equals(35.88));
}, skip: true);

test("age on Jupiter", () {
expect(spaceAge.age(planet: "Jupiter", seconds: 901876382), equals(2.41));
test('age on Jupiter', () {
expect(spaceAge.age(planet: 'Jupiter', seconds: 901876382), equals(2.41));
}, skip: true);

test("age on Saturn", () {
expect(spaceAge.age(planet: "Saturn", seconds: 3000000000), equals(3.23));
test('age on Saturn', () {
expect(spaceAge.age(planet: 'Saturn', seconds: 2000000000), equals(2.15));
}, skip: true);

test("age on Uranus", () {
expect(spaceAge.age(planet: "Uranus", seconds: 3210123456), equals(1.21));
test('age on Uranus', () {
expect(spaceAge.age(planet: 'Uranus', seconds: 1210123456), equals(0.46));
}, skip: true);

test("age on Neptune", () {
expect(spaceAge.age(planet: "Neptune", seconds: 8210123456), equals(1.58));
test('age on Neptune', () {
expect(spaceAge.age(planet: 'Neptune', seconds: 1821023456), equals(0.35));
}, skip: true);
}