//~ Function that test the user code
          
async function submit(){
    var test = editor.getValue()+`\n
import random as r

def EncryptVerif(text, key):
    result = ""
    for i in range(len(text)):
        char = text[i]
        if(char==" "):
            result+=" "
        elif (char.isupper()):
            result += chr((ord(char) + key-65) % 26 + 65)
        else:
            result += chr((ord(char) + key - 97) % 26 + 97)
    return result
  
def testEncrypte(x):
    Encrypt("",1)
    if(Encrypt("Hello world",2)!="Jgnnq yqtnf"):
        return False
    if(Encrypt("Scripted",9)!="Blarycnm"):
        return False
    for i in range(x):
        l=""
        cle=r.randint(1,26)
        for i in range(r.randint(1,10)):
            l+=chr(r.randint(97,122))
        if(Encrypt(l,cle)!=EncryptVerif(l,cle)):
            return False
    return True
  
print(testEncrypte(5))
    `;
    exec("print ('True')", "code"); 
    exec(test, "solution");
    result.innerHTML = "Test en cours...";
    await new Promise(r => setTimeout(r, 1500));
    check();
  }
  