French
Clemylia commited on
Commit
1961403
·
verified ·
1 Parent(s): 68be1dd

Upload 3 files

Browse files
Files changed (3) hide show
  1. test_package.c +76 -0
  2. test_packages.bzz +73 -0
  3. utils_package.rb +44 -0
test_package.c ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+ #include <string.h>
4
+ #include <math.h>
5
+
6
+ int main(int argc, char* argv[]) {
7
+ if (argc < 2) {
8
+ printf("🍯 Package C BzzBee chargé! Fonctions disponibles:\n");
9
+ printf("- puissance base exposant\n");
10
+ printf("- racine nombre\n");
11
+ printf("- premier nombre\n");
12
+ printf("- binaire nombre\n");
13
+ return 0;
14
+ }
15
+
16
+ char* operation = argv[1];
17
+
18
+ if (strcmp(operation, "puissance") == 0 && argc >= 4) {
19
+ double base = atof(argv[2]);
20
+ double exposant = atof(argv[3]);
21
+ double resultat = pow(base, exposant);
22
+ printf("🍯 Résultat: %.2f ^ %.2f = %.2f\n", base, exposant, resultat);
23
+ }
24
+ else if (strcmp(operation, "racine") == 0 && argc >= 3) {
25
+ double nombre = atof(argv[2]);
26
+ if (nombre >= 0) {
27
+ double resultat = sqrt(nombre);
28
+ printf("🍯 Résultat: √%.2f = %.2f\n", nombre, resultat);
29
+ } else {
30
+ printf("❌ Impossible de calculer la racine d'un nombre négatif!\n");
31
+ }
32
+ }
33
+ else if (strcmp(operation, "premier") == 0 && argc >= 3) {
34
+ int nombre = atoi(argv[2]);
35
+ int est_premier = 1;
36
+ if (nombre < 2) est_premier = 0;
37
+ for (int i = 2; i * i <= nombre; i++) {
38
+ if (nombre % i == 0) {
39
+ est_premier = 0;
40
+ break;
41
+ }
42
+ }
43
+ printf("🍯 Résultat: %d %s un nombre premier\n", nombre, est_premier ? "est" : "n'est pas");
44
+ }
45
+ else if (strcmp(operation, "binaire") == 0 && argc >= 3) {
46
+ int nombre = atoi(argv[2]);
47
+ if (nombre == 0) {
48
+ printf("🍯 Résultat: 0 en binaire = 0\n");
49
+ } else {
50
+ char binaire[33];
51
+ int index = 0;
52
+ int temp = abs(nombre);
53
+
54
+ while (temp > 0) {
55
+ binaire[index++] = (temp % 2) + '0';
56
+ temp /= 2;
57
+ }
58
+
59
+ printf("🍯 Résultat: %d en binaire = ", nombre);
60
+ if (nombre < 0) printf("-");
61
+ for (int i = index - 1; i >= 0; i--) {
62
+ printf("%c", binaire[i]);
63
+ }
64
+ printf("\n");
65
+ }
66
+ }
67
+ else if (strcmp(operation, "test") == 0) {
68
+ printf("🍯 Package C BzzBee testé avec succès!\n");
69
+ }
70
+ else {
71
+ printf("❌ Opération '%s' non reconnue!\n", operation);
72
+ printf("💡 Opérations disponibles: puissance, racine, premier, binaire, test\n");
73
+ }
74
+
75
+ return 0;
76
+ }
test_packages.bzz ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Test complet du système de packages BzzBee avec syntaxe étendue
3
+ # Démontre l'utilisation des différents langages et syntaxes
4
+
5
+ bzz BONJOUR
6
+ bzz R couleur jaune -> "=== TEST SYSTÈME DE PACKAGES BZZBEE V4.0 ==="
7
+
8
+ # Chargement des packages (optionnel si on utilise la syntaxe étendue)
9
+ bzz R couleur cyan -> "=== Chargement des packages ==="
10
+ bzz PACKAGE js -> math_package.js
11
+ bzz PACKAGE py -> string_package.py
12
+ bzz PACKAGE rb -> utils_package.rb
13
+ bzz PACKAGE c -> test_package.c
14
+
15
+ # Test 1: Syntaxe classique (utilise tous les packages chargés)
16
+ bzz R couleur vert -> "=== Test 1: Syntaxe classique ==="
17
+ pollen -> addition 15 25 : miel
18
+ pollen -> majuscule "bzzbee rocks" : miel
19
+ pollen -> date : miel
20
+
21
+ # Test 2: Syntaxe étendue avec spécification explicite du langage et fichier
22
+ bzz R couleur magenta -> "=== Test 2: Syntaxe étendue avec spécification ==="
23
+
24
+ # JavaScript spécifique
25
+ pollen -> multiplication 8 7 : miel [js math_package.js]
26
+ pollen -> factorielle 5 : miel [js math_package.js]
27
+
28
+ # Python spécifique
29
+ pollen -> inverse "Hello World" : miel [py string_package.py]
30
+ pollen -> voyelles "BzzBee Programming" : miel [py string_package.py]
31
+ pollen -> palindrome "radar" : miel [py string_package.py]
32
+
33
+ # Ruby spécifique
34
+ pollen -> hasard 1 100 : miel [rb utils_package.rb]
35
+ pollen -> fibonacci 10 : miel [rb utils_package.rb]
36
+ pollen -> couleur rouge "Texte coloré en Ruby!" : miel [rb utils_package.rb]
37
+
38
+ # C spécifique
39
+ pollen -> puissance 2 8 : miel [c test_package.c]
40
+ pollen -> racine 64 : miel [c test_package.c]
41
+ pollen -> premier 17 : miel [c test_package.c]
42
+ pollen -> binaire 42 : miel [c test_package.c]
43
+
44
+ # Test 3: Mélange des deux syntaxes
45
+ bzz R couleur bleu -> "=== Test 3: Mélange des syntaxes ==="
46
+ pollen -> addition 100 200 : miel
47
+ pollen -> longueur "Test de longueur" : miel [py string_package.py]
48
+ pollen -> soustraction 50 25 : miel [js math_package.js]
49
+
50
+ # Test 4: Gestion d'erreurs
51
+ bzz R couleur rouge -> "=== Test 4: Gestion d'erreurs ==="
52
+ bzz R console -> "Test avec langage inexistant:"
53
+ pollen -> test : miel [xx fichier_inexistant.xx]
54
+
55
+ bzz R console -> "Test avec fichier inexistant:"
56
+ pollen -> test : miel [py fichier_inexistant.py]
57
+
58
+ # Test 5: Packages BzzBee natifs
59
+ bzz R couleur cyan -> "=== Test 5: Package BzzBee natif ==="
60
+ bzz PACKAGE bzz -> art_package.bzz
61
+
62
+ bzz R couleur jaune -> "=== TESTS TERMINÉS ==="
63
+ bzz R console -> "🐝 Système de packages BzzBee v4.0 testé avec succès!"
64
+ bzz R console -> "✅ Syntaxe classique: pollen -> params : miel"
65
+ bzz R console -> "✅ Syntaxe étendue: pollen -> params : miel [langage fichier]"
66
+
67
+ # Syntaxe 2: Spécifier le langage et fichier explicitement
68
+ pollen -> addition 10 5 : miel [js math_package.js]
69
+ pollen -> majuscule "hello world" : miel [py string_package.py]
70
+ pollen -> fibonacci 10 : miel [rb utils_package.rb]
71
+ pollen -> pi : miel [jl science_package.jl]
72
+ pollen -> puissance 2 8 : miel [c test_package.c]
73
+ bzz AU REVOIR
utils_package.rb ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ #!/usr/bin/env ruby
3
+ # Package utilitaires en Ruby pour BzzBee
4
+ # Convention: pollen -> paramètres : miel
5
+
6
+ def process_command(command, *args)
7
+ case command
8
+ when "date"
9
+ puts "🍯 Date actuelle: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
10
+ when "hasard"
11
+ min = (args[0] || 1).to_i
12
+ max = (args[1] || 100).to_i
13
+ puts "🍯 Nombre aléatoire entre #{min} et #{max}: #{rand(min..max)}"
14
+ when "couleur"
15
+ color = args[0] || "blanc"
16
+ text = args[1] || "Texte coloré"
17
+ color_codes = {
18
+ "rouge" => "\033[31m",
19
+ "vert" => "\033[32m",
20
+ "jaune" => "\033[33m",
21
+ "bleu" => "\033[34m",
22
+ "reset" => "\033[0m"
23
+ }
24
+ puts "#{color_codes[color] || ''}#{text}#{color_codes['reset']}"
25
+ when "fibonacci"
26
+ n = (args[0] || 10).to_i
27
+ a, b = 0, 1
28
+ sequence = [a, b]
29
+ (2...n).each { sequence << sequence[-1] + sequence[-2] }
30
+ puts "🍯 Fibonacci(#{n}): #{sequence[0, n].join(', ')}"
31
+ else
32
+ puts """🐝 Package Utils BzzBee - Commandes disponibles:
33
+ - date
34
+ - hasard [min] [max]
35
+ - couleur [couleur] [texte]
36
+ - fibonacci [n]"""
37
+ end
38
+ end
39
+
40
+ if ARGV.length > 0
41
+ process_command(*ARGV)
42
+ else
43
+ puts "🍯 Package Utils BzzBee chargé! Utilisez: pollen -> commande paramètres : miel"
44
+ end