-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:drager/faker
- Loading branch information
Showing
8 changed files
with
1,108 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ main() { | |
faker.person.suffix(); | ||
// Sr. | ||
faker.lorem.sentence(); | ||
// Nec nam aliquam sem et | ||
} | ||
``` | ||
|
||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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,169 @@ | ||
const words = [ | ||
'a', | ||
'ac', | ||
'accumsan', | ||
'adipiscing', | ||
'aenean', | ||
'aliquam', | ||
'aliquet', | ||
'amet', | ||
'ante', | ||
'arcu', | ||
'at', | ||
'auctor', | ||
'augue', | ||
'bibendum', | ||
'blandit', | ||
'commodo', | ||
'condimentum', | ||
'congue', | ||
'consectetur', | ||
'consequat', | ||
'convallis', | ||
'cras', | ||
'cum', | ||
'curabitur', | ||
'cursus', | ||
'dapibus', | ||
'diam', | ||
'dictum', | ||
'dictumst', | ||
'dignissim', | ||
'dis', | ||
'dolor', | ||
'donec', | ||
'dui', | ||
'duis', | ||
'egestas', | ||
'eget', | ||
'eleifend', | ||
'elementum', | ||
'elit', | ||
'enim', | ||
'erat', | ||
'eros', | ||
'est', | ||
'et', | ||
'etiam', | ||
'eu', | ||
'euismod', | ||
'facilisi', | ||
'facilisis', | ||
'fames', | ||
'faucibus', | ||
'felis', | ||
'fermentum', | ||
'feugiat', | ||
'fringilla', | ||
'fusce', | ||
'gravida', | ||
'habitant', | ||
'habitasse', | ||
'hac', | ||
'hendrerit', | ||
'iaculis', | ||
'id', | ||
'imperdiet', | ||
'in', | ||
'integer', | ||
'interdum', | ||
'ipsum', | ||
'justo', | ||
'lacinia', | ||
'lacus', | ||
'laoreet', | ||
'lectus', | ||
'leo', | ||
'libero', | ||
'ligula', | ||
'lobortis', | ||
'lorem', | ||
'luctus', | ||
'maecenas', | ||
'magna', | ||
'magnis', | ||
'malesuada', | ||
'massa', | ||
'mattis', | ||
'mauris', | ||
'metus', | ||
'mi', | ||
'molestie', | ||
'mollis', | ||
'montes', | ||
'morbi', | ||
'mus', | ||
'nam', | ||
'nascetur', | ||
'natoque', | ||
'nec', | ||
'neque', | ||
'netus', | ||
'nibh', | ||
'nisi', | ||
'nisl', | ||
'non', | ||
'nulla', | ||
'nullam', | ||
'nunc', | ||
'odio', | ||
'orci', | ||
'ornare', | ||
'parturient', | ||
'pellentesque', | ||
'penatibus', | ||
'pharetra', | ||
'phasellus', | ||
'placerat', | ||
'platea', | ||
'porta', | ||
'porttitor', | ||
'posuere', | ||
'potenti', | ||
'praesent', | ||
'pretium', | ||
'proin', | ||
'pulvinar', | ||
'purus', | ||
'quam', | ||
'quis', | ||
'quisque', | ||
'rhoncus', | ||
'ridiculus', | ||
'risus', | ||
'sagittis', | ||
'sapien', | ||
'scelerisque', | ||
'sed', | ||
'sem', | ||
'semper', | ||
'senectus', | ||
'sit', | ||
'sociis', | ||
'sodales', | ||
'sollicitudin', | ||
'suscipit', | ||
'suspendisse', | ||
'tellus', | ||
'tempor', | ||
'tempus', | ||
'tincidunt', | ||
'tortor', | ||
'tristique', | ||
'turpis', | ||
'ullamcorper', | ||
'ultrices', | ||
'ultricies', | ||
'urna', | ||
'ut', | ||
'varius', | ||
'vel', | ||
'velit', | ||
'venenatis', | ||
'vestibulum', | ||
'vitae', | ||
'vivamus', | ||
'viverra', | ||
'volutpat', | ||
'vulputate', | ||
]; |
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,45 @@ | ||
import 'data/lorem/words.dart' as word_list; | ||
import 'data/lorem/sentences.dart' as sentence_list; | ||
import 'random_generator.dart'; | ||
|
||
class Lorem { | ||
const Lorem(); | ||
|
||
/// Generates a word. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// faker.lorem.word(); | ||
/// ``` | ||
String word() => random.element(word_list.words); | ||
|
||
/// Generates a list of random words. The number of words is determined | ||
/// by the `numberOfWords` parameter. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// faker.lorem.words(3); | ||
/// ``` | ||
List<String> words(numberOfWords) { | ||
return Iterable<int>.generate(numberOfWords).map((_) => word()).toList(); | ||
} | ||
|
||
/// Generates a random sentence. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// faker.lorem.sentence(); | ||
/// ``` | ||
String sentence() => random.element(sentence_list.sentences); | ||
|
||
/// Generates a list of random sentences. The size of the list of determined | ||
/// by the `numberOfSentences` parameter. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// faker.lorem.sentences(5); | ||
/// ``` | ||
List<String> sentences(numberOfSentences) { | ||
return Iterable<int>.generate(numberOfSentences).map((_) => word()).toList(); | ||
} | ||
} |
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
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,26 @@ | ||
import 'package:faker/faker.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
main() { | ||
group('Lorem', (){ | ||
group('words', () { | ||
test('should be able to generate single word', () { | ||
expect(faker.lorem.word(), matches(new RegExp(r'^[\w-^]+$'))); | ||
}); | ||
|
||
test('should be able to generate word list', () { | ||
expect(faker.lorem.words(3), hasLength(3)); | ||
}); | ||
}); | ||
|
||
group('senetences', () { | ||
test('should be able to generate sentence', () { | ||
expect(faker.lorem.sentence(), matches(new RegExp(r'^[\w^ ]+\.$'))); | ||
}); | ||
|
||
test('should be able to generate sentence list', () { | ||
expect(faker.lorem.sentences(3), hasLength(3)); | ||
}); | ||
}); | ||
}); | ||
} |