diff --git a/builtins.txt.dat b/builtins.txt.dat new file mode 100644 index 0000000..0f97a9c --- /dev/null +++ b/builtins.txt.dat @@ -0,0 +1,1112 @@ +integer llAbs( integer val ) +float llAcos( float val ) +void llAddToLandBanList( key avatar, float hours ) +void llAddToLandPassList( key avatar, float hours ) +void llAdjustSoundVolume( float volume ) +void llAllowInventoryDrop( integer add ) +float llAngleBetween( rotation a, rotation b ) +void llApplyImpulse( vector force, integer local ) +void llApplyRotationalImpulse( vector force, integer local ) +float llAsin( float val ) +float llAtan2( float y, float x ) +void llAttachToAvatar( integer attach_point ) +void llAttachToAvatarTemp( integer attach_point ) +key llAvatarOnLinkSitTarget( integer link ) +key llAvatarOnSitTarget( ) +rotation llAxes2Rot( vector fwd, vector left, vector up ) +rotation llAxisAngle2Rot( vector axis, float angle ) +integer llBase64ToInteger( string str ) +string llBase64ToString( string str ) +void llBreakAllLinks( ) +void llBreakLink( integer linknum ) +list llCSV2List( string src ) +list llCastRay( vector start, vector end, list params ) +integer llCeil( float val ) +void llClearCameraParams( ) +integer llClearLinkMedia( integer link, integer face ) +integer llClearPrimMedia( integer face ) +void llCloseRemoteDataChannel( key channel ) +float llCloud( vector offset ) +void llCollisionFilter( string name, key id, integer accept ) +void llCollisionSound( string impact_sound, float impact_volume ) +void llCollisionSprite( string impact_sprite ) +float llCos( float theta ) +void llCreateCharacter( list options ) +void llCreateLink( key target, integer parent ) +void llDeleteCharacter( ) +list llDeleteSubList( list src, integer start, integer end ) +string llDeleteSubString( string src, integer start, integer end ) +void llDetachFromAvatar( ) +vector llDetectedGrab( integer number ) +integer llDetectedGroup( integer number ) +key llDetectedKey( integer number ) +integer llDetectedLinkNumber( integer number ) +string llDetectedName( integer number ) +key llDetectedOwner( integer number ) +vector llDetectedPos( integer number ) +rotation llDetectedRot( integer number ) +vector llDetectedTouchBinormal( integer index ) +integer llDetectedTouchFace( integer index ) +vector llDetectedTouchNormal( integer index ) +vector llDetectedTouchPos( integer index ) +vector llDetectedTouchST( integer index ) +vector llDetectedTouchUV( integer index ) +integer llDetectedType( integer number ) +vector llDetectedVel( integer number ) +void llDialog( key avatar, string message, list buttons, integer chat_channel ) +void llDie( ) +string llDumpList2String( list src, string separator ) +integer llEdgeOfWorld( vector pos, vector dir ) +void llEjectFromLand( key avatar ) +void llEmail( string address, string subject, string message ) +string llEscapeURL( string url ) +rotation llEuler2Rot( vector v ) +void llEvade( key target, list options ) +void llExecCharacterCmd( integer cmd, list options ) +float llFabs( float val ) +void llFleeFrom( vector source, float radius, list options ) +integer llFloor( float val ) +void llForceMouselook( integer mouselook ) +float llFrand( float mag ) +key llGenerateKey( ) +vector llGetAccel( ) +integer llGetAgentInfo( key id ) +string llGetAgentLanguage( key avatar ) +list llGetAgentList( integer scope, list options ) +vector llGetAgentSize( key id ) +float llGetAlpha( integer face ) +float llGetAndResetTime( ) +string llGetAnimation( key id ) +list llGetAnimationList( key id ) +string llGetAnimationOverride( string anim_state ) +integer llGetAttached( ) +list llGetBoundingBox( key object ) +vector llGetCameraPos( ) +rotation llGetCameraRot( ) +vector llGetCenterOfMass( ) +list llGetClosestNavPoint( vector point, list options ) +vector llGetColor( integer face ) +key llGetCreator( ) +string llGetDate( ) +string llGetDisplayName( key id ) +float llGetEnergy( ) +string llGetEnv( string name ) +vector llGetForce( ) +integer llGetFreeMemory( ) +integer llGetFreeURLs( ) +float llGetGMTclock( ) +vector llGetGeometricCenter( ) +string llGetHTTPHeader( key request_id, string header ) +key llGetInventoryCreator( string item ) +key llGetInventoryKey( string name ) +string llGetInventoryName( integer type, integer number ) +integer llGetInventoryNumber( integer type ) +integer llGetInventoryPermMask( string item, integer mask ) +integer llGetInventoryType( string name ) +key llGetKey( ) +key llGetLandOwnerAt( vector pos ) +key llGetLinkKey( integer linknumber ) +list llGetLinkMedia( integer link, integer face, list params ) +string llGetLinkName( integer linknumber ) +integer llGetLinkNumber( ) +integer llGetLinkNumberOfSides( integer link ) +list llGetLinkPrimitiveParams( integer linknumber, list rules ) +integer llGetListEntryType( list src, integer index ) +integer llGetListLength( list src ) +vector llGetLocalPos( ) +rotation llGetLocalRot( ) +float llGetMass( ) +float llGetMassMKS( ) +float llGetMaxScaleFactor( ) +integer llGetMemoryLimit( ) +float llGetMinScaleFactor( ) +void llGetNextEmail( string address, string subject ) +key llGetNotecardLine( string name, integer line ) +key llGetNumberOfNotecardLines( string name ) +integer llGetNumberOfPrims( ) +integer llGetNumberOfSides( ) +string llGetObjectDesc( ) +list llGetObjectDetails( key id, list params ) +float llGetObjectMass( key id ) +string llGetObjectName( ) +integer llGetObjectPermMask( integer mask ) +integer llGetObjectPrimCount( key object_id ) +vector llGetOmega( ) +key llGetOwner( ) +key llGetOwnerKey( key id ) +list llGetParcelDetails( vector pos, list params ) +integer llGetParcelFlags( vector pos ) +integer llGetParcelMaxPrims( vector pos, integer sim_wide ) +string llGetParcelMusicURL( ) +integer llGetParcelPrimCount( vector pos, integer category, integer sim_wide ) +list llGetParcelPrimOwners( vector pos ) +integer llGetPermissions( ) +key llGetPermissionsKey( ) +list llGetPhysicsMaterial( ) +vector llGetPos( ) +list llGetPrimMediaParams( integer face, list params ) +list llGetPrimitiveParams( list params ) +integer llGetRegionAgentCount( ) +vector llGetRegionCorner( ) +float llGetRegionFPS( ) +integer llGetRegionFlags( ) +string llGetRegionName( ) +float llGetRegionTimeDilation( ) +vector llGetRootPosition( ) +rotation llGetRootRotation( ) +rotation llGetRot( ) +integer llGetSPMaxMemory( ) +vector llGetScale( ) +string llGetScriptName( ) +integer llGetScriptState( string name ) +float llGetSimStats( integer stat_type ) +string llGetSimulatorHostname( ) +integer llGetStartParameter( ) +list llGetStaticPath( vector start, vector end, float radius, list params ) +integer llGetStatus( integer status ) +string llGetSubString( string src, integer start, integer end ) +vector llGetSunDirection( ) +string llGetTexture( integer face ) +vector llGetTextureOffset( integer face ) +float llGetTextureRot( integer side ) +vector llGetTextureScale( integer side ) +float llGetTime( ) +float llGetTimeOfDay( ) +string llGetTimestamp( ) +vector llGetTorque( ) +integer llGetUnixTime( ) +integer llGetUsedMemory( ) +string llGetUsername( key id ) +vector llGetVel( ) +float llGetWallclock( ) +void llGiveInventory( key destination, string inventory ) +void llGiveInventoryList( key target, string folder, list inventory ) +integer llGiveMoney( key destination, integer amount ) +void llGodLikeRezObject( key inventory, vector pos ) +float llGround( vector offset ) +vector llGroundContour( vector offset ) +vector llGroundNormal( vector offset ) +void llGroundRepel( float height, integer water, float tau ) +vector llGroundSlope( vector offset ) +key llHTTPRequest( string url, list parameters, string body ) +void llHTTPResponse( key request_id, integer status, string body ) +string llInsertString( string dst, integer position, string src ) +void llInstantMessage( key user, string message ) +string llIntegerToBase64( integer number ) +list llJson2List( string json ) +string llJsonGetValue( string json, list specifiers ) +string llJsonSetValue( string json, list specifiers, string value ) +string llJsonValueType( string json, list specifiers ) +string llKey2Name( key id ) +void llLinkParticleSystem( integer linknumber, list rules ) +void llLinkSitTarget( integer link, vector offset, rotation rot ) +string llList2CSV( list src ) +float llList2Float( list src, integer index ) +integer llList2Integer( list src, integer index ) +string llList2Json( string type, list values ) +key llList2Key( list src, integer index ) +list llList2List( list src, integer start, integer end ) +list llList2ListStrided( list src, integer start, integer end, integer stride ) +rotation llList2Rot( list src, integer index ) +string llList2String( list src, integer index ) +vector llList2Vector( list src, integer index ) +integer llListFindList( list src, list test ) +list llListInsertList( list dest, list src, integer start ) +list llListRandomize( list src, integer stride ) +list llListReplaceList( list dest, list src, integer start, integer end ) +list llListSort( list src, integer stride, integer ascending ) +float llListStatistics( integer operation, list src ) +integer llListen( integer channel, string name, key id, string msg ) +void llListenControl( integer number, integer active ) +void llListenRemove( integer number ) +void llLoadURL( key avatar, string message, string url ) +float llLog( float val ) +float llLog10( float val ) +void llLookAt( vector target, float strength, float damping ) +void llLoopSound( string sound, float volume ) +void llLoopSoundMaster( string sound, float volume ) +void llLoopSoundSlave( string sound, float volume ) +string llMD5String( string src, integer nonce ) +void llMakeExplosion( integer particles, float scale, float vel, float lifetime, float arc, string texture, vector offset ) +void llMakeFire( integer particles, float scale, float vel, float lifetime, float arc, string texture, vector offset ) +void llMakeFountain( integer particles, float scale, float vel, float lifetime, float arc, integer bounce, string texture, vector offset, float bounce_offset ) +void llMakeSmoke( integer particles, float scale, float vel, float lifetime, float arc, string texture, vector offset ) +integer llManageEstateAccess( integer action, key id ) +void llMapDestination( string simname, vector pos, vector look_at ) +void llMessageLinked( integer linknum, integer num, string str, key id ) +void llMinEventDelay( float delay ) +integer llModPow( integer a, integer b, integer c ) +void llModifyLand( integer action, integer brush ) +void llMoveToTarget( vector target, float tau ) +void llNavigateTo( vector point, list options ) +void llOffsetTexture( float u, float v, integer face ) +void llOpenRemoteDataChannel( ) +integer llOverMyLand( key id ) +void llOwnerSay( string msg ) +void llParcelMediaCommandList( list command ) +list llParcelMediaQuery( list query ) +list llParseString2List( string src, list separators, list spacers ) +list llParseStringKeepNulls( string src, list separators, list spacers ) +void llParticleSystem( list rules ) +void llPassCollisions( integer pass ) +void llPassTouches( integer pass ) +void llPatrolPoints( list points, list options ) +void llPlaySound( string sound, float volume ) +void llPlaySoundSlave( string sound, float volume ) +void llPointAt( vector pos ) +float llPow( float base, float exponent ) +void llPreloadSound( string sound ) +void llPursue( key target, list options ) +void llPushObject( key id, vector impulse, vector ang_impulse, integer local ) +void llRefreshPrimURL( ) +void llRegionSay( integer channel, string msg ) +void llRegionSayTo( key target, integer channel, string msg ) +void llReleaseCamera( key avatar ) +void llReleaseControls( ) +void llReleaseURL( string url ) +void llRemoteDataReply( key channel, key message_id, string sdata, integer idata ) +void llRemoteDataSetRegion( ) +void llRemoteLoadScript( key target, string name, integer running, integer start_param ) +void llRemoteLoadScriptPin( key target, string name, integer pin, integer running, integer start_param ) +void llRemoveFromLandBanList( key avatar ) +void llRemoveFromLandPassList( key avatar ) +void llRemoveInventory( string item ) +void llRemoveVehicleFlags( integer flags ) +key llRequestAgentData( key id, integer data ) +key llRequestDisplayName( key id ) +key llRequestInventoryData( string name ) +void llRequestPermissions( key agent, integer perm ) +key llRequestSecureURL( ) +key llRequestSimulatorData( string simulator, integer data ) +key llRequestURL( ) +key llRequestUsername( key id ) +void llResetAnimationOverride( string anim_state ) +void llResetLandBanList( ) +void llResetLandPassList( ) +void llResetOtherScript( string name ) +void llResetScript( ) +void llResetTime( ) +integer llReturnObjectsByID( list objects ) +integer llReturnObjectsByOwner( key owner, integer scope ) +void llRezAtRoot( string inventory, vector pos, vector vel, rotation rot, integer param ) +void llRezObject( string inventory, vector pos, vector vel, rotation rot, integer param ) +float llRot2Angle( rotation rot ) +vector llRot2Axis( rotation rot ) +vector llRot2Euler( rotation q ) +vector llRot2Fwd( rotation q ) +vector llRot2Left( rotation q ) +vector llRot2Up( rotation q ) +rotation llRotBetween( vector v1, vector v2 ) +void llRotLookAt( rotation target, float strength, float damping ) +integer llRotTarget( rotation rot, float error ) +void llRotTargetRemove( integer number ) +void llRotateTexture( float angle, integer face ) +integer llRound( float val ) +string llSHA1String( string src ) +integer llSameGroup( key id ) +void llSay( integer channel, string msg ) +integer llScaleByFactor( float scaling_factor ) +void llScaleTexture( float u, float v, integer face ) +integer llScriptDanger( vector pos ) +void llScriptProfiler( integer flags ) +key llSendRemoteData( key channel, string dest, integer idata, string sdata ) +void llSensor( string name, key id, integer type, float range, float arc ) +void llSensorRemove( ) +void llSensorRepeat( string name, key id, integer type, float range, float arc, float rate ) +void llSetAlpha( float alpha, integer face ) +void llSetAngularVelocity( vector angular_velocity, integer local ) +void llSetAnimationOverride( string anim_state, string anim ) +void llSetBuoyancy( float buoyancy ) +void llSetCameraAtOffset( vector offset ) +void llSetCameraEyeOffset( vector offset ) +void llSetCameraParams( list rules ) +void llSetClickAction( integer action ) +void llSetColor( vector color, integer face ) +void llSetContentType( key request_id, integer content_type ) +void llSetDamage( float damage ) +void llSetForce( vector force, integer local ) +void llSetForceAndTorque( vector force, vector torque, integer local ) +void llSetHoverHeight( float height, integer water, float tau ) +void llSetInventoryPermMask( string item, integer mask, integer value ) +void llSetKeyframedMotion( list keyframes, list options ) +void llSetLinkAlpha( integer linknumber, float alpha, integer face ) +void llSetLinkCamera( integer link, vector eye, vector at ) +void llSetLinkColor( integer linknumber, vector color, integer face ) +integer llSetLinkMedia( integer link, integer face, list params ) +void llSetLinkPrimitiveParams( integer linknumber, list rules ) +void llSetLinkPrimitiveParamsFast( integer linknumber, list rules ) +void llSetLinkTexture( integer linknumber, string texture, integer face ) +void llSetLinkTextureAnim( integer link, integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate ) +void llSetLocalRot( rotation rot ) +integer llSetMemoryLimit( integer limit ) +void llSetObjectDesc( string desc ) +void llSetObjectName( string name ) +void llSetObjectPermMask( integer mask, integer value ) +void llSetParcelMusicURL( string url ) +void llSetPayPrice( integer price, list quick_pay_buttons ) +void llSetPhysicsMaterial( integer flags, float gravity_multiplier, float restitution, float friction, float density ) +void llSetPos( vector pos ) +integer llSetPrimMediaParams( integer face, list params ) +void llSetPrimURL( string url ) +void llSetPrimitiveParams( list rules ) +integer llSetRegionPos( vector pos ) +void llSetRemoteScriptAccessPin( integer pin ) +void llSetRot( rotation rot ) +void llSetScale( vector scale ) +void llSetScriptState( string name, integer run ) +void llSetSitText( string text ) +void llSetSoundQueueing( integer queue ) +void llSetSoundRadius( float radius ) +void llSetStatus( integer status, integer value ) +void llSetText( string text, vector color, float alpha ) +void llSetTexture( string texture, integer face ) +void llSetTextureAnim( integer mode, integer face, integer sizex, integer sizey, float start, float length, float rate ) +void llSetTimerEvent( float sec ) +void llSetTorque( vector torque, integer local ) +void llSetTouchText( string text ) +void llSetVehicleFlags( integer flags ) +void llSetVehicleFloatParam( integer param, float value ) +void llSetVehicleRotationParam( integer param, rotation rot ) +void llSetVehicleType( integer type ) +void llSetVehicleVectorParam( integer param, vector vec ) +void llSetVelocity( vector velocity, integer local ) +void llShout( integer channel, string msg ) +float llSin( float theta ) +void llSitTarget( vector offset, rotation rot ) +void llSleep( float sec ) +void llSound( string sound, float volume, integer queue, integer loop ) +void llSoundPreload( string sound ) +float llSqrt( float val ) +void llStartAnimation( string anim ) +void llStopAnimation( string anim ) +void llStopHover( ) +void llStopLookAt( ) +void llStopMoveToTarget( ) +void llStopPointAt( ) +void llStopSound( ) +integer llStringLength( string str ) +string llStringToBase64( string str ) +string llStringTrim( string src, integer trim_type ) +integer llSubStringIndex( string source, string pattern ) +void llTakeCamera( key avatar ) +void llTakeControls( integer controls, integer accept, integer pass_on ) +float llTan( float theta ) +integer llTarget( vector position, float range ) +void llTargetOmega( vector axis, float spinrate, float gain ) +void llTargetRemove( integer number ) +void llTeleportAgent( key avatar, string landmark, vector position, vector look_at ) +void llTeleportAgentGlobalCoords( key agent, vector global_coordinates, vector region_coordinates, vector look_at ) +void llTeleportAgentHome( key id ) +void llTextBox( key avatar, string message, integer chat_channel ) +string llToLower( string src ) +string llToUpper( string src ) +key llTransferLindenDollars( key destination, integer amount ) +void llTriggerSound( string sound, float volume ) +void llTriggerSoundLimited( string sound, float volume, vector top_north_east, vector bottom_south_west ) +void llUnSit( key id ) +string llUnescapeURL( string url ) +void llUpdateCharacter( list options ) +float llVecDist( vector v1, vector v2 ) +float llVecMag( vector v ) +vector llVecNorm( vector v ) +void llVolumeDetect( integer detect ) +void llWanderWithin( vector center, vector radius, list options ) +float llWater( vector offset ) +void llWhisper( integer channel, string msg ) +vector llWind( vector offset ) +string llXorBase64( string str1, string str2 ) +string llXorBase64Strings( string str1, string str2 ) +string llXorBase64StringsCorrect( string str1, string str2 ) +const integer ACTIVE = 0x2 +const integer AGENT = 0x1 +const integer AGENT_ALWAYS_RUN = 0x1000 +const integer AGENT_ATTACHMENTS = 0x2 +const integer AGENT_AUTOPILOT = 0x2000 +const integer AGENT_AWAY = 0x40 +const integer AGENT_BUSY = 0x800 +const integer AGENT_BY_LEGACY_NAME = 0x1 +const integer AGENT_BY_USERNAME = 0x10 +const integer AGENT_CROUCHING = 0x400 +const integer AGENT_FLYING = 0x1 +const integer AGENT_IN_AIR = 0x100 +const integer AGENT_LIST_PARCEL = 1 +const integer AGENT_LIST_PARCEL_OWNER = 2 +const integer AGENT_LIST_REGION = 4 +const integer AGENT_MOUSELOOK = 0x8 +const integer AGENT_ON_OBJECT = 0x20 +const integer AGENT_SCRIPTED = 0x4 +const integer AGENT_SITTING = 0x10 +const integer AGENT_TYPING = 0x200 +const integer AGENT_WALKING = 0x80 +const integer ALL_SIDES = -1 +const integer ANIM_ON = 0x1 +const integer ATTACH_AVATAR_CENTER = 40 +const integer ATTACH_BACK = 9 +const integer ATTACH_BELLY = 28 +const integer ATTACH_CHEST = 1 +const integer ATTACH_CHIN = 12 +const integer ATTACH_HEAD = 2 +const integer ATTACH_HUD_BOTTOM = 37 +const integer ATTACH_HUD_BOTTOM_LEFT = 36 +const integer ATTACH_HUD_BOTTOM_RIGHT = 38 +const integer ATTACH_HUD_CENTER_1 = 35 +const integer ATTACH_HUD_CENTER_2 = 31 +const integer ATTACH_HUD_TOP_CENTER = 33 +const integer ATTACH_HUD_TOP_LEFT = 34 +const integer ATTACH_HUD_TOP_RIGHT = 32 +const integer ATTACH_LEAR = 13 +const integer ATTACH_LEFT_PEC = 29 +const integer ATTACH_LEYE = 15 +const integer ATTACH_LFOOT = 7 +const integer ATTACH_LHAND = 5 +const integer ATTACH_LHIP = 25 +const integer ATTACH_LLARM = 21 +const integer ATTACH_LLLEG = 27 +const integer ATTACH_LPEC = 30 +const integer ATTACH_LSHOULDER = 3 +const integer ATTACH_LUARM = 20 +const integer ATTACH_LULEG = 26 +const integer ATTACH_MOUTH = 11 +const integer ATTACH_NECK = 39 +const integer ATTACH_NOSE = 17 +const integer ATTACH_PELVIS = 10 +const integer ATTACH_REAR = 14 +const integer ATTACH_REYE = 16 +const integer ATTACH_RFOOT = 8 +const integer ATTACH_RHAND = 6 +const integer ATTACH_RHIP = 22 +const integer ATTACH_RIGHT_PEC = 30 +const integer ATTACH_RLARM = 19 +const integer ATTACH_RLLEG = 24 +const integer ATTACH_RPEC = 29 +const integer ATTACH_RSHOULDER = 4 +const integer ATTACH_RUARM = 18 +const integer ATTACH_RULEG = 23 +const integer AVOID_CHARACTERS = 1 +const integer AVOID_DYNAMIC_OBSTACLES = 2 +const integer AVOID_NONE = 0 +const integer CAMERA_ACTIVE = 12 +const integer CAMERA_BEHINDNESS_ANGLE = 8 +const integer CAMERA_BEHINDNESS_LAG = 9 +const integer CAMERA_DISTANCE = 7 +const integer CAMERA_FOCUS = 17 +const integer CAMERA_FOCUS_LAG = 6 +const integer CAMERA_FOCUS_LOCKED = 22 +const integer CAMERA_FOCUS_OFFSET = 1 +const integer CAMERA_FOCUS_THRESHOLD = 11 +const integer CAMERA_PITCH = 0 +const integer CAMERA_POSITION = 13 +const integer CAMERA_POSITION_LAG = 5 +const integer CAMERA_POSITION_LOCKED = 21 +const integer CAMERA_POSITION_THRESHOLD = 10 +const integer CHANGED_ALLOWED_DROP = 0x40 +const integer CHANGED_COLOR = 0x2 +const integer CHANGED_INVENTORY = 0x1 +const integer CHANGED_LINK = 0x20 +const integer CHANGED_MEDIA = 0x800 +const integer CHANGED_OWNER = 0x80 +const integer CHANGED_REGION = 0x100 +const integer CHANGED_REGION_START = 0x400 +const integer CHANGED_SCALE = 0x8 +const integer CHANGED_SHAPE = 0x4 +const integer CHANGED_TELEPORT = 0x200 +const integer CHANGED_TEXTURE = 0x10 +const integer CHARACTER_ACCOUNT_FOR_SKIPPED_FRAMES = 14 +const integer CHARACTER_AVOIDANCE_MODE = 5 +const integer CHARACTER_CMD_JUMP = 1 +const integer CHARACTER_CMD_SMOOTH_STOP = 2 +const integer CHARACTER_CMD_STOP = 0 +const integer CHARACTER_DESIRED_SPEED = 1 +const integer CHARACTER_DESIRED_TURN_SPEED = 12 +const integer CHARACTER_LENGTH = 3 +const integer CHARACTER_MAX_ACCEL = 8 +const integer CHARACTER_MAX_DECEL = 9 +const integer CHARACTER_MAX_SPEED = 13 +const integer CHARACTER_MAX_TURN_RADIUS = 10 +const integer CHARACTER_ORIENTATION = 4 +const integer CHARACTER_RADIUS = 2 +const integer CHARACTER_STAY_WITHIN_PARCEL = 15 +const integer CHARACTER_TYPE = 6 +const integer CHARACTER_TYPE_A = 0 +const integer CHARACTER_TYPE_B = 1 +const integer CHARACTER_TYPE_C = 2 +const integer CHARACTER_TYPE_D = 3 +const integer CHARACTER_TYPE_NONE = 4 +const integer CLICK_ACTION_BUY = 2 +const integer CLICK_ACTION_NONE = 0 +const integer CLICK_ACTION_OPEN = 4 +const integer CLICK_ACTION_OPEN_MEDIA = 6 +const integer CLICK_ACTION_PAY = 3 +const integer CLICK_ACTION_PLAY = 5 +const integer CLICK_ACTION_SIT = 1 +const integer CLICK_ACTION_TOUCH = 0 +const integer CONTENT_TYPE_ATOM = 4 +const integer CONTENT_TYPE_FORM = 7 +const integer CONTENT_TYPE_HTML = 1 +const integer CONTENT_TYPE_JSON = 5 +const integer CONTENT_TYPE_LLSD = 6 +const integer CONTENT_TYPE_RSS = 8 +const integer CONTENT_TYPE_TEXT = 0 +const integer CONTENT_TYPE_XHTML = 3 +const integer CONTENT_TYPE_XML = 2 +const integer CONTROL_BACK = 0x2 +const integer CONTROL_DOWN = 0x20 +const integer CONTROL_FWD = 0x1 +const integer CONTROL_LBUTTON = 0x10000000 +const integer CONTROL_LEFT = 0x4 +const integer CONTROL_ML_LBUTTON = 0x40000000 +const integer CONTROL_RIGHT = 0x8 +const integer CONTROL_ROT_LEFT = 0x100 +const integer CONTROL_ROT_RIGHT = 0x200 +const integer CONTROL_UP = 0x10 +const integer DATA_BORN = 3 +const integer DATA_NAME = 2 +const integer DATA_ONLINE = 1 +const integer DATA_PAYINFO = 8 +const integer DATA_RATING = 4 +const integer DATA_SIM_POS = 5 +const integer DATA_SIM_RATING = 7 +const integer DATA_SIM_STATUS = 6 +const integer DEBUG_CHANNEL = 0x7FFFFFFF +const float DEG_TO_RAD = 0.017453292 +const integer DENSITY = 0x1 +const string EOF = "\n\n\n" +const integer ERR_GENERIC = -1 +const integer ERR_MALFORMED_PARAMS = -3 +const integer ERR_PARCEL_PERMISSIONS = -2 +const integer ERR_RUNTIME_PERMISSIONS = -4 +const integer ERR_THROTTLED = -5 +const integer ESTATE_ACCESS_ALLOWED_AGENT_ADD = 0x4 +const integer ESTATE_ACCESS_ALLOWED_AGENT_REMOVE = 0x8 +const integer ESTATE_ACCESS_ALLOWED_GROUP_ADD = 0x10 +const integer ESTATE_ACCESS_ALLOWED_GROUP_REMOVE = 0x20 +const integer ESTATE_ACCESS_BANNED_AGENT_ADD = 0x40 +const integer ESTATE_ACCESS_BANNED_AGENT_REMOVE = 0x80 +const integer FALSE = 0 +const integer FORCE_DIRECT_PATH = 1 +const integer FRICTION = 0x2 +const integer GCNP_RADIUS = 0 +const integer GCNP_STATIC = 1 +const integer GRAVITY_MULTIPLIER = 0x8 +const integer HORIZONTAL = 1 +const integer HTTP_BODY_MAXLENGTH = 2 +const integer HTTP_BODY_TRUNCATED = 0 +const integer HTTP_CUSTOM_HEADER = 5 +const integer HTTP_METHOD = 0 +const integer HTTP_MIMETYPE = 1 +const integer HTTP_PRAGMA_NO_CACHE = 6 +const integer HTTP_VERBOSE_THROTTLE = 4 +const integer HTTP_VERIFY_CERT = 3 +const integer INVENTORY_ALL = -1 +const integer INVENTORY_ANIMATION = 20 +const integer INVENTORY_BODYPART = 13 +const integer INVENTORY_CLOTHING = 5 +const integer INVENTORY_GESTURE = 21 +const integer INVENTORY_LANDMARK = 3 +const integer INVENTORY_NONE = -1 +const integer INVENTORY_NOTECARD = 7 +const integer INVENTORY_OBJECT = 6 +const integer INVENTORY_SCRIPT = 10 +const integer INVENTORY_SOUND = 1 +const integer INVENTORY_TEXTURE = 0 +const integer JSON_APPEND = -1 +const string JSON_ARRAY = "﷒" +const string JSON_DELETE = "﷘" +const string JSON_FALSE = "﷗" +const string JSON_INVALID = "﷐" +const string JSON_NULL = "﷕" +const string JSON_NUMBER = "﷓" +const string JSON_OBJECT = "﷑" +const string JSON_STRING = "﷔" +const string JSON_TRUE = "﷖" +const integer KFM_CMD_PAUSE = 2 +const integer KFM_CMD_PLAY = 0 +const integer KFM_CMD_SET_MODE = 3 +const integer KFM_CMD_STOP = 1 +const integer KFM_COMMAND = 0 +const integer KFM_DATA = 2 +const integer KFM_FORWARD = 0 +const integer KFM_LOOP = 1 +const integer KFM_MODE = 1 +const integer KFM_PING_PONG = 2 +const integer KFM_REVERSE = 3 +const integer KFM_ROTATION = 1 +const integer KFM_TRANSLATION = 2 +const integer LAND_LARGE_BRUSH = 3 +const integer LAND_LEVEL = 0 +const integer LAND_LOWER = 2 +const integer LAND_MEDIUM_BRUSH = 2 +const integer LAND_NOISE = 4 +const integer LAND_RAISE = 1 +const integer LAND_REVERT = 5 +const integer LAND_SMALL_BRUSH = 1 +const integer LAND_SMOOTH = 3 +const integer LINK_ALL_CHILDREN = -3 +const integer LINK_ALL_OTHERS = -2 +const integer LINK_ROOT = 1 +const integer LINK_SET = -1 +const integer LINK_THIS = -4 +const integer LIST_STAT_GEOMETRIC_MEAN = 9 +const integer LIST_STAT_MAX = 2 +const integer LIST_STAT_MEAN = 3 +const integer LIST_STAT_MEDIAN = 4 +const integer LIST_STAT_MIN = 1 +const integer LIST_STAT_NUM_COUNT = 8 +const integer LIST_STAT_RANGE = 0 +const integer LIST_STAT_STD_DEV = 5 +const integer LIST_STAT_SUM = 6 +const integer LIST_STAT_SUM_SQUARES = 7 +const integer LOOP = 0x2 +const integer MASK_BASE = 0 +const integer MASK_EVERYONE = 3 +const integer MASK_GROUP = 2 +const integer MASK_NEXT = 4 +const integer MASK_OWNER = 1 +const string NULL_KEY = "00000000-0000-0000-0000-000000000000" +const integer OBJECT_ATTACHED_POINT = 19 +const integer OBJECT_CHARACTER_TIME = 17 +const integer OBJECT_CREATOR = 8 +const integer OBJECT_DESC = 2 +const integer OBJECT_GROUP = 7 +const integer OBJECT_NAME = 1 +const integer OBJECT_OWNER = 6 +const integer OBJECT_PATHFINDING_TYPE = 20 +const integer OBJECT_PHANTOM = 22 +const integer OBJECT_PHYSICS = 21 +const integer OBJECT_PHYSICS_COST = 16 +const integer OBJECT_POS = 3 +const integer OBJECT_PRIM_EQUIVALENCE = 13 +const integer OBJECT_RENDER_WEIGHT = 24 +const integer OBJECT_RETURN_PARCEL = 0x1 +const integer OBJECT_RETURN_PARCEL_OWNER = 0x2 +const integer OBJECT_RETURN_REGION = 0x4 +const integer OBJECT_ROOT = 18 +const integer OBJECT_ROT = 4 +const integer OBJECT_RUNNING_SCRIPT_COUNT = 9 +const integer OBJECT_SCRIPT_MEMORY = 11 +const integer OBJECT_SCRIPT_TIME = 12 +const integer OBJECT_SERVER_COST = 14 +const integer OBJECT_STREAMING_COST = 15 +const integer OBJECT_TEMP_ON_REZ = 23 +const integer OBJECT_TOTAL_SCRIPT_COUNT = 10 +const integer OBJECT_UNKNOWN_DETAIL = -1 +const integer OBJECT_VELOCITY = 5 +const integer OPT_AVATAR = 1 +const integer OPT_CHARACTER = 2 +const integer OPT_EXCLUSION_VOLUME = 6 +const integer OPT_LEGACY_LINKSET = 0 +const integer OPT_MATERIAL_VOLUME = 5 +const integer OPT_OTHER = -1 +const integer OPT_STATIC_OBSTACLE = 4 +const integer OPT_WALKABLE = 3 +const integer PARCEL_COUNT_GROUP = 2 +const integer PARCEL_COUNT_OTHER = 3 +const integer PARCEL_COUNT_OWNER = 1 +const integer PARCEL_COUNT_SELECTED = 4 +const integer PARCEL_COUNT_TEMP = 5 +const integer PARCEL_COUNT_TOTAL = 0 +const integer PARCEL_DETAILS_AREA = 4 +const integer PARCEL_DETAILS_DESC = 1 +const integer PARCEL_DETAILS_GROUP = 3 +const integer PARCEL_DETAILS_ID = 5 +const integer PARCEL_DETAILS_NAME = 0 +const integer PARCEL_DETAILS_OWNER = 2 +const integer PARCEL_DETAILS_SEE_AVATARS = 6 +const integer PARCEL_FLAG_ALLOW_ALL_OBJECT_ENTRY = 0x08000000 +const integer PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS = 0x04000000 +const integer PARCEL_FLAG_ALLOW_CREATE_OBJECTS = 0x00000040 +const integer PARCEL_FLAG_ALLOW_DAMAGE = 0x00000020 +const integer PARCEL_FLAG_ALLOW_FLY = 0x00000001 +const integer PARCEL_FLAG_ALLOW_GROUP_OBJECT_ENTRY = 0x10000000 +const integer PARCEL_FLAG_ALLOW_GROUP_SCRIPTS = 0x02000000 +const integer PARCEL_FLAG_ALLOW_LANDMARK = 0x00000008 +const integer PARCEL_FLAG_ALLOW_SCRIPTS = 0x00000002 +const integer PARCEL_FLAG_ALLOW_TERRAFORM = 0x00000010 +const integer PARCEL_FLAG_LOCAL_SOUND_ONLY = 0x00008000 +const integer PARCEL_FLAG_RESTRICT_PUSHOBJECT = 0x00200000 +const integer PARCEL_FLAG_USE_ACCESS_GROUP = 0x00000100 +const integer PARCEL_FLAG_USE_ACCESS_LIST = 0x00000200 +const integer PARCEL_FLAG_USE_BAN_LIST = 0x00000400 +const integer PARCEL_FLAG_USE_LAND_PASS_LIST = 0x00000800 +const integer PARCEL_MEDIA_COMMAND_AGENT = 7 +const integer PARCEL_MEDIA_COMMAND_AUTO_ALIGN = 9 +const integer PARCEL_MEDIA_COMMAND_DESC = 12 +const integer PARCEL_MEDIA_COMMAND_LOOP = 3 +const integer PARCEL_MEDIA_COMMAND_LOOP_SET = 13 +const integer PARCEL_MEDIA_COMMAND_PAUSE = 1 +const integer PARCEL_MEDIA_COMMAND_PLAY = 2 +const integer PARCEL_MEDIA_COMMAND_SIZE = 11 +const integer PARCEL_MEDIA_COMMAND_STOP = 0 +const integer PARCEL_MEDIA_COMMAND_TEXTURE = 4 +const integer PARCEL_MEDIA_COMMAND_TIME = 6 +const integer PARCEL_MEDIA_COMMAND_TYPE = 10 +const integer PARCEL_MEDIA_COMMAND_UNLOAD = 8 +const integer PARCEL_MEDIA_COMMAND_URL = 5 +const integer PASSIVE = 0x4 +const integer PATROL_PAUSE_AT_WAYPOINTS = 0 +const integer PAYMENT_INFO_ON_FILE = 0x1 +const integer PAYMENT_INFO_USED = 0x2 +const integer PAY_DEFAULT = -2 +const integer PAY_HIDE = -1 +const integer PERMISSION_ATTACH = 0x20 +const integer PERMISSION_CHANGE_JOINTS = 0x100 +const integer PERMISSION_CHANGE_LINKS = 0x80 +const integer PERMISSION_CHANGE_PERMISSIONS = 0x200 +const integer PERMISSION_CONTROL_CAMERA = 0x800 +const integer PERMISSION_DEBIT = 0x2 +const integer PERMISSION_OVERRIDE_ANIMATIONS = 0x8000 +const integer PERMISSION_RELEASE_OWNERSHIP = 0x40 +const integer PERMISSION_REMAP_CONTROLS = 0x8 +const integer PERMISSION_RETURN_OBJECTS = 0x10000 +const integer PERMISSION_SILENT_ESTATE_MANAGEMENT = 0x4000 +const integer PERMISSION_TAKE_CONTROLS = 0x4 +const integer PERMISSION_TELEPORT = 0x1000 +const integer PERMISSION_TRACK_CAMERA = 0x400 +const integer PERMISSION_TRIGGER_ANIMATION = 0x10 +const integer PERM_ALL = 0x7FFFFFFF +const integer PERM_COPY = 0x00008000 +const integer PERM_MODIFY = 0x00004000 +const integer PERM_MOVE = 0x00080000 +const integer PERM_TRANSFER = 0x00002000 +const float PI = 3.14159265 +const integer PING_PONG = 0x8 +const float PI_BY_TWO = 1.57079632 +const integer PRIM_BUMP_BARK = 4 +const integer PRIM_BUMP_BLOBS = 12 +const integer PRIM_BUMP_BRICKS = 5 +const integer PRIM_BUMP_BRIGHT = 1 +const integer PRIM_BUMP_CHECKER = 6 +const integer PRIM_BUMP_CONCRETE = 7 +const integer PRIM_BUMP_DARK = 2 +const integer PRIM_BUMP_DISKS = 10 +const integer PRIM_BUMP_GRAVEL = 11 +const integer PRIM_BUMP_LARGETILE = 14 +const integer PRIM_BUMP_NONE = 0 +const integer PRIM_BUMP_SHINY = 19 +const integer PRIM_BUMP_SIDING = 13 +const integer PRIM_BUMP_STONE = 9 +const integer PRIM_BUMP_STUCCO = 15 +const integer PRIM_BUMP_SUCTION = 16 +const integer PRIM_BUMP_TILE = 8 +const integer PRIM_BUMP_WEAVE = 17 +const integer PRIM_BUMP_WOOD = 3 +const integer PRIM_CAST_SHADOWS = 24 +const integer PRIM_COLOR = 18 +const integer PRIM_DESC = 28 +const integer PRIM_FLEXIBLE = 21 +const integer PRIM_FULLBRIGHT = 20 +const integer PRIM_GLOW = 25 +const integer PRIM_HOLE_CIRCLE = 0x10 +const integer PRIM_HOLE_DEFAULT = 0x0 +const integer PRIM_HOLE_SQUARE = 0x20 +const integer PRIM_HOLE_TRIANGLE = 0x30 +const integer PRIM_LINK_TARGET = 34 +const integer PRIM_MATERIAL = 2 +const integer PRIM_MATERIAL_FLESH = 4 +const integer PRIM_MATERIAL_GLASS = 2 +const integer PRIM_MATERIAL_LIGHT = 7 +const integer PRIM_MATERIAL_METAL = 1 +const integer PRIM_MATERIAL_PLASTIC = 5 +const integer PRIM_MATERIAL_RUBBER = 6 +const integer PRIM_MATERIAL_STONE = 0 +const integer PRIM_MATERIAL_WOOD = 3 +const integer PRIM_MEDIA_ALT_IMAGE_ENABLE = 0 +const integer PRIM_MEDIA_AUTO_LOOP = 4 +const integer PRIM_MEDIA_AUTO_PLAY = 5 +const integer PRIM_MEDIA_AUTO_SCALE = 6 +const integer PRIM_MEDIA_AUTO_ZOOM = 7 +const integer PRIM_MEDIA_CONTROLS = 1 +const integer PRIM_MEDIA_CONTROLS_MINI = 1 +const integer PRIM_MEDIA_CONTROLS_STANDARD = 0 +const integer PRIM_MEDIA_CURRENT_URL = 2 +const integer PRIM_MEDIA_FIRST_CLICK_INTERACT = 8 +const integer PRIM_MEDIA_HEIGHT_PIXELS = 10 +const integer PRIM_MEDIA_HOME_URL = 3 +const integer PRIM_MEDIA_MAX_HEIGHT_PIXELS = 2048 +const integer PRIM_MEDIA_MAX_URL_LENGTH = 1024 +const integer PRIM_MEDIA_MAX_WHITELIST_COUNT = 64 +const integer PRIM_MEDIA_MAX_WHITELIST_SIZE = 1024 +const integer PRIM_MEDIA_MAX_WIDTH_PIXELS = 2048 +const integer PRIM_MEDIA_PARAM_MAX = 14 +const integer PRIM_MEDIA_PERMS_CONTROL = 14 +const integer PRIM_MEDIA_PERMS_INTERACT = 13 +const integer PRIM_MEDIA_PERM_ANYONE = 0x4 +const integer PRIM_MEDIA_PERM_GROUP = 0x2 +const integer PRIM_MEDIA_PERM_NONE = 0x0 +const integer PRIM_MEDIA_PERM_OWNER = 0x1 +const integer PRIM_MEDIA_WHITELIST = 12 +const integer PRIM_MEDIA_WHITELIST_ENABLE = 11 +const integer PRIM_MEDIA_WIDTH_PIXELS = 9 +const integer PRIM_NAME = 27 +const integer PRIM_OMEGA = 32 +const integer PRIM_PHANTOM = 5 +const integer PRIM_PHYSICS = 3 +const integer PRIM_PHYSICS_SHAPE_CONVEX = 2 +const integer PRIM_PHYSICS_SHAPE_NONE = 1 +const integer PRIM_PHYSICS_SHAPE_PRIM = 0 +const integer PRIM_PHYSICS_SHAPE_TYPE = 30 +const integer PRIM_POINT_LIGHT = 23 +const integer PRIM_POSITION = 6 +const integer PRIM_POS_LOCAL = 33 +const integer PRIM_ROTATION = 8 +const integer PRIM_ROT_LOCAL = 29 +const integer PRIM_SCULPT_FLAG_INVERT = 0x40 +const integer PRIM_SCULPT_FLAG_MIRROR = 0x80 +const integer PRIM_SCULPT_TYPE_CYLINDER = 4 +const integer PRIM_SCULPT_TYPE_MASK = 7 +const integer PRIM_SCULPT_TYPE_PLANE = 3 +const integer PRIM_SCULPT_TYPE_SPHERE = 1 +const integer PRIM_SCULPT_TYPE_TORUS = 2 +const integer PRIM_SHINY_HIGH = 3 +const integer PRIM_SHINY_LOW = 1 +const integer PRIM_SHINY_MEDIUM = 2 +const integer PRIM_SHINY_NONE = 0 +const integer PRIM_SIZE = 7 +const integer PRIM_SLICE = 35 +const integer PRIM_TEMP_ON_REZ = 4 +const integer PRIM_TEXGEN = 22 +const integer PRIM_TEXGEN_DEFAULT = 0 +const integer PRIM_TEXGEN_PLANAR = 1 +const integer PRIM_TEXT = 26 +const integer PRIM_TEXTURE = 17 +const integer PRIM_TYPE = 9 +const integer PRIM_TYPE_BOX = 0 +const integer PRIM_TYPE_CYLINDER = 1 +const integer PRIM_TYPE_PRISM = 2 +const integer PRIM_TYPE_RING = 6 +const integer PRIM_TYPE_SCULPT = 7 +const integer PRIM_TYPE_SPHERE = 3 +const integer PRIM_TYPE_TORUS = 4 +const integer PRIM_TYPE_TUBE = 5 +const integer PROFILE_NONE = 0 +const integer PROFILE_SCRIPT_MEMORY = 1 +const integer PSYS_PART_BF_DEST_COLOR = 2 +const integer PSYS_PART_BF_ONE = 0 +const integer PSYS_PART_BF_ONE_MINUS_DEST_COLOR = 4 +const integer PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA = 9 +const integer PSYS_PART_BF_ONE_MINUS_SOURCE_COLOR = 5 +const integer PSYS_PART_BF_SOURCE_ALPHA = 7 +const integer PSYS_PART_BF_SOURCE_COLOR = 3 +const integer PSYS_PART_BF_ZERO = 1 +const integer PSYS_PART_BLEND_FUNC_DEST = 25 +const integer PSYS_PART_BLEND_FUNC_SOURCE = 24 +const integer PSYS_PART_BOUNCE_MASK = 0x4 +const integer PSYS_PART_EMISSIVE_MASK = 0x100 +const integer PSYS_PART_END_ALPHA = 4 +const integer PSYS_PART_END_COLOR = 3 +const integer PSYS_PART_END_GLOW = 27 +const integer PSYS_PART_END_SCALE = 6 +const integer PSYS_PART_FLAGS = 0 +const integer PSYS_PART_FOLLOW_SRC_MASK = 0x10 +const integer PSYS_PART_FOLLOW_VELOCITY_MASK = 0x20 +const integer PSYS_PART_INTERP_COLOR_MASK = 0x1 +const integer PSYS_PART_INTERP_SCALE_MASK = 0x2 +const integer PSYS_PART_MAX_AGE = 7 +const integer PSYS_PART_RIBBON_MASK = 0x400 +const integer PSYS_PART_START_ALPHA = 2 +const integer PSYS_PART_START_COLOR = 1 +const integer PSYS_PART_START_GLOW = 26 +const integer PSYS_PART_START_SCALE = 5 +const integer PSYS_PART_TARGET_LINEAR_MASK = 0x80 +const integer PSYS_PART_TARGET_POS_MASK = 0x40 +const integer PSYS_PART_WIND_MASK = 0x8 +const integer PSYS_SRC_ACCEL = 8 +const integer PSYS_SRC_ANGLE_BEGIN = 22 +const integer PSYS_SRC_ANGLE_END = 23 +const integer PSYS_SRC_BURST_PART_COUNT = 15 +const integer PSYS_SRC_BURST_RADIUS = 16 +const integer PSYS_SRC_BURST_RATE = 13 +const integer PSYS_SRC_BURST_SPEED_MAX = 18 +const integer PSYS_SRC_BURST_SPEED_MIN = 17 +const integer PSYS_SRC_INNERANGLE = 10 +const integer PSYS_SRC_MAX_AGE = 19 +const integer PSYS_SRC_OBJ_REL_MASK = 1 +const integer PSYS_SRC_OMEGA = 21 +const integer PSYS_SRC_OUTERANGLE = 11 +const integer PSYS_SRC_PATTERN = 9 +const integer PSYS_SRC_PATTERN_ANGLE = 4 +const integer PSYS_SRC_PATTERN_ANGLE_CONE = 8 +const integer PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY = 16 +const integer PSYS_SRC_PATTERN_DROP = 1 +const integer PSYS_SRC_PATTERN_EXPLODE = 2 +const integer PSYS_SRC_TARGET_KEY = 20 +const integer PSYS_SRC_TEXTURE = 12 +const integer PUBLIC_CHANNEL = 0 +const integer PURSUIT_FUZZ_FACTOR = 3 +const integer PURSUIT_GOAL_TOLERANCE = 5 +const integer PURSUIT_INTERCEPT = 4 +const integer PURSUIT_OFFSET = 1 +const integer PU_EVADE_HIDDEN = 7 +const integer PU_EVADE_SPOTTED = 8 +const integer PU_FAILURE_DYNAMIC_PATHFINDING_DISABLED = 10 +const integer PU_FAILURE_INVALID_GOAL = 3 +const integer PU_FAILURE_INVALID_START = 2 +const integer PU_FAILURE_NO_NAVMESH = 9 +const integer PU_FAILURE_NO_VALID_DESTINATION = 6 +const integer PU_FAILURE_OTHER = 1000000 +const integer PU_FAILURE_PARCEL_UNREACHABLE = 11 +const integer PU_FAILURE_TARGET_GONE = 5 +const integer PU_FAILURE_UNREACHABLE = 4 +const integer PU_GOAL_REACHED = 1 +const integer PU_SLOWDOWN_DISTANCE_REACHED = 0 +const float RAD_TO_DEG = 57.295779 +const integer RCERR_CAST_TIME_EXCEEDED = -3 +const integer RCERR_SIM_PERF_LOW = -2 +const integer RCERR_UNKNOWN = -1 +const integer RC_DATA_FLAGS = 2 +const integer RC_DETECT_PHANTOM = 1 +const integer RC_GET_LINK_NUM = 0x4 +const integer RC_GET_NORMAL = 0x1 +const integer RC_GET_ROOT_KEY = 0x2 +const integer RC_MAX_HITS = 3 +const integer RC_REJECT_AGENTS = 0x1 +const integer RC_REJECT_LAND = 0x8 +const integer RC_REJECT_NONPHYSICAL = 0x4 +const integer RC_REJECT_PHYSICAL = 0x2 +const integer RC_REJECT_TYPES = 0 +const integer REGION_FLAG_ALLOW_DAMAGE = 0x00000001 +const integer REGION_FLAG_ALLOW_DIRECT_TELEPORT = 0x00100000 +const integer REGION_FLAG_BLOCK_FLY = 0x00080000 +const integer REGION_FLAG_BLOCK_TERRAFORM = 0x00000040 +const integer REGION_FLAG_DISABLE_COLLISIONS = 0x00001000 +const integer REGION_FLAG_DISABLE_PHYSICS = 0x00004000 +const integer REGION_FLAG_FIXED_SUN = 0x00000010 +const integer REGION_FLAG_RESTRICT_PUSHOBJECT = 0x00400000 +const integer REGION_FLAG_SANDBOX = 0x00000100 +const integer REMOTE_DATA_CHANNEL = 1 +const integer REMOTE_DATA_REPLY = 3 +const integer REMOTE_DATA_REQUEST = 2 +const integer REQUIRE_LINE_OF_SIGHT = 2 +const integer RESTITUTION = 0x4 +const integer REVERSE = 0x4 +const integer ROTATE = 0x20 +const integer SCALE = 0x40 +const integer SCRIPTED = 0x8 +const integer SIM_STAT_PCT_CHARS_STEPPED = 0 +const integer SMOOTH = 0x10 +const float SQRT2 = 1.4142135 +const integer STATUS_BLOCK_GRAB = 0x40 +const integer STATUS_BLOCK_GRAB_OBJECT = 0x400 +const integer STATUS_BOUNDS_ERROR = 1002 +const integer STATUS_CAST_SHADOWS = 0x200 +const integer STATUS_DIE_AT_EDGE = 0x80 +const integer STATUS_INTERNAL_ERROR = 1999 +const integer STATUS_MALFORMED_PARAMS = 1000 +const integer STATUS_NOT_FOUND = 1003 +const integer STATUS_NOT_SUPPORTED = 1004 +const integer STATUS_OK = 0 +const integer STATUS_PHANTOM = 0x10 +const integer STATUS_PHYSICS = 0x1 +const integer STATUS_RETURN_AT_EDGE = 0x100 +const integer STATUS_ROTATE_X = 0x2 +const integer STATUS_ROTATE_Y = 0x4 +const integer STATUS_ROTATE_Z = 0x8 +const integer STATUS_SANDBOX = 0x20 +const integer STATUS_TYPE_MISMATCH = 1001 +const integer STATUS_WHITELIST_FAILED = 2001 +const integer STRING_TRIM = 3 +const integer STRING_TRIM_HEAD = 1 +const integer STRING_TRIM_TAIL = 2 +const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f" +const string TEXTURE_DEFAULT = "89556747-24cb-43ed-920b-47caed15465f" +const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361" +const string TEXTURE_PLYWOOD = "89556747-24cb-43ed-920b-47caed15465f" +const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903" +const integer TOUCH_INVALID_FACE = -1 +const vector TOUCH_INVALID_TEXCOORD = <-1.0, -1.0, 0.0> +const vector TOUCH_INVALID_VECTOR = <0.0, 0.0, 0.0> +const integer TRAVERSAL_TYPE = 7 +const integer TRAVERSAL_TYPE_FAST = 1 +const integer TRAVERSAL_TYPE_NONE = 2 +const integer TRAVERSAL_TYPE_SLOW = 0 +const integer TRUE = 1 +const float TWO_PI = 6.2831853 +const integer TYPE_FLOAT = 2 +const integer TYPE_INTEGER = 1 +const integer TYPE_INVALID = 0 +const integer TYPE_KEY = 4 +const integer TYPE_ROTATION = 6 +const integer TYPE_STRING = 3 +const integer TYPE_VECTOR = 5 +const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED" +const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED" +const integer VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY = 32 +const integer VEHICLE_ANGULAR_DEFLECTION_TIMESCALE = 33 +const integer VEHICLE_ANGULAR_FRICTION_TIMESCALE = 17 +const integer VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE = 35 +const integer VEHICLE_ANGULAR_MOTOR_DIRECTION = 19 +const integer VEHICLE_ANGULAR_MOTOR_TIMESCALE = 34 +const integer VEHICLE_BANKING_EFFICIENCY = 38 +const integer VEHICLE_BANKING_MIX = 39 +const integer VEHICLE_BANKING_TIMESCALE = 40 +const integer VEHICLE_BUOYANCY = 27 +const integer VEHICLE_FLAG_CAMERA_DECOUPLED = 0x200 +const integer VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT = 0x10 +const integer VEHICLE_FLAG_HOVER_TERRAIN_ONLY = 0x8 +const integer VEHICLE_FLAG_HOVER_UP_ONLY = 0x20 +const integer VEHICLE_FLAG_HOVER_WATER_ONLY = 0x4 +const integer VEHICLE_FLAG_LIMIT_MOTOR_UP = 0x40 +const integer VEHICLE_FLAG_LIMIT_ROLL_ONLY = 0x2 +const integer VEHICLE_FLAG_MOUSELOOK_BANK = 0x100 +const integer VEHICLE_FLAG_MOUSELOOK_STEER = 0x80 +const integer VEHICLE_FLAG_NO_DEFLECTION_UP = 0x1 +const integer VEHICLE_FLAG_NO_FLY_UP = 0x1 +const integer VEHICLE_HOVER_EFFICIENCY = 25 +const integer VEHICLE_HOVER_HEIGHT = 24 +const integer VEHICLE_HOVER_TIMESCALE = 26 +const integer VEHICLE_LINEAR_DEFLECTION_EFFICIENCY = 28 +const integer VEHICLE_LINEAR_DEFLECTION_TIMESCALE = 29 +const integer VEHICLE_LINEAR_FRICTION_TIMESCALE = 16 +const integer VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE = 31 +const integer VEHICLE_LINEAR_MOTOR_DIRECTION = 18 +const integer VEHICLE_LINEAR_MOTOR_OFFSET = 20 +const integer VEHICLE_LINEAR_MOTOR_TIMESCALE = 30 +const integer VEHICLE_REFERENCE_FRAME = 44 +const integer VEHICLE_TYPE_AIRPLANE = 4 +const integer VEHICLE_TYPE_BALLOON = 5 +const integer VEHICLE_TYPE_BOAT = 3 +const integer VEHICLE_TYPE_CAR = 2 +const integer VEHICLE_TYPE_NONE = 0 +const integer VEHICLE_TYPE_SLED = 1 +const integer VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY = 36 +const integer VEHICLE_VERTICAL_ATTRACTION_TIMESCALE = 37 +const integer VERTICAL = 0 +const integer WANDER_PAUSE_AT_WAYPOINTS = 0 +const rotation ZERO_ROTATION = <0.0, 0.0, 0.0, 1.0> +const vector ZERO_VECTOR = <0.0, 0.0, 0.0> +event at_rot_target( integer tnum, rotation targetrot, rotation ourrot ) +event at_target( integer tnum, vector targetpos, vector ourpos ) +event attach( key id ) +event changed( integer change ) +event collision( integer num_detected ) +event collision_end( integer num_detected ) +event collision_start( integer num_detected ) +event control( key id, integer level, integer edge ) +event dataserver( key queryid, string data ) +event email( string time, string address, string subj, string message, integer num_left ) +event http_request( key id, string method, string body ) +event http_response( key request_id, integer status, list metadata, string body ) +event land_collision( vector pos ) +event land_collision_end( vector pos ) +event land_collision_start( vector pos ) +event link_message( integer sender_num, integer num, string str, key id ) +event listen( integer channel, string name, key id, string message ) +event money( key id, integer amount ) +event moving_end( ) +event moving_start( ) +event no_sensor( ) +event not_at_rot_target( ) +event not_at_target( ) +event object_rez( key id ) +event on_rez( integer start_param ) +event path_update( integer type, list reserved ) +event remote_data( integer event_type, key channel, key message_id, string sender, integer idata, string sdata ) +event run_time_permissions( integer perm ) +event sensor( integer num_detected ) +event state_entry( ) +event state_exit( ) +event timer( ) +event touch( integer num_detected ) +event touch_end( integer num_detected ) +event touch_start( integer num_detected ) +event transaction_result( key id, integer success, string data ) diff --git a/testfuncs.py b/testfuncs.py new file mode 100644 index 0000000..21b247d --- /dev/null +++ b/testfuncs.py @@ -0,0 +1,1556 @@ +from lslopt.lslcommon import * +from lslopt.lslfuncs import * +from lslopt import lslcommon +import sys +import math + +StopAtFirstError = False + +errors = 0 +tests = 0 +untested = 0 + +nan = NaN +inf = Infinity + +F = float.fromhex + +class ETestFailed(Exception): + def __init__(self): + super(self.__class__, self).__init__("Test failed") + pass + +def reallyequal(actual, expected, tol): + if tol is None: + return repr(actual) == repr(expected) + + if type(actual) != type(expected): + return False + + # Deal with floats (edge cases, tolerance) + if isinstance(actual, float): + if actual == 0.0: + return str(actual) == str(expected) + elif math.isnan(actual): + return math.isnan(expected) + return abs(actual - expected) <= tol + + # Deal with tuples and lists (item-by-item, recursively) + if isinstance(actual, (tuple, list)): + return all(reallyequal(i1, i2, tol) for i1, i2 in zip(actual, expected)) + + # Fall back to 'classic' equality + return actual == expected + +def test(fn, expected): + global tests + global errors + global untested + tol = None # get rid of tolerance test + tests += 1 + if StopAtFirstError: + if errors: + untested += 1 + return + + actual = eval(fn) + werr = sys.stderr.write + if not reallyequal(actual, expected, tol): + werr("Test failed: " + fn + '\n') + werr("Actual: " + repr(actual) + '\n') + werr("Expect: " + repr(expected) + '\n') + errors += 1 + #raise ETestFailed + else: + sys.stdout.write("PASSED! %s == %s\n" % (fn, repr(expected))) + +def shouldexcept(txt, exc): + global tests + global errors + global untested + + tests += 1 + if StopAtFirstError: + if errors: + untested += 1 + return + + try: + eval(txt) + except exc: + sys.stdout.write("PASSED! %s on %s\n" % (exc.__name__, txt)) + return + + werr = sys.stderr.write + werr('Test failed: ' + txt + '\n') + werr('Actual: (no exception)\n') + werr('Expect: should raise ' + exc.__name__ + '\n') + errors += 1 + +def testXB64S(s1, s2, expect): + if type(s1) == str: + s1 = s1.decode('utf8') + if type(s2) == str: + s2 = s2.decode('utf8') + if type(expect) == str: + expect = expect.decode('utf8') + test('llXorBase64Strings(' + repr(s1) + ',' + repr(s2) + ')', expect) + +def testXB64SC(s1, s2, expect): + if type(s1) == str: + s1 = s1.decode('utf8') + if type(s2) == str: + s2 = s2.decode('utf8') + if type(expect) == str: + expect = expect.decode('utf8') + test('llXorBase64StringsCorrect(' + repr(s1) + ',' + repr(s2) + ')', expect) + +def testXB64(s1, s2, expect, Bug3763=False): + if type(s1) == str: + s1 = s1.decode('utf8') + if type(s2) == str: + s2 = s2.decode('utf8') + if type(expect) == str: + expect = expect.decode('utf8') + if Bug3763: + Bugs.add(3763) + test('llXorBase64(' + repr(s1) + ',' + repr(s2) + ')', expect) + Bugs.discard(3763) + +# Begin JSON tests from http://wiki.secondlife.com/wiki/Json_usage_in_LSL/TestScript +def verify(msg, result, expected): + global tests + tests += 1 + werr = sys.stderr.write + if expected != result: + global errors + errors += 1 + werr("Test failed: " + msg + '\n') + werr("Actual: " + repr(result) + '\n') + werr("Expect: " + repr(expected) + '\n') + #return 0 + else: + sys.stdout.write("PASSED! %s, expect=actual=%s\n" % (msg, repr(expected))) + #return 1 + +def verify_list(msg, result, expected): + verify(msg, repr(result), repr(expected)) + +def test_types(): + verify("Type of string",llJsonValueType(u"\"test\"",[]),JSON_STRING); + verify("Type of string, unquoted",llJsonValueType(u"test",[]),JSON_INVALID); + verify("Type of invalid",llJsonValueType(u"test",[]),JSON_INVALID); + verify("Type of integer",llJsonValueType(u"12",[]),JSON_NUMBER); + verify("Type of float",llJsonValueType(u"12.300000",[]),JSON_NUMBER); + verify("Type of Inf (is unsupported by JSON standard)",llJsonValueType(u"Inf",[]),JSON_INVALID); + verify("Type of NaN (is unsupported by JSON standard)",llJsonValueType(u"NaN",[]),JSON_INVALID); + verify("Type of number",llJsonValueType(u"-123.4e-5",[]),JSON_NUMBER); + verify("Type of object",llJsonValueType(u"{\"a\":\"b\"}",[]),JSON_OBJECT); + # Expected to be OBJECT, since we don't do deep validation on input + #verify("Type of object, invalid/unquoted key",llJsonValueType(u"{a:\"b\"}",[]),JSON_INVALID); + \ +verify("Type of object, invalid/unquoted key",llJsonValueType(u"{a:\"b\"}",[]),JSON_OBJECT) # check so + # Expected to be OBJECT, since we don't do deep validation on input + #verify("Type of object, invalid/unquoted value",llJsonValueType(u"{\"a\":b}",[]),JSON_INVALID); + \ +verify("Type of object, invalid/unquoted value",llJsonValueType(u"{\"a\":b}",[]),JSON_OBJECT) # check so + verify("Type of array",llJsonValueType(u"[1,2,3]",[]),JSON_ARRAY); + verify("Type of array padded front",llJsonValueType(u" [1,2,3]",[]),JSON_ARRAY); + verify("Type of array padded back",llJsonValueType(u"[1,2,3] ",[]),JSON_ARRAY); + verify("Type of array padded",llJsonValueType(u" [1,2,3] ",[]),JSON_ARRAY); + verify("Type of true",llJsonValueType(u"true",[]),JSON_TRUE); + verify("Type of false",llJsonValueType(u"false",[]),JSON_FALSE); + verify("Type of null",llJsonValueType(u"null",[]),JSON_NULL); + + # test traversal of llJsonValueType + json = u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6],\"c\":\"true\",\"d\":false}]"; + verify("Type of [0]",llJsonValueType(json,[0]),JSON_ARRAY); + verify("Type of [0,1]",llJsonValueType(json,[0,1]),JSON_NUMBER); + verify("Type of [1]",llJsonValueType(json,[1]),JSON_OBJECT); + verify("Type of [1,\"b\"]",llJsonValueType(json,[1,u"b"]),JSON_ARRAY); + verify("Type of [1,\"b\",0]",llJsonValueType(json,[1,u"b",0]),JSON_TRUE); + verify("Type of [1,\"b\",1]",llJsonValueType(json,[1,u"b",1]),JSON_STRING); + verify("Type of [1,\"b\",2]",llJsonValueType(json,[1,u"b",2]),JSON_NUMBER); + verify("Type of [1,\"c\"]",llJsonValueType(json,[1,u"c"]),JSON_STRING); + verify("Type of [1,\"d\"]",llJsonValueType(json,[1,u"d"]),JSON_FALSE); + verify("Type of [3] (invalid index at level 0)",llJsonValueType(json,[3]),JSON_INVALID); + verify("Type of [-1] (invalid index at level 0)",llJsonValueType(json,[-1]),JSON_INVALID); + verify("Type of [1,\"c\",3] (invalid index at level 1), MAINT-2670",llJsonValueType(json,[1,u"c",3]),JSON_INVALID); + \ +verify("Type of [1,\"c\",0] (first element of non-nested object)",llJsonValueType(json,[1,u"c",0]),JSON_INVALID); +# added by us + verify("Type of [1,\"b\",3] (invalid index at level 2)",llJsonValueType(json,[1,u"b",3]),JSON_INVALID); + verify("Type of [1,\"b\",2,0,1] (invalid index at level 3) MAINT-2670",llJsonValueType(json,[1,u"b",2, 0, 1]),JSON_INVALID); + + # some invalid cases where keys are uncoded + json = u"[[1,2,3],{a:3,b:[true,\"test\",6],c:\"true\",\"d\":false}]"; + verify("Type of [1,\"a\"] where key is unquoted",llJsonValueType(json,[1,u"a"]),JSON_INVALID); + verify("Type of [1,\"b\"] where key is unquoted",llJsonValueType(json,[1,u"b"]),JSON_INVALID); + verify("Type of [1,\"c\"] where key is unquoted",llJsonValueType(json,[1,u"c"]),JSON_INVALID); + + +def test_get_value(): + json = u"[[1,2,3,4.0],{\"a\":3,\"b\":[true,\"test\",6]}]"; + verify("llJsonGetValue [0]",llJsonGetValue(json,[0]),u"[1,2,3,4.0]"); + verify("llJsonGetValue [0,1]",llJsonGetValue(json,[0,1]),u"2"); + verify("llJsonGetValue [1]",llJsonGetValue(json,[1]),u"{\"a\":3,\"b\":[true,\"test\",6]}"); + verify("llJsonGetValue [1,\"b\"]",llJsonGetValue(json,[1,u"b"]),u"[true,\"test\",6]"); + verify("llJsonGetValue [1,\"b\",0]",llJsonGetValue(json,[1,u"b",0]),JSON_TRUE); + verify("llJsonGetValue [1,\"b\",1]",llJsonGetValue(json,[1,u"b",1]),u"test"); + verify("llJsonGetValue [1,\"b\",2]",llJsonGetValue(json,[1,u"b",2]),u"6"); + verify("llJsonGetValue [0,3]",llJsonGetValue(json,[0,3]), u"4.0"); + verify("llJsonGetValue [2] (invalid index at level 0)",llJsonGetValue(json,[2]),JSON_INVALID); + verify("llJsonGetValue [-1] (invalid index at level 0)",llJsonGetValue(json,[-1]),JSON_INVALID); + verify("llJsonGetValue [0,4] (invalid index within array)",llJsonGetValue(json,[0,4]),JSON_INVALID); + verify("llJsonGetValue [\"f\"] (look for missing object within array, depth=0) MAINT-2671",llJsonGetValue(json,[u"f"]),JSON_INVALID); + verify("llJsonGetValue [0,\"f\"] (look for missing object within array, depth=1) MAINT-2671",llJsonGetValue(json,[0,u"f"]),JSON_INVALID); + verify("llJsonGetValue [1,2] (specify index within object - disallowed)",llJsonGetValue(json,[1,2]),JSON_INVALID); + + # invalid input json - missing quotes around 'a' and 'test' + json = u"[[1,2,3,4.0],{a:3,\"b\":[true,test,6]}]"; + verify("llJsonGetValue [1,\"b\",1], unquoted/invalid string value",llJsonGetValue(json,[1,u"b",1]),JSON_INVALID); + verify("llJsonGetValue [1,\"a\"], unquoted/invalid string for key",llJsonGetValue(json,[1,u"a"]),JSON_INVALID); + +def test_set_value(): + # Test building from scratch + json = u"" + json = llJsonSetValue(json,[0,0],u"1"); + verify("llJsonSetValue build json",json,u"[[1]]"); + json = llJsonSetValue(json,[0,1],u"2"); + verify("llJsonSetValue build json",json,u"[[1,2]]"); + json = llJsonSetValue(json,[0,2],u"3"); + verify("llJsonSetValue build json",json,u"[[1,2,3]]"); + json = llJsonSetValue(json,[1,u"a"],u"3"); + verify("llJsonSetValue build json",json,u"[[1,2,3],{\"a\":3}]"); + json = llJsonSetValue(json,[1,u"b",0],JSON_TRUE); + verify("llJsonSetValue build json",json,u"[[1,2,3],{\"a\":3,\"b\":[true]}]"); + json = llJsonSetValue(json,[1,u"b",1],u"test"); + verify("llJsonSetValue build json",json,u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\"]}]"); + json = llJsonSetValue(json,[1,u"b",2],u"6"); + verify("llJsonSetValue completed json",json,u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6]}]"); + + # Test replacing + json = llJsonSetValue(json,[1,u"b",1],u"foo"); + verify("llJsonSetValue completed json",json,u"[[1,2,3],{\"a\":3,\"b\":[true,\"foo\",6]}]"); + json = llJsonSetValue(json,[1,u"b"],JSON_TRUE); + verify("llJsonSetValue completed json, true",json,u"[[1,2,3],{\"a\":3,\"b\":true}]"); + json = llJsonSetValue(json,[1,u"b"],u"true"); + verify("llJsonSetValue completed json, alt true",json,u"[[1,2,3],{\"a\":3,\"b\":true}]"); + json = llJsonSetValue(json,[1,0,0],JSON_FALSE); + verify("llJsonSetValue completed json",json,u"[[1,2,3],[[false]]]"); + + # Test appending + json = llJsonSetValue(u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6]}]",[0,JSON_APPEND], u"4.0"); + verify("llJsonSetValue append to first array",json,u"[[1,2,3,4.0],{\"a\":3,\"b\":[true,\"test\",6]}]"); + json = llJsonSetValue(json,[1,u"b",JSON_APPEND], u"5.0"); + verify("llJsonSetValue append to array withhin object",json,u"[[1,2,3,4.0],{\"a\":3,\"b\":[true,\"test\",6,5.0]}]"); + json = llJsonSetValue(json,[JSON_APPEND], u"6.0"); + verify("llJsonSetValue append to outer array",json,u"[[1,2,3,4.0],{\"a\":3,\"b\":[true,\"test\",6,5.0]},6.0]"); + json = llJsonSetValue(u"[]",[JSON_APPEND], u"\"alone\""); + verify("llJsonSetValue append to empty array (MAINT-2684)",json,u"[\"alone\"]"); + json = llJsonSetValue(u"[]",[1], u"\"alone\""); + verify("llJsonSetValue append to empty array at invalid index (MAINT-2684)",json,JSON_INVALID); + json = llJsonSetValue(u"[]",[0], u"\"alone\""); + verify("llJsonSetValue append to empty array at first index (MAINT-2684)",json,u"[\"alone\"]"); + + # Test deleting + json = u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6,null]}]"; + json = llJsonSetValue(json,[1,u"b",1],JSON_DELETE); + verify("llJsonSetValue deleting string in middle of array",json,u"[[1,2,3],{\"a\":3,\"b\":[true,6,null]}]"); + json = llJsonSetValue(json,[1,u"b",2],JSON_DELETE); + verify("llJsonSetValue deleting null at end of array",json,u"[[1,2,3],{\"a\":3,\"b\":[true,6]}]"); + json = llJsonSetValue(json,[1,u"b"],JSON_DELETE); + verify("llJsonSetValue deleting key-value",json,u"[[1,2,3],{\"a\":3}]"); + json = llJsonSetValue(json,[1],JSON_DELETE); + verify("llJsonSetValue deleting object in array",json,u"[[1,2,3]]"); + json = u"[[1,2,3],4]"; + json = llJsonSetValue(json,[0],JSON_DELETE); + verify("llJsonSetValue deleting array (which is first index in array)",json,u"[4]"); + json = llJsonSetValue(json,[0],JSON_DELETE); + verify("llJsonSetValue deleting last element in array",json,u"[]"); + json = u"[[1]]"; + json = llJsonSetValue(json,[0,0],JSON_DELETE); + verify("llJsonSetValue deleting last element in array",json,u"[[]]"); + json = llJsonSetValue(json,[0],JSON_DELETE); + verify("llJsonSetValue deleting array within array",json,u"[]"); + + # Test failures in deleting + json = u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6,null]}]"; + verify("llJsonSetValue deleting undefined key-value in object",llJsonSetValue(json,[1,u"d"],JSON_DELETE),JSON_INVALID); + verify("llJsonSetValue deleting out-of-range index in array",llJsonSetValue(json,[2],JSON_DELETE),JSON_INVALID); + verify("llJsonSetValue deleting depth within object that doesn't exist",llJsonSetValue(json,[1,u"a",u"unicorn"],JSON_DELETE),JSON_INVALID); + verify("llJsonSetValue deleting depth within array that doesn't exist",llJsonSetValue(json,[0,1,1],JSON_DELETE),JSON_INVALID); + + # this is the only failure mode that should exist. + json = u"[[1,2,3],{\"a\":3,\"b\":[true,\"foo\",6]}]"; + json = llJsonSetValue(json,[3],JSON_FALSE); + verify("llJsonSetValue fail to insert data into invalid array index (MAINT-2675)",json,JSON_INVALID); + +def test_json_to_list(): + l = llJson2List(u"[[1,2,3],{\"a\":3,\"b\":[true,\"test\",6]}]"); + verify_list("llJson2List first",l,[u"[1,2,3]",u"{\"a\":3,\"b\":[true,\"test\",6]}"]); + n = llJson2List(llList2String(l,0)); + verify_list("llJson2List l,0",n,[1,2,3]); + n = llJson2List(llList2String(l,1)); + verify_list("llJson2List l,1",n,[u"a",3,u"b",u"[true,\"test\",6]"]); + n = llJson2List(llList2String(n,3)); + verify_list("llJson2List n,3",n,[JSON_TRUE, u"test", 6]); + n = llJson2List(llList2String(n,1)); + verify_list("llJson2List n,1",n,[u"test"]); + n = llJson2List(u""); + verify_list("Empty JSON string becomes empty list",n,[]); + n = llJson2List(u"[]"); + verify_list("Empty JSON array becomes empty list (MAINT-2678)",n,[]); + n = llJson2List(u"{}"); + verify_list("Empty JSON object becomes empty list (MAINT-2678)",n,[]); + n = llJson2List(u"Non-JSON string, with comma"); + verify_list("llJson2List for non-JSON string is stored as a single object",n,[u"Non-JSON string, with comma"]); + n = llJson2List(u"[malformed}"); + verify_list("llJson2List, malformed input",n,[u"[malformed}"]); + +def test_list_to_json(): + TRUE=1 + # test objects + json = llList2Json(JSON_OBJECT,[u"a",1,u"b",2.5,u"c",u"test",u"d",u"true",u"e",u"[1,2,3]"]); + verify("llList2Json, json object",json,u"{\"a\":1,\"b\":2.500000,\"c\":\"test\",\"d\":true,\"e\":[1,2,3]}"); + + # test arrays + json = llList2Json(JSON_ARRAY,[1,2.5,u"test",u"true",u"[1,2,3]"]); + verify("llList2Json, json array",json,u"[1,2.500000,\"test\",true,[1,2,3]]"); + + # test arrays + json = llList2Json(JSON_ARRAY,[1,2.5,u"test",JSON_TRUE,u"[1,2,3]"]); + verify("llList2Json, json array, alternative true representation",json,u"[1,2.500000,\"test\",true,[1,2,3]]"); + + # test objects, with empty input + json = llList2Json(JSON_OBJECT,[]); + verify("llList2Json, json object with empty input (MAINT-2681)",json,u"{}"); + + # test arrays, with empty input + json = llList2Json(JSON_ARRAY,[]); + verify("llList2Json, json array with empty input (MAINT-2681)",json,u"[]"); + + # test objects which are truncated + json = llList2Json(JSON_OBJECT,[u"a",1,u"b",2.5,u"c",u"test",u"d",u"true",u"e"]); + verify("llList2Json, json object, truncated",json,JSON_INVALID); + + # test objects which has a non-string identifier somewhere + json = llList2Json(JSON_OBJECT,[u"a",1,TRUE,2.5,u"c",u"test",u"d",u"true",u"e"]); + verify("llList2Json, json object, non-string in one of the first stride values",json,JSON_INVALID); + + # test invalid type + json = llList2Json(u"foo",[u"a",1,u"b",2.5,u"c",u"test",u"d",u"true",u"e",u"[1,2,3]"]); + verify("llList2Json, json invalid type",json,JSON_INVALID); + +def test_strings_with_escaped_chars(): + escaped_pairs = [ + (u"funky\"string", u"funky\\\"string", "quote in middle"), + (u"funkystr\"ing", u"funkystr\\\"ing", "quote in middle, other position"), + # note that we have to double-up backslashes to assign them to strings.. + (u"funky\\string", u"funky\\\\string", "backslashes in middle"), + (u"\\funkystring", u"\\\\funkystring", "backslashes at beginning"), + (u"funky\nstring", u"funky\\nstring", "newline in string"), + (u"funky/string", u"funky\\/string", "forward slash in string"), + # TAB (\t) fails, because it seems that LSL automatically converts any tab into 4 consecutive spaces. + (u"funky\tstring", u"funky\\tstring", "tab in string"), # we enable it, with some mods + # these cases fail; it seems that LSL doesn't support these characters, and strips the '\' + (u"funky\x08string", u"funky\\bstring", "backspace in middle"), # we enable it, with some mods + (u"funky\x0Cstring", u"funky\\fstring", "form feed in middle"), # we enable it, with some mods + (u"funky\rstring", "funky\\rstring", "carriage return in string"), # we enable it, with some mods + # note that the following case can't be supported, since strings starting with \" can't be escaped + (u"\"funkystring", u"\\\"funkystring", "quote in beginning"), # we enable it as it's supported + (u"vanilla string", u"vanilla string", "nothing that needs to be escaped..") + ]; + for funky_string, funky_string_escaped, escaped_desc1 in escaped_pairs: + escaped_desc = " '" + escaped_desc1 + "'" + + verify("Type of string with escaped char (for MAINT-2698),"+escaped_desc,llJsonValueType(u"\""+funky_string_escaped+u"\"",[]),JSON_STRING); + + json = u"[[1,2,3,4.0],{\""+funky_string_escaped+u"\":3,\"b\":\""+funky_string_escaped+u"value\"}]"; + verify("llJsonGetValue [1,\""+str(funky_string_escaped)+"\"] (for MAINT-2698),"+escaped_desc, + llJsonGetValue(json,[1,funky_string]),"3"); + verify("llJsonGetValue [1,\"b\"] (for MAINT-2698),"+escaped_desc,llJsonGetValue(json,[1,u"b"]),funky_string+u"value"); + + #llSay(0, "DEBU G: '" + llEscapeURL(json) + "' is input for test " + escaped_desc); + json = llJsonSetValue(json,[0],funky_string); + verify("llJsonSetValue with escaped string as value (for MAINT-2698),"+escaped_desc,json, + u"[\""+funky_string_escaped+u"\",{\""+funky_string_escaped+u"\":3,\"b\":\""+funky_string_escaped+u"value\"}]"); + + json = llJsonSetValue(json,[0],funky_string); + verify("llJsonSetValue with escaped string as value (for MAINT-2698),"+escaped_desc,json, + u"[\""+funky_string_escaped+u"\",{\""+funky_string_escaped+u"\":3,\"b\":\""+funky_string_escaped+u"value\"}]"); + + json = llJsonSetValue(json,[0,funky_string], funky_string+u"value"); + verify("llJsonSetValue with escaped string as key's value (for MAINT-2698),"+escaped_desc,json, + u"[{\""+funky_string_escaped+u"\":\""+funky_string_escaped+u"value\"},{\""+funky_string_escaped+u"\":3,\"b\":\""+funky_string_escaped+u"value\"}]"); + + l = llJson2List(json); + verify_list("llJson2List extracting object containing escaped string (for MAINT-2698),"+escaped_desc, l, + [u"{\""+funky_string_escaped+u"\":\""+funky_string_escaped+u"value\"}",u"{\""+funky_string_escaped+u"\":3,\"b\":\""+funky_string_escaped+u"value\"}"]); + n = llJson2List(llList2String(l, 0)); + verify_list("llJson2List extracting escaped strings (for MAINT-2698),"+escaped_desc, n, + [funky_string,funky_string+u"value"]); + + json = llList2Json(JSON_ARRAY,n); + verify("llList2Json from escaped-containing string to array (for MAINT-2698),"+escaped_desc,json, + u"[\""+funky_string_escaped+u"\",\""+funky_string_escaped+u"value\"]"); + + json = llList2Json(JSON_OBJECT,n); + verify("llList2Json from escaped-containing string to object (for MAINT-2698),"+escaped_desc,json, + u"{\""+funky_string_escaped+u"\":\""+funky_string_escaped+u"value\"}"); + +def maint3070(): + verify("Set value 'messa[g]e'", llJsonSetValue(u"",[u"toast"],u"messa[g]e"), u"{\"toast\":\"messa[g]e\"}"); + verify("Set value 'messag[e]'", llJsonSetValue(u"",[u"toast"],u"messag[e]"), u"{\"toast\":\"messag[e]\"}"); + #verify("Set value 'messag\[e\]'", llJsonSetValue(u"",[u"toast"],u"messag\[e\]"), u"{\"toast\":\"messag[e]\"}"); + # ^^ BROKEN!!!!! LSL does not include the backslashes in the strings, so the above test is redundant. + # Python does, thus making that test would break it. We include our own test tho: + \ +verify("Set value 'messag\\[e\\]'", llJsonSetValue(u"",[u"toast"],u"messag\\[e\\]"), u"{\"toast\":\"messag\\\\[e\\\\]\"}"); + +def maint4187(): + verify("Valid json number with + before exponent", llJsonValueType(u"1.0e+1", []), JSON_NUMBER); + verify("Valid json number with - before exponent", llJsonValueType(u"1.0e-1", []), JSON_NUMBER); + verify("Valid json number with - before exponent and mantissa", llJsonValueType(u"-1.0e-1", []), JSON_NUMBER); + verify("Valid json number with unsigned exponent", llJsonValueType(u"1.0e1", []), JSON_NUMBER); + verify("Invalid json number due to + before mantissa", llJsonValueType(u"+1.0e1", []), JSON_INVALID); + + verify("Invalid json number due to leading e", llJsonValueType(u"e1", []), JSON_INVALID); + verify("Invalid json number due to leading 0", llJsonValueType(u"01", []), JSON_INVALID); + verify("Invalid json number due to leading -0", llJsonValueType(u"-01", []), JSON_INVALID); + verify("Valid json number with 0 immediately before .", llJsonValueType(u"0.01", []), JSON_NUMBER); + verify("Valid json number with -0 immediately before .", llJsonValueType(u"-0.01", []), JSON_NUMBER); + +def maint3053(): + jT1 = u"[1, 2]"; # A JSON array + verify("llJsonSetValue(jT1,[2],\"t\")",llJsonSetValue(jT1,[2],u"t"),u"[1,2,\"t\"]"); + verify("llJsonSetValue(jT1,[3],\"t\")",llJsonSetValue(jT1,[3],u"t"),JSON_INVALID); + verify("llJsonSetValue(jT1,[0, 0],\"t\")",llJsonSetValue(jT1,[0, 0],u"t"),u"[[\"t\"],2]"); + verify("llJsonSetValue(jT1,[0, 0, 2, \"t\", 75],\"t\")",llJsonSetValue(jT1,[0, 0, 2, u"t", 75],u"t"),JSON_INVALID); + verify("llJsonSetValue(jT1,[0, 1],\"t\")",llJsonSetValue(jT1,[0, 1],u"t"),JSON_INVALID); + verify("llJsonSetValue(jT1,[0, 1, 2, \"t\", 75],\"t\")",llJsonSetValue(jT1,[0, 1, 2, u"t", 75],u"t"),JSON_INVALID); + + jT2 = u"[ [\"A\", \"B\", \"C\"], 2]"; + verify("llJsonSetValue(jT2,[0, 3],\"t\")",llJsonSetValue(jT2,[0, 3],u"t"),u"[[\"A\",\"B\",\"C\",\"t\"],2]"); + verify("llJsonSetValue(jT2,[0, 4],\"t\")",llJsonSetValue(jT2,[0, 4],u"t"),JSON_INVALID); + verify("llJsonSetValue(jT2,[0, 1, 0],\"t\")",llJsonSetValue(jT2,[0, 1, 0],u"t"),u"[[\"A\",[\"t\"],\"C\"],2]"); + verify("llJsonSetValue(jT2,[0, 1, 1],\"t\")",llJsonSetValue(jT2,[0, 1, 1],u"t"),JSON_INVALID); + + jT3 = u"{\"1\":2}"; + verify("llJsonSetValue(jT3,[\"1\"],\"t\")",llJsonSetValue(jT3,[u"1"],u"t"),u"{\"1\":\"t\"}"); + verify("llJsonSetValue(jT3,[\"1\",0],\"t\")",llJsonSetValue(jT3,[u"1",0],u"t"),u"{\"1\":[\"t\"]}"); + verify("llJsonSetValue(jT3,[\"1\",1],\"t\")",llJsonSetValue(jT3,[u"1",1],u"t"),JSON_INVALID); + + jGood = u"[null, 2]"; + verify("llJsonValueType(jGood, [0])",llJsonValueType(jGood, [0]),JSON_NULL); + verify("llJsonValueType(jGood, [0, 0])",llJsonValueType(jGood, [0, 0]),JSON_INVALID); + + jBad = u"[, 2]"; + verify("llJsonValueType(jBad,[0])",llJsonValueType(jBad,[0]),JSON_INVALID); + verify("llJsonValueType(jBad,[0, 0, 2, \"t\", 75])",llJsonValueType(jBad,[0, 0, 2, u"t", 75]),JSON_INVALID); + verify("llJsonGetValue(jBad,[1, 0, 2, \"t\", 75])",llJsonGetValue(jBad,[1, 0, 2, u"t", 75]),JSON_INVALID); + +def maint3081(): + verify("llJsonSetValue blank string",llJsonSetValue(u"",[u"test"],u""),u"{\"test\":\"\"}"); + verify("llJsonSetValue JSON_NULL",llJsonSetValue(u"",[u"test"],JSON_NULL),u"{\"test\":null}"); + verify("llJsonGetValue blank string",llJsonGetValue(u"{\"test\":\"\"}",[u"test"]),u""); + verify("llJsonGetValue JSON_NULL",llJsonGetValue(u"{\"test\":null}",[u"test"]),JSON_NULL); + verify("Identity (set->get) blank string",llJsonGetValue(llJsonSetValue(u"",[u"test"],u""),[u"test"]),u""); + verify("Identity (set->get) JSON_NULL",llJsonGetValue(llJsonSetValue(u"",[u"test"],JSON_NULL),[u"test"]),JSON_NULL); + +def test_jira_fixes(): + # FIXME: llJsonSetValue pending + #maint3070(); + if 6466 not in Bugs: + maint4187(); + # FIXME: llJsonSetValue pending + #maint3053(); + # FIXME: llJsonSetValue pending + #maint3081(); + +# End JSON tests from wiki + +def do_tests(): + + shouldexcept('div(1.0, 0.0)', ELSLMathError) + shouldexcept('div(1, 0)', ELSLMathError) + shouldexcept('zstr("blah")', ELSLInvalidType) + test(r'zstr(Key(u"xy\0zzy"))', Key(u'xy')) + test('typecast(Infinity, unicode)', u'Infinity') + test('typecast(NaN, unicode)', u'NaN') + test('typecast(Vector((NaN,-Infinity,-0.)), unicode)', u'') + lslcommon.LSO = True + test('typecast(Vector((NaN,-Infinity,-0.)), unicode, True, True)', u'') + lslcommon.LSO = False + test('typecast(Vector((NaN,2.,3.)), list)', [Vector((NaN,2.,3.))]) + test('typecast([Vector((NaN,2.,-Infinity))], list)', [Vector((NaN,2.,-Infinity))]) + + shouldexcept('typecast(1.2, Vector)', ELSLTypeMismatch) + shouldexcept('typecast(1, Vector)', ELSLTypeMismatch) + shouldexcept('typecast(Vector((1.,2.,3.)), Key)', ELSLTypeMismatch) + shouldexcept('typecast(Quaternion((1.,2.,3.,0.)), Key)', ELSLTypeMismatch) + shouldexcept('typecast(Key(u""), Vector)', ELSLTypeMismatch) + shouldexcept('typecast(Key(u""), Vector)', ELSLTypeMismatch) + test('typecast(Key(u"xyz"), unicode)', u'xyz') + test('typecast(u"xyz", Key)', Key(u'xyz')) + test('typecast(u"3.14e+0a", int)', 3) + test('typecast(u"a3.14e+0a", int)', 0) + test('typecast(u"0XA3.14e+0a", int)', 0xA3) + test('typecast(u"3333333333333", int)', -1) + test('typecast(u"4124567890", int)', -170399406) + test('typecast(u"-4124567890", int)', 170399406) + test('typecast(u"3.14e+0a", float)', F32(3.14)) + test('typecast(u"++3.14e+0a", float)', F32(0.)) + test('typecast(u"0x3.14p+0a", float)', F32(float.fromhex('0x3.14p0'))) + test('typecast(u"<5.31,7.13,0x9.99", Vector)', F32(Vector((5.31,7.13,float.fromhex('0x9.99'))))) + test('typecast(u"<5.31, 7.13, 0x9.99>", Vector)', F32(Vector((5.31,7.13,float.fromhex('0x9.99'))))) + test('typecast(u"<5.31 , 7.13 , 0x9.99>", Vector)', ZERO_VECTOR) + test('typecast(u"5.31, 7.13, 0x9.99>", Vector)', ZERO_VECTOR) + test('typecast(u"<5.31, a7.13, 0x9.99>", Vector)', ZERO_VECTOR) + test('typecast(u"<1,1,2+", Vector)', Vector((1.,1.,2.))) + test('typecast(u"<1,1,2a", Vector)', Vector((1.,1.,2.))) + test('typecast(u"<1,1,inf", Vector)', Vector((1.,1.,Infinity))) + test('typecast(u"<1,1,infi", Vector)', ZERO_VECTOR) + test('typecast(u"<1,1,infix", Vector)', ZERO_VECTOR) + test('typecast(u"<1,1,infinity", Vector)', Vector((1.,1.,Infinity))) + test('minus(-2147483648)',-2147483648) + test('minus(2147483647)',-2147483647) + test('minus(Quaternion((-.5,.5,.4,-.4)))',Quaternion((.5,-.5,-.4,.4))) + shouldexcept('minus(u"3")', ELSLTypeMismatch) + test('add(-2147483648,-1)', 2147483647) + test('add(-2147483648.,-1.)', -2147483648.) + test('add(-2147483648.,-1)', -2147483648.) + test('add(-2147483648,-1.)', -2147483648.) + test('add(Vector((1.,2.,3.)),Vector((2.,4.,6.)))', Vector((3.,6.,9.))) + test('add(Quaternion((1.,2.,3.,4.)),Quaternion((2.,4.,6.,8.)))', Quaternion((3.,6.,9.,12.))) + test('add([u"1"],[u"2"])', [u'1',u'2']) + test('add(u"1",[u"2"])', [u'1',u'2']) + test('add([u"1"],u"2")', [u'1',u'2']) + test('add(u"1",u"2")', u'12') + test('sub(1,2)', -1) + test('sub(1.,2)', -1.) + test('sub(1,2.)', -1.) + test('sub(1.,2.)', -1.) + test('sub(-2147483647,2)', 2147483647) + test('sub(Vector((1.,2.,3.)),Vector((2.,4.,6.)))', Vector((-1.,-2.,-3.))) + test('sub(Quaternion((1.,2.,3.,4.)),Quaternion((2.,4.,6.,8.)))', Quaternion((-1.,-2.,-3.,-4.))) + test('mul(2.,Vector((1.,2.,3.)))', Vector((2.,4.,6.))) + test('mul(Quaternion((.5,.5,.5,.5)),Quaternion((1.,0.,0.,0.)))', Quaternion((.5,-.5,.5,-.5))) + test('mul(1,2)', 2) + test('mul(1.,2)', 2.) + test('mul(1,2.)', 2.) + test('mul(1.,2.)', 2.) + test('mul(Vector((3.,4.,5.)),Vector((3.,4.,5.)))', 50.) + test('mul(Vector((3.,4.,5.)),1.)', Vector((3.,4.,5.))) + test('mul(Vector((3.,4.,5.)),ZERO_ROTATION)', Vector((3.,4.,5.))) + test('mul(Vector((3.,4.,5.)),Quaternion((.5,.5,.5,.5)))', Vector((5.,3.,4.))) + shouldexcept('add(Key(u"1"),Key(u"2"))', ELSLTypeMismatch) + shouldexcept('sub(u"1",u"2")', ELSLTypeMismatch) + shouldexcept('mul(u"1",u"2")', ELSLTypeMismatch) + shouldexcept('mul(1.,Quaternion((1.,2.,3.,4.)))', ELSLTypeMismatch) + shouldexcept('mul(Quaternion((1.,2.,3.,4.)),1.)', ELSLTypeMismatch) + shouldexcept('mul(Quaternion((1.,2.,3.,4.)),Vector((1.,2.,3.)))', ELSLTypeMismatch) + shouldexcept('mul("a",3)', ELSLInvalidType) + shouldexcept('mul(Vector((3.,4.,5.)),"a")', ELSLInvalidType) + shouldexcept('typecast([1,F32(3.14),Key(u"blah"),Quaternion((1.,0.,0.,0.))], Vector)', + ELSLTypeMismatch) + shouldexcept('typecast(b"", unicode)', ELSLInvalidType) + + + test('''llListSort( + [Quaternion((1.,2.,3.,4.)),Quaternion((2.,3.,4.,5.)),Quaternion((5.,4.,3.,2.)), + Quaternion((4.,3.,2.,1.)),Quaternion((3.,2.,1.,0.))] + ,1,0)''', + [Quaternion((3.,2.,1.,0.)),Quaternion((4.,3.,2.,1.)),Quaternion((5.,4.,3.,2.)), + Quaternion((2.,3.,4.,5.)),Quaternion((1.,2.,3.,4.))] + ) + + test('''llListSort( + [Quaternion((1.,2.,3.,4.)),Quaternion((2.,3.,4.,5.)),Quaternion((5.,4.,3.,2.)), + Quaternion((4.,3.,2.,1.)),Quaternion((3.,2.,1.,0.))] + ,1,1)''', + [Quaternion((1.,2.,3.,4.)),Quaternion((2.,3.,4.,5.)),Quaternion((5.,4.,3.,2.)), + Quaternion((4.,3.,2.,1.)),Quaternion((3.,2.,1.,0.))] + ) + + test('''llListSort( + [Vector((1.,0.,0.)),Vector((0.,3.,0.)),Vector((0.,0.,1.)),Vector((3.,0.,0.))] + ,1,1)''', + [Vector((1.0, 0.0, 0.0)), Vector((0.0, 0.0, 1.0)), Vector((0.0, 3.0, 0.0)), Vector((3.0, 0.0, 0.0))] + ) + + test('''llListSort([2,0,1,1,2,2,2,3,2,4,1,5,2,6], 2, 1)''', + [1, 1, 1, 5, 2, 2, 2, 3, 2, 4, 2, 0, 2, 6]) + test('''llListSort([2,0,1,1,2,2,2,3,2,4,1,5,2,6], 2, 0)''', + [2, 6, 2, 4, 2, 3, 2, 2, 2, 0, 1, 5, 1, 1]) + test('''llListSort([2,0,1,1,2,2,2,3,2,4,1,5,2,6,3], 2, 1)''', + [2, 0, 1, 1, 2, 2, 2, 3, 2, 4, 1, 5, 2, 6, 3]) + + # NaN in sort behaves strangely. Also when inside vectors. + test('llListSort([-1., 9., 3., 2., NaN, 5., 1.], 1, 1)', [1., 5., NaN, -1., 2., 3., 9.]) + test('llListSort([Vector((2.,0.,0.)),Vector((1.,NaN,0.))],1,1)', [Vector((1.,NaN,0.)),Vector((2.,0.,0.))]) + test('llListSort([Vector((1.,NaN,0.)),Vector((2.,0.,0.))],1,1)', [Vector((2.,0.,0.)),Vector((1.,NaN,0.))]) + test('llListSort([Vector((2.,0.,0.)),Vector((1.,NaN,0.))],1,0)', [Vector((2.,0.,0.)),Vector((1.,NaN,0.))]) + test('llListSort([Vector((1.,NaN,0.)),Vector((2.,0.,0.))],1,0)', [Vector((1.,NaN,0.)),Vector((2.,0.,0.))]) + # This proves that it does not sort by UTF-16 words, but by code points. + # Otherwise u"\U0001d41a" would be before u"\ufb01" (because the UTF-16 + # of u"\U0001d41a" is 0xD835 0xDC1A) + test(r'llListSort([u"\ufb01",u"\xe1", u"\U0001d41a", u"a"], 1, 1)', [u'a',u'\xe1',u'\ufb01',u'\U0001d41a']) + + test('llLog(NaN)', 0.) + test('llLog(-Infinity)', 0.) + test('llLog(Infinity)', Infinity) + test('llLog(-1.)', 0.) + test('llLog(-0.)', 0.) + test('llLog(1.)', 0.) + test('llLog(F32(math.e))', F('0x1.FFFFFEp-1')) + test('llLog10(NaN)', 0.) + test('llLog10(-Infinity)', 0.) + test('llLog10(Infinity)', Infinity) + test('llLog10(-1.)', 0.) + test('llLog10(-0.)', 0.) + test('llLog10(1.)', 0.) + test('llLog10(100.)', 2.) + test('llLog(Infinity)', Infinity) + + test('F32(1e38)', 99999996802856924650656260769173209088.) + test('''llList2CSV([F32(1e0),F32(1e1),F32(1e2),F32(1e3),F32(1e4),F32(1e5),F32(1e6), + F32(1e7),F32(1e8),F32(1e9),F32(1e10),F32(1e11),F32(1e12),F32(1e13), + F32(1e14),F32(1e15),F32(1e16),F32(1e17),F32(1e18),F32(1e19),F32(1e20), + F32(1e21),F32(1e22),F32(1e23),F32(1e24),F32(1e25),F32(1e26),F32(1e27), + F32(1e28),F32(1e29),F32(1e30),F32(1e31),F32(1e32),F32(1e33),F32(1e34), + F32(1e35),F32(1e36),F32(1e37),F32(1e38)])''', + u"1.000000, 10.000000, 100.000000, 1000.000000, 10000.000000, 100000.000000, " + u"1000000.000000, 10000000.000000, 100000000.000000, 1000000000.000000, " + u"10000000000.000000, 99999997952.000000, 999999995904.000000, " + u"9999999827968.000000, 100000000376832.000000, 999999986991104.000000, " + u"10000000272564224.000000, 99999998430674944.000000, " + u"999999984306749440.000000, 9999999980506447872.000000, " + u"100000002004087734272.000000, 1000000020040877342720.000000, " + u"9999999778196308361216.000000, 99999997781963083612160.000000, " + u"1000000013848427855085568.000000, 9999999562023526247432192.000000, " + u"100000002537764290115403776.000000, 999999988484154753734934528.000000, " + u"9999999442119689768320106496.000000, " + u"100000001504746621987668885504.000000, " + u"1000000015047466219876688855040.000000, " + u"9999999848243207295109594873856.000000, " + u"100000003318135351409612647563264.000000, " + u"999999994495727286427992885035008.000000, " + u"9999999790214767953607394487959552.000000, " + u"100000004091847875962975319375216640.000000, " + u"999999961690316245365415600208216064.000000, " + u"9999999933815812510711506376257961984.000000, " + u"99999996802856924650656260769173209088.000000") + + test('llDumpList2String([F32(1e11)], "/")', u'100000000000.000000') + + # Inputs + inp = [F32(i) for i in [1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, + 1e15, 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, 1e30, + 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38]] + + # Expected + exp = [ + u'1.000000',u'10.000000',u'100.000000',u'1000.000000',u'10000.000000',u'100000.000000', + u'1000000.000000',u'10000000.000000',u'100000000.000000',u'1000000000.000000',u'10000000000.000000', + u'100000000000.000000',u'1000000000000.000000',u'10000000000000.000000',u'100000000000000.000000', + u'1000000000000000.000000',u'10000000000000000.000000',u'100000000000000000.000000', + u'1000000000000000000.000000',u'10000000000000000000.000000',u'100000000000000000000.000000', + u'1000000000000000000000.000000',u'10000000000000000000000.000000', + u'100000000000000000000000.000000',u'1000000000000000000000000.000000', + u'10000000000000000000000000.000000',u'100000000000000000000000000.000000', + u'1000000000000000000000000000.000000',u'9999999000000000000000000000.000000', + u'100000000000000000000000000000.000000',u'1000000000000000000000000000000.000000', + u'10000000000000000000000000000000.000000',u'100000000000000000000000000000000.000000', + u'1000000000000000000000000000000000.000000',u'10000000000000000000000000000000000.000000', + u'100000000000000000000000000000000000.000000',u'1000000000000000000000000000000000000.000000', + u'10000000000000000000000000000000000000.000000',u'100000000000000000000000000000000000000.000000' + ] + + for i in range(len(inp)): + test('typecast('+repr(inp[i])+',unicode)', exp[i]) + + # Mono mode + test('f2s(F32(-.5e-6), 6)', u'-0.000001') + test('f2s(F("-0x1.0C6F7Ap-21"), 6)', u'-0.000001') # = F32(-.5e-6) so this test is redundant + test('f2s(F("0x1.0C6F7Ap-21"), 6)', u'0.000001') + test('f2s(F("-0x1.0C6F78p-21"), 6)', u'0.000000') + test('f2s(F("0x1.0C6F78p-21"), 6)', u'0.000000') + test('f2s(F32(.5e-5), 5)', u'0.00001') + test('f2s(F("-0x1.4F8B58p-18"), 5)', u'-0.00001') # = F32(-.5e-5) so this test is redundant + test('f2s(F("0x1.4F8B58p-18"), 5)', u'0.00001') + test('f2s(F("-0x1.4F8B56p-18"), 5)', u'0.00000') + test('f2s(F("0x1.4F8B56p-18"), 5)', u'0.00000') + + test('f2s(F32(-123456789.), 6)', u'-123456800.000000') + test('f2s(F32(-123456784.), 6)', u'-123456800.000000') + + test('f2s(F32(-123456740.), 6)', u'-123456700.000000') + test('f2s(F32(-12345.674), 6)', u'-12345.670000') + test('f2s(F32(-1.2345674), 6)', u'-1.234567') + test('f2s(F32(-1.2345675), 6)', u'-1.234568') + test('f2s(F32(-123456740.), 5)', u'-123456700.00000') + test('f2s(F32(-12345.674), 5)', u'-12345.67000') + test('f2s(F32(-1.2345674), 5)', u'-1.23457') + test('f2s(F32(-1.234564), 5)', u'-1.23456') + + test('f2s(F32(-123456750.), 6)', u'-123456800.000000') + test('f2s(F32(-12345.675), 6)', u'-12345.670000') # I kid you not - that's from LSL + test('f2s(F32(-12345.676), 6)', u'-12345.680000') + test('f2s(F32(-123456750.), 5)', u'-123456800.00000') + test('f2s(F32(-12345.675), 5)', u'-12345.67000') # I kid you not - that's from LSL + test('f2s(F32(-12345.676), 5)', u'-12345.68000') + test('f2s(F32(-12.345675), 5)', u'-12.34568') + test('f2s(F32(1234567.5), 5)', u'1234568.00000') + test('f2s(F32(1234567.5), 6)', u'1234568.000000') + test('f2s(F32(1234567.4), 5)', u'1234567.00000') + test('f2s(F32(1234567.4), 6)', u'1234567.000000') + test('f2s(F32(123456.75), 5)', u'123456.80000') + test('f2s(F32(123456.74), 5)', u'123456.70000') + test('f2s(F32(12345675.), 5)', u'12345680.00000') + test('f2s(F32(12345674.), 5)', u'12345670.00000') + test('f2s(F32(9.999999), 5)', u'10.00000') + + # LSO mode + lslcommon.LSO = True + test('f2s(F32(-.5e-6), 6)', u'-0.000000') + test('f2s(F32(-.51e-6), 6)', u'-0.000001') + test('f2s(F("-0x1.0C6F7Ap-21"), 6)', u'-0.000000') # = F32(-.5e-6) so this test is redundant + test('f2s(F("0x1.0C6F7Ap-21"), 6)', u'0.000000') + test('f2s(F("-0x1.0C6F7Cp-21"), 6)', u'-0.000001') + test('f2s(F("0x1.0C6F7Cp-21"), 6)', u'0.000001') + test('f2s(F32(.5e-5), 5)', u'0.00000') + test('f2s(F("-0x1.4F8B58p-18"), 5)', u'-0.00000') # = F32(-.5e-5) so this test is redundant + test('f2s(F("0x1.4F8B58p-18"), 5)', u'0.00000') + test('f2s(F("-0x1.4F8B5Ap-18"), 5)', u'-0.00001') + test('f2s(F("0x1.4F8B5Ap-18"), 5)', u'0.00001') + + test('f2s(F32(-123456789.), 6)', u'-123456792.000000') + test('f2s(F32(-123456784.), 6)', u'-123456784.000000') + + test('f2s(F32(-123456740.), 6)', u'-123456736.000000') + test('f2s(F32(-12345.674), 6)', u'-12345.673828') + test('f2s(F32(-1.2345674), 6)', u'-1.234567') + test('f2s(F32(-1.2345675), 6)', u'-1.234568') + test('f2s(F32(-123456740.), 5)', u'-123456736.00000') + test('f2s(F32(-12345.674), 5)', u'-12345.67383') + test('f2s(F32(-1.2345674), 5)', u'-1.23457') + test('f2s(F32(-1.234564), 5)', u'-1.23456') + + test('f2s(F32(-123456750.), 6)', u'-123456752.000000') + test('f2s(F32(-12345.675), 6)', u'-12345.674805') + test('f2s(F32(-12345.676), 6)', u'-12345.675781') + test('f2s(F32(-123456750.), 5)', u'-123456752.00000') + test('f2s(F32(-12345.675), 5)', u'-12345.67480') + test('f2s(F32(-12345.676), 5)', u'-12345.67578') + test('f2s(F32(-12.345675), 5)', u'-12.34568') + test('f2s(F32(1234567.5), 5)', u'1234567.50000') + test('f2s(F32(1234567.5), 6)', u'1234567.500000') + test('f2s(F32(1234567.4), 5)', u'1234567.37500') + test('f2s(F32(1234567.4), 6)', u'1234567.375000') + test('f2s(F32(123456.75), 5)', u'123456.75000') + test('f2s(F32(123456.74), 5)', u'123456.74219') + test('f2s(F32(123456.74), 6)', u'123456.742188') + test('f2s(F32(12345675.), 5)', u'12345675.00000') + test('f2s(F32(12345674.), 5)', u'12345674.00000') + + lslcommon.LSO = False + + # llPow() input matrix + in1 = in2 = [NaN,-Infinity,F32(-2.1),-2.,-1.,F32(-.1),-.0,.0,F32(.1),1.,2.,F32(2.1),Infinity] + + # Expected results table + exp = [ + NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN,NaN, + NaN,0.,0.,0.,0.,0.,1.,1.,Infinity,-Infinity,Infinity,Infinity,Infinity, + NaN,0.,NaN,F('0x1.D0662Ep-3'),F('-0x1.E79E7Cp-2'),NaN,1.,1.,NaN,F('-0x1.0CCCCCp+1'),F('0x1.1A3D6Ep+2'),NaN,Infinity, + NaN,0.,NaN,.25,-0.5,NaN,1.,1.,NaN,-2.,4.,NaN,Infinity, + NaN,NaN,NaN,1.,-1.,NaN,1.,1.,NaN,-1.,1.,NaN,NaN, + NaN,Infinity,NaN,100.,-10.,NaN,1.,1.,NaN,F('-0x1.99999Ap-4'),F('0x1.47AE16p-7'),NaN,0., + NaN,Infinity,Infinity,Infinity,-Infinity,Infinity,1.,1.,0.,0.,0.,0.,0., + NaN,Infinity,Infinity,Infinity,Infinity,Infinity,1.,1.,0.,0.,0.,0.,0., + NaN,Infinity,F('0x1.F791EEp+6'),100.,10.,F('0x1.4248F0p0'),1.,1.,F('0x1.96B230p-1'),F('0x1.99999Ap-4'),F('0x1.47AE16p-7'),F('0x1.04491Ap-7'),0., + NaN,NaN,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,NaN, + NaN,0.,F('0x1.DDB682p-3'),.25,.5,F('0x1.DDB680p-1'),1.,1.,F('0x1.125FBEp0'),2.,4.,F('0x1.125FBEp+2'),Infinity, + NaN,0.,F('0x1.AF30DAp-3'),F('0x1.D0662Ep-3'),F('0x1.E79E7Cp-2'),F('0x1.DB6346p-1'),1.,1.,F('0x1.13B748p0'),F('0x1.0CCCCCp+1'),F('0x1.1A3D6Ep+2'),F('0x1.2FFA0Ep+2'),Infinity, + NaN,0.,0.,0.,0.,0.,1.,1.,Infinity,Infinity,Infinity,Infinity,Infinity, + ] + + idx = 0 + for i in in1: + for j in in2: + test('llPow(' + repr(i) + ',' + repr(j) + ')', exp[idx]) + idx += 1 + + test('llCos(NaN)', NaN) + test('llCos(Infinity)', NaN) + test('llCos(-Infinity)', NaN) + test('llCos(math.pi)', -1.) + test('llCos(1000.)', F('0x1.1FF026p-1')) + test('llCos(1000000.)', F('0x1.DF9DFAp-1')) + test('llCos(1000000000.)', F('0x1.ACFF8Cp-1')) + test('llCos(-1000000000.)', F('0x1.ACFF8Cp-1')) + #test('llCos(F("0x.FFFFFFp+63"))', F('-0x1.F4E122p-1')) # alas, doesn't match + test('abs(llCos(F("0x.FFFFFFp+63")) - F("-0x1.F4E122p-1")) < 0.003', True) # workaround + test('llSin(NaN)', NaN) + test('llSin(Infinity)', NaN) + test('llSin(-Infinity)', NaN) + test('llSin(F32(math.pi))', F('-0x1.777A5Cp-24')) + test('llSin(1000.)', F('0x1.A75CC2p-1')) + test('llSin(1000000.)', F('-0x1.6664B2p-2')) + test('llSin(1000000000.)', F('0x1.1778CAp-1')) + test('llSin(-1000000000.)', F('-0x1.1778CAp-1')) + test('llSin(F32(1e38))', F32(1e38)) + #test('llSin(F("0x.FFFFFFp+63"))', F('0x1.A8862Cp-3')) # alas, doesn't match + test('abs(llSin(F("0x.FFFFFFp+63")) - F("0x1.A8862Cp-3")) < 0.012', True) # workaround + test('llTan(F32(1e38))', F32(1e38)) + test('llTan(F32(4e38))', NaN) + test('llTan(F32(math.pi))', F('0x1.777A5Cp-24')) + test('llTan(F32(math.pi*.5))', -22877330.) + test('llTan(F("0x1.921FB4p0"))', 13245400.) + + testXB64S("", "", "") + testXB64S(u"Hello, World!", u"", u"Hello, World!") + testXB64S("AAAAA==AAAAA=", "_X", "/X/X/==X/X/X=") + testXB64S("AAAAAA......AAAAAAA", "BCDEFG=====", "BCDEFG======CDEFGBC") + testXB64S("AAAAA===AAAAAAAAAAA", "BCDEF", "BCDEF===EFBCDEFBCDE") + testXB64S("Hello, World!", "A", "Hello==World=") + testXB64S("Hello, World!", "A=", "Hello==World=") + testXB64S("Hello, World!", "A?", "Hello==World=") + testXB64S("Hello, World!", "A?A", "Hello==World=") + testXB64S("Hello, World!", "+", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "++", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "=", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+=", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+?", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+??", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+???", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+????", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+?????", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "+???????", "5gbbW==oWVbj=") + testXB64S("Hello, World!", "/", "4haaX==pXUai=") + testXB64S("Hello, World!", "//", "4haaX==pXUai=") + testXB64S("Hello, World!", "^", "4haaX==pXUai=") + testXB64S("Hello, World!", ".", "4haaX==pXUai=") + testXB64S("Hello, World!", "_", "4haaX==pXUai=") + testXB64S("Hello, World!", "_XX", "4Jya/==B/UyK=") + testXB64S("Hello, World!", "XYZ", "QG8yw==Ox89E=") + testXB64S("Hello, World!", "XYZ?", "QG8yw==BwyyF=") + testXB64S("Hello, World!", "XYZXYZ", "QG8yw==Ox89E=") + testXB64S("Hello, World!", "XYZXYZ==", "QG8yw==BwyyF=") + testXB64S("AAAAA===AAAAAAAAAAA", "BCDEF", "BCDEF===EFBCDEFBCDE") + testXB64S("AAAAA===AAAAAAAAAAA", "BCDEF=", "BCDEF===DEFBCDEFBCD") + testXB64S("AAAAA===AAAAAAAAAAA", "BCDEF==", "BCDEF===CDEFBCDEFBC") + testXB64S("AAAAA===AAAAAAAAAAA", "BCDEF===", "BCDEF===BCDEFBCDEFB") + testXB64S("AA_AAA______AAAAAAAAAAAAA", "BC=EFG==", + "BC=EFG======FGBCBCBCBCBCB") + testXB64S("AA_AAA______AAAAAA=AAAAAA", "BC=EFG==", + "BC=EFG======FGBCBC=EFGBCB") + testXB64S("AAAAA==AAAAA", "_XXXXXXX", "/XXXX==X/XXX") + testXB64S("ABCDABCDABCDABCDABCDABCDABCD", "ABCD", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + testXB64S("BCDABCDABCDABCDABCDABCDABCDA", "BCDA", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + testXB64S("AQCDAQCD", "AQC=", "AAADQSCT") + testXB64S("AA_AAA______AAAAAAAAAAAAA", "=5gbbW==oWVbj=", "+5=bbW======j+5gbbW+5gbbW") + + testXB64SC(u"\U00012345", "", u"\U00012345") + testXB64SC("AABA", "1234", "1224") + testXB64SC("1234", "AABA", "1234") + testXB64SC("BAAA", "1234", "0234") + testXB64SC("1234", "BAAA", "02n8") + testXB64SC("AABA", "AABA", "AABA") + testXB64SC("AABA", "AABC", "AABA") + testXB64SC("AABC", "AABA", "AABC") + testXB64SC("Hello, World!", "XYZXYZ", "QG8y") + testXB64SC("QG8y", "XYZXYZ", "Hell") + testXB64SC("ABCDABCDABCDABCDABCDABCDABCD", "ABCD", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + testXB64SC("BCDABCDABCDABCDABCDABCDABCDA", "BCDA", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + testXB64SC("ABCD", "ABCD", "AAAA") + testXB64SC("ABCDABCDABCD", "ABCD", "AAAAAAAAAAAA") + testXB64SC("AACD", "AACD", "AACD") + testXB64SC("AQCD", "AQCD", "AAGC") + testXB64SC("AQCD", "AQC=", "AAGC") + testXB64SC("AQCD", "AQC=", "AAGC") + testXB64SC("AQCDAQCD", "AQC=", "AAGCAAGC") + testXB64SC("AQCD", "AQCD", "AAGC") + testXB64SC("AQCDAQCD", "AQCD", "AAGCAAGC") + testXB64SC("ACCD", "AC==", "ACCD") + testXB64SC("ABCD", "AB==", "ABCD") + testXB64SC("ABCD", "ABC=", "AACD") + testXB64SC("APCD", "APC=", "AACD") + testXB64SC("AQCD", "AQC=", "AAGC") + testXB64SC("ACCD", "ABC=", "ADCD") + testXB64SC("ARCD", "ARC=", "AACC") + testXB64SC("ABCDABCDABCDABCDABCDABCDABCD", "AB==", + "ABCDABCDABCDABCDABCDABCDABCD") + testXB64SC("ABCDABCDABCDABCDABCDABCDABCD", "AQ==", + "ARGCARGCARGCARGCARGCARGCARGC") + testXB64SC("ABCDABCDABCDABCDABCDABCDABCD", "ABCDAP//", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + + testXB64(u"\U00012345", "", u"\U00012345") + testXB64("AABA", "1234", "1224") + testXB64("1234", "AABA", "1224") + testXB64("BAAA", "1234", "0234") + testXB64("1234", "BAAA", "0234") + testXB64("AABA", "AABA", "AAAA") + testXB64("AABA", "AABC", "AAAC") + testXB64("AABC", "AABA", "AAAC") + testXB64("Hello, World!", "XYZXYZ", "QG8y") + testXB64("QG8y", "XYZXYZ", "Hell") + testXB64("ABCDABCDABCD", "ABCD", "AAAAAAAAABCT", True) + testXB64("ABCDABCDABCDABCDABCDABCDABCD", "ABCD", + "AAAAAAAAABCTgxCDEJODAAAAABCT", True) + testXB64("ABCDABCDABCD", "ABCD", "AAAAAAAAAAAA") + testXB64("ABCDABCDABCDABCDABCDABCDABCD", "ABCD", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAA") + testXB64S ("ABCDABCDABCD", "ABC=", "AAADBDCCCBDB") + testXB64SC("ABCDABCDABCD", "ABC=", "AACDEBCTAACD") + testXB64 ("ABCDABCDABCD", "ABC=", "AACDEBCDEBCD", True) + testXB64 ("ABCDABCDABCD", "ABC=", "AACDEBCTAACD") + + testXB64("Stuffs not b64 <^.^>!", "AA==", "Stuffg==") + + # Four different results for the same input strings... + testXB64S ("AQCDAQCD", "AQC=", "AAADQSCT") + testXB64SC("AQCDAQCD", "AQC=", "AAGCAAGC") + testXB64 ("AQCDAQCD", "AQC=", "AACCAQCC", True) + testXB64 ("AQCDAQCD", "AQC=", "AACCAQGD") # the only correct one + + + test('llModPow(65535, 3, 0)', 0) + test('llModPow(65535, 3, 41)', 34) + test('llModPow(65535, 3, -2147483648)', 196607) + test('llModPow(65535, 3, -2147483647)', 131071) + test('llModPow(65533, 3, -2147483648)', 1769445) + test('llModPow(65533, 3, -2147483645)', 1572843) + test('llModPow(65533, 3, 2147483645)', 1966047) + test('llModPow(65533, 3, 555)', 142) + test('llModPow(65533, 3, 1073741823)', 1966045) + test('llModPow(65533, 3, 1073741824)', 1769445) + test('llModPow(65533, 3, 1073741825)', 1572845) + test('llModPow(32767, 3, 1073741825)', 98302) + test('llModPow(32767, 3, 107374182)', 216275) + test('llModPow(32767, 3, 10737418)', 876887) + test('llModPow(32767, 3, 1073741)', 230066) + test('llModPow(32767, 3, 107374)', 54345) + test('llModPow(32767, 3, 507374)', 161343) + test('llModPow(32767, 3, 907374)', 346875) + test('llModPow(32767, 3, 707374)', 690307) + test('llModPow(32767, 3, 607374)', 139309) + test('llModPow(32767, 3, 600374)', 146813) + test('llModPow(32767, 3, 550374)', 389875) + test('llModPow(32767, 3, 520374)', 301047) + test('llModPow(32767, 3, 510374)', 36839) + test('llModPow(32767, 3, 500374)', 115989) + test('llModPow(32767, 3, 300374)', 83681) + test('llModPow(32767, 3, 100374)', 23425) + test('llModPow(32767, 3, 130374)', 64819) + test('llModPow(32767, 3, 132374)', 66641) + test('llModPow(32767, 3, 142374)', 93049) + test('llModPow(32767, 3, 172374)', 59569) + test('llModPow(32767, 3, 192374)', 66591) + test('llModPow(32767, 3, 199374)', 112231) + test('llModPow(32767, 3, 209374)', 54343) + test('llModPow(32767, 3, 259374)', 84733) + test('llModPow(32767, 3, 269374)', 49913) + test('llModPow(32767, 3, 261374)', 85865) + test('llModPow(32767, 3, 260374)', 2379) + test('llModPow(32767, 3, 250374)', 78307) + test('llModPow(32767, 3, 259375)', 99163) + test('llModPow(32767, 3, 260000)', 254367) + test('llModPow(32767, 3, 259999)', 90487) + test('llModPow(32767, 3, 259500)', 19663) + test('llModPow(32767, 3, 259750)', 29663) + test('llModPow(32767, 3, 259850)', 49367) + test('llModPow(32767, 3, 259800)', 164967) + test('llModPow(32767, 3, 259790)', 137017) + test('llModPow(32767, 3, 259770)', 64183) + test('llModPow(32767, 3, 259780)', 237863) + test('llModPow(32767, 3, 259785)', 162132) + test('llModPow(32767, 3, 259782)', 85797) + test('llModPow(32767, 3, 259781)', 157054) + test('llModPow(32767, 2, 259781)', 1416) + test('llModPow(32767, 2, 259782)', 257065) + test('llModPow(32767, 3, 259782)', 85797) + test('llModPow(-1, 3, 259782)', 251271) + test('llModPow(-1, -3, 259782)', 251271) + test('llModPow(0, 0, 0)', 0) + test('llModPow(1, 0, 0)', 0) + test('llModPow(1, 0, 1)', 0) + test('llModPow(1, 0, 2)', 1) + test('llModPow(1, 0, 3)', 1) + test('llModPow(1, 0, 4)', 1) + test('llModPow(1, 1, 1)', 0) + test('llModPow(5, 1, 1)', 0) + test('llModPow(5, 25, 7)', 5) + test('llModPow(5, 25, 13)', 5) + test('llModPow(5, 25, 17)', 12) + test('llModPow(41, 1, 17)', 7) + + test('llListFindList([], [])', 0) + test('llListFindList([NaN], [NaN])', 0) # I swear + test('llListFindList([-0.], [0.])', 0) # Really. + test('llListFindList([0.], [-0.])', 0) # Yes. + test('llListFindList([1, NaN, 1., NaN], [1., NaN])', 2) + test('llListFindList([1, NaN, 1., NaN], [2.])', -1) + test('llListFindList([Vector((NaN,0.,0.))], [Vector((NaN,0.,0.))])', -1) # Yes, really + test('llListFindList([Vector((0.,0.,0.))], [Vector((0.,0.,0.))])', 0) + test('llListFindList([Quaternion((0.,0.,0.,NaN))], [Quaternion((0.,0.,0.,NaN))])', -1) # Python == fails here + test('llListFindList([Quaternion((0.,0.,0.,float("nan")))], [Quaternion((0.,0.,0.,float("nan")))])', -1) + test('llListFindList([],[])', 0) + test('llListFindList([3],[])', 0) + test('llListFindList([3],[3,4,5])', -1) + test('''llListFindList([Key(u"12345678-ABCD-5678-1234-123456781234")], + [Key(u"12345678-abcd-5678-1234-123456781234")])''', -1) + test('''llListFindList([Key(u"12345678-abcd-5678-1234-123456781234")], + [Key(u"12345678-abcd-5678-1234-123456781234")])''', 0) + test('''llListFindList([u"12345678-abcd-5678-1234-123456781234", + Key(u"12345678-abcd-5678-1234-123456781234")], + [Key(u"12345678-abcd-5678-1234-123456781234")])''', 1) + test('llListInsertList([1,2,3],[4,5],-1)', [1,2,4,5,3]) + test('llListInsertList([1,2,3],[4,5],-5)', [4,5,1,2,3]) + + test('llIntegerToBase64(-680658713)', u'12345w==') + test('llIntegerToBase64(-1)', u'/////w==') + test('llIntegerToBase64(0)', u'AAAAAA==') + test('llIntegerToBase64(1)', u'AAAAAQ==') + test('llIntegerToBase64(2)', u'AAAAAg==') + test('llIntegerToBase64(3)', u'AAAAAw==') + test('llIntegerToBase64(-2147483648)', u'gAAAAA==') + test('llIntegerToBase64(2147483647)', u'f////w==') + + test('llBase64ToInteger(u"123456789")', 0) + test('llBase64ToInteger(u"12345A===")', 0) + test('llBase64ToInteger(u"12345678")', -680658713) + test('llBase64ToInteger(u"123456")', -680658713) + test('llBase64ToInteger(u"123456==")', -680658713) + test('llBase64ToInteger(u"12345w==")', -680658713) + test('llBase64ToInteger(u"12345.")', -680658944) + test('llBase64ToInteger(u"gAAAAA")', -2147483648) + test('llBase64ToInteger(u"/////w")', -1) + + s = u''.join(unichr(i) for i in xrange(1,257)) + test('llEscapeURL(' + repr(s) + ')', + u'%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F' + u'%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F0123456789%3A%3B%3C%3D%3E%3F%40ABCDEFGHIJKLMN' + u'OPQRSTUVWXYZ%5B%5C%5D%5E%5F%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D%7E%7F%C2%80%C2%81%C2%82%C2%' + u'83%C2%84%C2%85%C2%86%C2%87%C2%88%C2%89%C2%8A%C2%8B%C2%8C%C2%8D%C2%8E%C2%8F%C2%90%C2%91%C2%92%' + u'C2%93%C2%94%C2%95%C2%96%C2%97%C2%98%C2%99%C2%9A%C2%9B%C2%9C%C2%9D%C2%9E%C2%9F%C2%A0%C2%A1%C2%' + u'A2%C2%A3%C2%A4%C2%A5%C2%A6%C2%A7%C2%A8%C2%A9%C2%AA%C2%AB%C2%AC%C2%AD%C2%AE%C2%AF%C2%B0%C2%B1%' + u'C2%B2%C2%B3%C2%B4%C2%B5%C2%B6%C2%B7%C2%B8%C2%B9%C2%BA%C2%BB%C2%BC%C2%BD%C2%BE%C2%BF%C3%80%C3%' + u'81%C3%82%C3%83%C3%84%C3%85%C3%86%C3%87%C3%88%C3%89%C3%8A%C3%8B%C3%8C%C3%8D%C3%8E%C3%8F%C3%90%' + u'C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%97%C3%98%C3%99%C3%9A%C3%9B%C3%9C%C3%9D%C3%9E%C3%9F%C3%' + u'A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%A8%C3%A9%C3%AA%C3%AB%C3%AC%C3%AD%C3%AE%C3%AF%' + u'C3%B0%C3%B1%C3%B2%C3%B3%C3%B4%C3%B5%C3%B6%C3%B7%C3%B8%C3%B9%C3%BA%C3%BB%C3%BC%C3%BD%C3%BE%C3%' + u'BF%C4%80') + + test(r'llStringToBase64(u"\U0001D11E\xC1a\xF1# +")', u'8J2EnsOBYcOxIyAr') + test('llBase64ToString(u"8J2EnsOBYcOxIyAr")', u'\U0001D11E\xC1a\xF1# +') + test('llBase64ToString(u"")', u'') + test('llBase64ToString(u"1")', u'') + test('llBase64ToString(u"12")', u'?') + test('llBase64ToString(u"14A")', u'\u05C0') # Defer thorough testing of UTF-8 to llUnescapeURL tests + test('typecast([1,F32(3.14),Key(u"blah"),Quaternion((1.,0.,0.,0.))], unicode)', + u'13.140000blah<1.000000, 0.000000, 0.000000, 0.000000>') + + test('''llDumpList2String(llCSV2List(u'a,<<1,2>,3,4,">5,6, "1,3",7<<>,8,9'), u"|")''', + u'a|<<1,2>,3,4,">5|6|"1|3"|7<<>,8,9') + + test('llInsertString(u"", -3, u"abc")', u'abc') + test('llInsertString(u"", -1, u"abc")', u'abc') + test('llInsertString(u"", 0, u"abc")', u'abc') + test('llInsertString(u"", 1, u"abc")', u'abc') + test('llInsertString(u"", 3, u"abc")', u'abc') + + test('llInsertString(u"xy", -3, u"abc")', u'abcxy') + test('llInsertString(u"xy", -1, u"abc")', u'abcxy') + test('llInsertString(u"xy", 0, u"abc")', u'abcxy') + test('llInsertString(u"xy", 1, u"abc")', u'xabcy') + test('llInsertString(u"xy", 2, u"abc")', u'xyabc') + test('llInsertString(u"xy", 3, u"abc")', u'xyabc') + + test('llUnescapeURL(u"%")', u'') + test('llUnescapeURL(u"%%")', u'') + test('llUnescapeURL(u"%4%252Fabc")', u'\x40\x252Fabc') + test('llUnescapeURL(u"%%4%252Fabc")', u'\x04\x252Fabc') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c"))', u'%044%25%02Fa%E2%86%90c') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%"))', u'%044%25%02Fa%E2%86%90c') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%2"))', u'%044%25%02Fa%E2%86%90c') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%%"))', u'%044%25%02Fa%E2%86%90c') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%%2"))', u'%044%25%02Fa%E2%86%90c%02') + test('llEscapeURL(llUnescapeURL(u"%.44%25%%2Fa\u2190c%%%2346"))', u'%044%25%02Fa%E2%86%90c') + test('llEscapeURL(llUnescapeURL(u"%4.%25"))', u'%40%25') + + # test UTF-8 validity + test('llEscapeURL(llUnescapeURL(u"%C3%81%80%E3%81%C3%80ABC%D3"))', u'%C3%81%3F%3F%3F%C3%80ABC%3F') + test('llEscapeURL(llUnescapeURL(u"%C3%81%80%E3%81%C3%80ABC%00%D3"))', u'%C3%81%3F%3F%3F%C3%80ABC') + test('llEscapeURL(llUnescapeURL(u"%E0%80%80%80%80%80%80%E3%81%C3%80ABC%00%D3"))', u'%3F%3F%3F%3F%3F%3F%3F%3F%3F%C3%80ABC') + # test UTF-8 valid ranges + test('llEscapeURL(llUnescapeURL(u"%7Fx"))', u'%7Fx') # range up to U+007F + test('llEscapeURL(llUnescapeURL(u"%80%80x"))', u'%3F%3Fx') # invalid range begin + test('llEscapeURL(llUnescapeURL(u"%BF%BFx"))', u'%3F%3Fx') # invalid range end + test('llEscapeURL(llUnescapeURL(u"%C0%80x"))', u'%3F%3Fx') # aliased range begin (U+0000) + test('llEscapeURL(llUnescapeURL(u"%C1%BFx"))', u'%3F%3Fx') # aliased range end (U+007F) + test('llEscapeURL(llUnescapeURL(u"%C2%80x"))', u'%C2%80x') # U+0080 (2-byte range start) + test('llEscapeURL(llUnescapeURL(u"%DF%BFx"))', u'%DF%BFx') # U+07FF (2-byte range end) + test('llEscapeURL(llUnescapeURL(u"%E0%80%80x"))', u'%3F%3F%3Fx') # aliased range begin (U+0000) + test('llEscapeURL(llUnescapeURL(u"%E0%9F%BFx"))', u'%3F%3F%3Fx') # aliased range end (U+07FF) + test('llEscapeURL(llUnescapeURL(u"%E0%A0%80x"))', u'%E0%A0%80x') # U+0800 (3-byte range start) + test('llEscapeURL(llUnescapeURL(u"%EF%BF%BFx"))', u'%EF%BF%BFx') # U+FFFF (3-byte range end) + test('llEscapeURL(llUnescapeURL(u"%F0%80%80%80x"))', u'%3F%3F%3F%3Fx') # aliased range begin (U+0000) + test('llEscapeURL(llUnescapeURL(u"%F0%8F%BF%BFx"))', u'%3F%3F%3F%3Fx') # aliased range end (U+FFFF) + test('llEscapeURL(llUnescapeURL(u"%F0%90%80%80x"))', u'%F0%90%80%80x') # U+10000 (4-byte range start) + test('llEscapeURL(llUnescapeURL(u"%F4%8F%BF%BFx"))', u'%F4%8F%BF%BFx') # U+10FFFF (valid 4-byte range end) + # excluded because of truncation to U+10FFFF + test('llEscapeURL(llUnescapeURL(u"%F4%90%80%80x"))', u'%3F%3F%3F%3Fx') # U+110000 (invalid 4-byte range start) + test('llEscapeURL(llUnescapeURL(u"%F7%BF%BF%BFx"))', u'%3F%3F%3F%3Fx') # U+1FFFFF (invalid 4-byte range end) + test('llEscapeURL(llUnescapeURL(u"%F8%80%80%80%80x"))', u'%3F%3F%3F%3F%3Fx') # aliased range begin (U+0000) + test('llEscapeURL(llUnescapeURL(u"%F8%87%BF%BF%BFx"))', u'%3F%3F%3F%3F%3Fx') # aliased range end (U+1FFFFF) + test('llEscapeURL(llUnescapeURL(u"%F8%88%80%80%80x"))', u'%3F%3F%3F%3F%3Fx') # U+200000 (5-byte range start) + test('llEscapeURL(llUnescapeURL(u"%FB%BF%BF%BF%BFx"))', u'%3F%3F%3F%3F%3Fx') # U+3FFFFFF (5-byte range end) + test('llEscapeURL(llUnescapeURL(u"%FC%80%80%80%80%80x"))', u'%3F%3F%3F%3F%3F%3Fx') # aliased range begin (U+0000) + test('llEscapeURL(llUnescapeURL(u"%FC%83%BF%BF%BF%BFx"))', u'%3F%3F%3F%3F%3F%3Fx') # aliased range end (U+3FFFFFF) + test('llEscapeURL(llUnescapeURL(u"%FC%84%80%80%80%80x"))', u'%3F%3F%3F%3F%3F%3Fx') # U+4000000 (6-byte range start) + test('llEscapeURL(llUnescapeURL(u"%FD%BF%BF%BF%BF%BFx"))', u'%3F%3F%3F%3F%3F%3Fx') # U+7FFFFFFF (6-byte range end) + # not actually valid either way (these are actually used to distinguish the input as UTF-16 BOM) + test('llEscapeURL(llUnescapeURL(u"%FE%B0%80%80%80%80%80%80x"))', u'%3F%3F%3F%3F%3F%3F%3F%3Fx') + test('llEscapeURL(llUnescapeURL(u"%FF%BF%BF%BF%BF%BF%BF%BFx"))', u'%3F%3F%3F%3F%3F%3F%3F%3Fx') + + # Test that U+FFFD is preserved even with invalid characters + test('llEscapeURL(llUnescapeURL(u"%EF%BF%BD%90"))', u'%EF%BF%BD%3F') + + test('llParseString2List(u"[ 1 ]2|3|4|5", [u"|"], [u"[ ", u" ]"])', + [u"[ ", u"1", u" ]", u"2", u"3", u"4", u"5"]) + test('llParseString2List(u"[ 1 ]2|3|4|5", [u"|"], [u"|", u"|"])', + [u"[ 1 ]2", u"3", u"4", u"5"]) + test('llList2CSV(llParseString2List(u"1abc2ab3abc4",[u"ab",u"abc"],[]))', + u'1, c2, 3, c4') + test('llList2CSV(llParseString2List(u"1abc2ab3abc4",[u"abc",u"ab"],[]))', + u'1, 2, 3, 4') + test('llList2CSV(llParseStringKeepNulls(u"1abc2ab3abc4",[u"ab"],[u"abc"]))', + u'1, c2, 3, c4') + test('llList2CSV(llParseStringKeepNulls(u"1abc2ab3abc4",[u"ab"],[u"a"]))', + u'1, c2, 3, c4') + test('llList2CSV(llParseStringKeepNulls(u"1abc2ab3abc4",[u"ab"],[u"ab"]))', + u'1, c2, 3, c4') + test('llParseStringKeepNulls(u"",[],[])', [u""]) + test('llParseStringKeepNulls(u"",[],[""])', [u""]) + test('llParseStringKeepNulls(u"",[""],[])', [u""]) + test('llParseStringKeepNulls(u"",[""],[""])', [u""]) + test('llParseString2List(u"",[],[])', []); + test('llParseString2List(u"",[],[u""])', []); + test('llParseString2List(u"",[u""],[])', []); + test('llParseString2List(u"",[u""],[u""])', []); + test('llParseStringKeepNulls(u"a",[u""],[])', [u"a"]); + + + test(r'llToUpper(u"\u03c4\u03ac\u03c7\u03b9\u03c3\u03c4\u03b7 \u03b1\u03bb' + r'\u03ce\u03c0\u03b7\u03be \u03b2\u03b1\u03c6\u03ae\u03c2 \u03c8\u03b7' + r'\u03bc\u03ad\u03bd\u03b7 \u03b3\u03b7, \u03b4\u03c1\u03b1\u03c3' + r'\u03ba\u03b5\u03bb\u03af\u03b6\u03b5\u03b9 \u03c5\u03c0\u03ad\u03c1 ' + r'\u03bd\u03c9\u03b8\u03c1\u03bf\u03cd \u03ba\u03c5\u03bd\u03cc\u03c2")', + u'\u03a4\u0386\u03a7\u0399\u03a3\u03a4\u0397 \u0391\u039b\u038f\u03a0' + u'\u0397\u039e \u0392\u0391\u03a6\u0389\u03a3 \u03a8\u0397\u039c\u0388' + u'\u039d\u0397 \u0393\u0397, \u0394\u03a1\u0391\u03a3\u039a\u0395' + u'\u039b\u038a\u0396\u0395\u0399 \u03a5\u03a0\u0388\u03a1 \u039d\u03a9' + u'\u0398\u03a1\u039f\u038e \u039a\u03a5\u039d\u038c\u03a3') + + test(r'llToLower(u"\u03a4\u0386\u03a7\u0399\u03a3\u03a4\u0397 \u0391\u039b' + r'\u038f\u03a0\u0397\u039e \u0392\u0391\u03a6\u0389\u03a3 \u03a8\u0397' + r'\u039c\u0388\u039d\u0397 \u0393\u0397, \u0394\u03a1\u0391\u03a3' + r'\u039a\u0395\u039b\u038a\u0396\u0395\u0399 \u03a5\u03a0\u0388\u03a1 ' + r'\u039d\u03a9\u0398\u03a1\u039f\u038e \u039a\u03a5\u039d\u038c\u03a3")', + u'\u03c4\u03ac\u03c7\u03b9\u03c3\u03c4\u03b7 \u03b1\u03bb\u03ce\u03c0' + u'\u03b7\u03be \u03b2\u03b1\u03c6\u03ae\u03c3 \u03c8\u03b7\u03bc\u03ad' + u'\u03bd\u03b7 \u03b3\u03b7, \u03b4\u03c1\u03b1\u03c3\u03ba\u03b5' + u'\u03bb\u03af\u03b6\u03b5\u03b9 \u03c5\u03c0\u03ad\u03c1 \u03bd\u03c9' + u'\u03b8\u03c1\u03bf\u03cd \u03ba\u03c5\u03bd\u03cc\u03c3') + + test('llListStatistics(1, [])', 0.) + test('llListStatistics(0, [1.,5.,2,3,9,-1])', 10.) + test('llListStatistics(1, [1.,5.,-2,3,9,-1])', -2.) + test('llListStatistics(2, [1.,5.,2,3,9,-1])', 9.) + test('llListStatistics(3, [1.,5.,2,3,9,-1])', F('0x1.955556p+1')) + test('llListStatistics(4, [1.,5.,2,3,9,-1])', 2.5) + test('llListStatistics(4, [1.,5.,NaN,2,3,9,-1])', -1.) + test('llListStatistics(5, [1.,5.,2,3,9,-1])', F32(3.488075)) + test('llListStatistics(6, [1.,5.,2,3,9,-1])', 19.) + test('llListStatistics(7, [1.,5.,2,3,9,-1])', 121.) + test('llListStatistics(8, [1.,5.,2,3,9,-1])', 6.) + test('llListStatistics(9, [1.,5.,2.,3.,NaN,9.])', NaN) + test('llListStatistics(9, [1.,5.,2.,3.,NaN,-9.])', 0.) + test('llListStatistics(9, [1.,5.,2.,3.,1.,9.])', F('0x1.456A2Ep+1')) + test('llListStatistics(10, [1.,5.,2,3,9,-1])', 0.) + test('llList2ListStrided([1,2,3,4,5],0,-1,2)', [1,3,5]) + test('llList2ListStrided([1,2,3,4,5],1,-1,2)', [3,5]) + test('llList2ListStrided([1,2,3,4,5],0,-2,2)', [1,3]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],0,-4,3)', [1, 4, 7]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],0,-3,3)', [1, 4, 7, 10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],0,-1,3)', [1, 4, 7, 10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],-3,3,3)', [1, 4, 7, 10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],-2,-3,3)', [1, 4, 7, 10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],-2,-2,3)', []) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],-2,-1,3)', []) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],4,3,3)', [1,4,7,10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],4,4,3)', []) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],4,5,3)', []) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],5,5,3)', []) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],5,6,3)', [7]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,5,3)', [1,4,7,10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,6,3)', [7]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,2,-3)', [1,4,7,10]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,2,-2)', [1,3,5,7,9,11]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,2,-1)', [1,2,3,4,5,6,7,8,9,10,11,12]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,2,0)', [1,2,3,4,5,6,7,8,9,10,11,12]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,2,1)', [1,2,3,4,5,6,7,8,9,10,11,12]) + test('llList2ListStrided([1,2,3,4,5,6,7,8,9,10,11,12],6,20,3)', [7,10]) + + test('llListReplaceList([0,1,2,3,4,5],[6,7],2,3)', [0,1,6,7,4,5]) + test('llListReplaceList([0,1,2,3,4,5],[],2,3)', [0,1,4,5]) + test('llListReplaceList([0,1,2,3,4,5],[6,7],2,3)', [0,1,6,7,4,5]) + test('llListReplaceList([0,1,2,3,4,5],[6,7],2,-1)', [0,1,6,7]) + test('llListReplaceList([0,1,2,3,4,5],[],4,1)', [2,3]) + test('llListReplaceList([0,1,2,3,4,5],[6,7,8],4,1)', [2,3,6,7,8]) + test('llListReplaceList([0,1,2,3,4,5],[6,7,8],6,6)', [0,1,2,3,4,5,6,7,8]) + test('llListReplaceList([0,1,2,3,4,5],[6,7,8],7,6)', [6,7,8]) + test('llListReplaceList([0,1,2,3,4,5],[6,7,8],7,8)', [0,1,2,3,4,5,6,7,8]) + + test('llMD5String(u"", 0)', u'1a9d5db22c73a993ff0b42f64b396873') + test('llListInsertList([], [1], 0)', [1]) + test('llListInsertList([], [1], 3)', [1]) + test('llListInsertList([], [1], -1)', [1]) + test('llListInsertList([1,2,3,4,5],[9],-3)', [1,2,9,3,4,5]) + + + test('''llEscapeURL(llList2Json(JSON_OBJECT, [llUnescapeURL( + u"%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F" + u"%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F" + u"%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F" + u"%30%39%3A%3B%3C%3D%3E%3F%40%41%5A%5B%5C%5D%5E%5F" + u"%60%61%7A%7B%7C%7D%7E%7F%C2%80%C2%81"),Key(u"")]))''', + + u'%7B%22%01%02%03%04%05%06%07%5Cb%5Ct%5Cn%0B%5Cf%5Cr%0E%0F' + u'%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F' + u'%20%21%5C%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%5C%2F' + u'09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5C%5D%5E%5F%60az%7B%7C%7D%7E%7F' + u'%C2%80%C2%81%22%3A%22%22%7D') + + test(r'llEscapeURL(llList2Json(JSON_OBJECT, [u"blah",F32(Quaternion((1000000000000.0,-Infinity,NaN,-0.))), u"x", u"{\"}}"]))', + u'%7B%22blah%22%3A%22%3C999999995904%2E000000%2C%20%2Dinf%2C%20nan%2C%20' + u'%2D0%2E000000%3E%22%2C%22x%22%3A%7B%22%7D%7D%7D') + + test(r'llList2Json(JSON_OBJECT, [u"true",u"true"])', u'{"true":true}') + test(r'llList2Json(JSON_OBJECT, [u"true",u"tr\nue"])', ur'{"true":"tr\nue"}') + + # ... yeah + test(r'llList2Json(JSON_ARRAY, [u" "+JSON_INVALID+u" ",u" "+JSON_DELETE+u" ",' + r'u" "+JSON_STRING+u" ",JSON_NUMBER,JSON_OBJECT,JSON_ARRAY])', + u'[,"\ufdd8","\ufdd4","\ufdd3","\ufdd1","\ufdd2"]') + + + Bugs.add(6466) + test(r'llJson2List(u" -e11111.193147483650 ")', [0.0]) + test(r'llJson2List(u" 12345678901234 ")', [2147483647]) + test(r'llJson2List(u" 12345678901234e ")', [12345679020032.]) + test(r'llJson2List(u" 1.0e+1 ")', [u'1.0e+1']) + test(r'llJson2List(u" 5e-1.2 ")', [0.5]) + test(r'llJson2List(u" 0e0 ")', [0.]) + test(r'llJson2List(u" . ")', [0.]) + test(r'llJson2List(u" .5 ")', [0.5]) + test(r'llJson2List(u" .5e ")', [0.5]) + test(r'llJson2List(u" .e1 ")', [0.]) + test(r'llJson2List(u" 0.e1 ")', [0.]) + Bugs.discard(6466) + test(r'llJson2List(u" -e11111.193147483650 ")', [u'-e11111.193147483650']) + test(r'llJson2List(u" 12345678901234 ")', [2147483647]) + test(r'llJson2List(u" 12345678901234e ")', [12345679020032.]) + test(r'llJson2List(u" 1.0e+1 ")', [10.0]) + test(r'llJson2List(u" 5e-1.2 ")', [0.5]) + test(r'llJson2List(u" 0e0 ")', [u'0e0']) + test(r'llJson2List(u" . ")', [0.]) + test(r'llJson2List(u" .5 ")', [0.5]) + test(r'llJson2List(u" .5e ")', [0.5]) + test(r'llJson2List(u" .e1 ")', [u'.e1']) + test(r'llJson2List(u" 0.e1 ")', [0.]) + test(r'llJson2List(u" -12345678901234 ")', [-2147483648]) + test(r'llJson2List(u" -123456 ")', [-123456]) + test(r'llJson2List(u" true ")', [JSON_TRUE]) + test(r'llJson2List(u" \"blah\\\" ")', [u'blah\\']) + test(r'llJson2List(u" True ")', [u'True']) + test(r'llJson2List(u" \" ")', [u'"']) + + # Here's where the fun begins. Solve this puzzle. + test(r'llJson2List(u" \"ab,c\"3{,\"de\\1234\" ")', [u'ab,c"3{,"de1234']) + # INCOMPAT: Too crazy to make it work compatibly. All these tests fail. + #test(r'llJson2List(u" { \"ab,c\"3{,\"de\\1234\" } ")', [u'', u'"ab,c"3']) + #test(r'llJson2List(u" { x: \"ab,c\"3{,\"de\\1234\" } ")', [JSON_INVALID]) + #test(r'llJson2List(u" { \"x\": \"ab,c\"3{,\"de\\1234\" } ")', [u'x', u'"ab,c"3']) + #test(r'llJson2List(u" [ \"x\": \"ab,c\"3{,\"de\\1234\" ] ")', [u'x', u'"ab,c"3']) + #test(r'llJson2List(u" [ ab,c\"3{,\"de\\1234} ] ")', [u'ab', ur'"3,de\1234']) + #test(r'llJson2List(u" [ ab, tes{t3\"de\\1234\" ] ")', [u'ab', u'tes']) + #test(r'llJson2List(u" [ ab, tes{t3\"de\\1234}\" ] ")', [u'ab', u'"']) + #test(r'llJson2List(u" [ ab, tes{t3\"de\\1234}\"x\" ] ")', [u'ab', u'x']) + #test(r'llJson2List(u" [ ab, tes{t3\"de\\1234}x ] ")', [u'ab', ur'tes{t3"de\1234}x']) + #test(r'llJson2List(u" [ ab, test\"3{,\"de\\1234} ] ")', [u'ab', ur'"3{,"de\1234}']) + test(r'llJson2List(u"[,,3]")', [u'', u'', 3]) + test(r'llJson2List(u"[:,2,3]")', [JSON_INVALID]) + test(r'llJson2List(u"[;,,3]")', [u';', u'', 3]) + test(r'llJson2List(u"[],,3]")', [u']', u'', 3]) # nice, huh? + # INCOMPAT: + #test(r'llJson2List(u"[[,,3]")', [u'']) # Even crazier. Not going to try to make that work. + test(r'llJson2List(u"[,],3]")', [u'', u']', 3]) + test(r'llJson2List(u"{1}")', [u'', 1]) + test(r'llJson2List(u"{\"a\"}")', [u'', u'a']) + test(r'llJson2List(u"{1,2}")', [JSON_INVALID]) + test(r'llJson2List(u"{\"\":1,\"a\":2}")', [JSON_INVALID]) # Empty names are only allowed at the end. + test(r'llJson2List(u"{\"a\":1,\"\":2}")', [u'a',1,u'',2]) + test(r'llJson2List(u"{\"a\":1,2}")', [u'a',1,u'',2]) + test(r'llJson2List(u"{\"a\":1,}")', [u'a',1,u'',u'']) + test(r'llJson2List(u"{\"a\":},}}")', [u'a', u'}', u'', u'}']) + + test(r'llJsonGetValue(u" { ab, tes{t3\"de\\1234}x ", [])', JSON_INVALID) + Bugs.add(6466) + test(r'llJsonGetValue(u"x", [])', JSON_INVALID) + test(r'llJsonGetValue(u"e", [])', u'e') + Bugs.discard(6466) + test(r'llJsonGetValue(u"x", [])', JSON_INVALID) + test(r'llJsonGetValue(u"e", [])', JSON_INVALID) + test(r'llJsonGetValue(u"", [])', JSON_INVALID) + test(r'llJsonGetValue(u"}", [])', JSON_INVALID) + test(r'llJsonGetValue(u"{", [])', JSON_INVALID) + test(r'llJsonGetValue(u" ", [])', JSON_INVALID) + test(r'llJsonGetValue(u" , ", [])', JSON_INVALID) + test(r'llJsonGetValue(u" null ", [])', JSON_NULL) + test(r'llJsonGetValue(u" false ", [])', JSON_FALSE) + test(r'llJsonGetValue(u" true ", [])', JSON_TRUE) + test(r'llJsonGetValue(u"true,", [])', JSON_INVALID) + test(r'llJsonGetValue(u"true,false", [])', JSON_INVALID) + test(r'llJsonGetValue(u"{x}", [])', u'{x}') + test(r'llJsonGetValue(u"[x]", [])', u'[x]') + test(r'llJsonGetValue(u" \"blah\\\\\" ", [])', u'blah\\') + test(r'llJsonGetValue(u" \"blah\\\" ", [])', u'blah\\') + test(r'llJsonGetValue(u" [[[]]]]]]][] ", [])', u'[[[]]]]]]][]') + + test(r'llJsonGetValue(u"{\"a\":[1],\"a\":[2],\"a\":[3]}", [u"a",0])', u'3') + test(r'llJsonGetValue(u"{\"a\":[2,3,[4]],\"a\":1}", [u"a", 2, 0])', JSON_INVALID); + + test(r'llJsonGetValue(u"{\"a\":1,}",["a"])', JSON_INVALID) + + + test(r'llJsonGetValue(u"[3,4,5,[6,7,8],:9,10]", [1])', JSON_INVALID) # *ing crap! ALL entries are tested before the result is returned... + test(r'llJsonGetValue(u"[3,4,5,[6,7,:8]]", [1])', u'4') # ... But only at the current nesting level. Crazy. + test(r'llJsonGetValue(u"[3,4,5,{:6,7,8}]", [1])', u'4') + test(r'llJsonGetValue(u"[[[[1,2,[3],4],5],6],7]", [0,0,0,2])', u'[3]') + test(r'llJsonGetValue(u"[[[[1,2,[3],4],5],6],7]", [0,0,0,2,0])', u'3') + # This suggests recursivity is used, once per nesting level, and that deeper levels remain unchecked: + test(r'llJsonGetValue(u"[[[[1,2,[:3],4],5],6],7]", [0,0,0,2,0])', JSON_INVALID) + test(r'llJsonGetValue(u"[[[[1,2,[:3],4],5],6],7]", [0,0,0,2])', u'[:3]') + test(r'llJsonGetValue(u"[[[[1,2,[3],:4],5],6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonGetValue(u"[[[[1,2,[3],4],:5],6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonGetValue(u"[[[[1,2,[3],4],5],:6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonGetValue(u"[[[[1,2,[3],4],5],6],:7]", [0,0,0,2])', JSON_INVALID) + # same with value type + test(r'llJsonValueType(u"[[[[1,2,[3],4],5],6],7]", [0,0,0,2,0])', JSON_NUMBER) + test(r'llJsonValueType(u"[[[[1,2,[:3],4],5],6],7]", [0,0,0,2,0])', JSON_INVALID) + test(r'llJsonValueType(u"[[[[1,2,[:3],4],5],6],7]", [0,0,0,2])', JSON_ARRAY) + test(r'llJsonValueType(u"[[[[1,2,[3],:4],5],6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonValueType(u"[[[[1,2,[3],4],:5],6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonValueType(u"[[[[1,2,[3],4],5],:6],7]", [0,0,0,2])', JSON_INVALID) + test(r'llJsonValueType(u"[[[[1,2,[3],4],5],6],:7]", [0,0,0,2])', JSON_INVALID) + + if 6495 in Bugs: + # OH-MY-FLYINGSPAGHETTIMONSTER!!!!!! A nested string can't contain "]"!!!! + # INCOMPAT: Too crazy. We're not emulating that. + #test(r'llJsonGetValue(u"[[[[1,2,[\"],4]\",5],6],7]]]", [0,0,0,2])', JSON_INVALID) + # Simpler test case: + # INCOMPAT + #test(r'llJsonGetValue(u"[[\"[\"]]", [0])', JSON_INVALID) + #test(r'llJsonGetValue(u"[[\"]\"]]", [0])', JSON_INVALID) + #test(r'llJsonGetValue(u"[{\"{\":0}]", [0])', JSON_INVALID) + #test(r'llJsonGetValue(u"[{\"}\":0}]", [0])', JSON_INVALID) + test(r'llJsonGetValue(u"[[\"{\"]]", [0])', u'["{"]') + test(r'llJsonGetValue(u"[[\"}\"]]", [0])', u'["}"]') + test(r'llJsonGetValue(u"[{\"[\":0}]", [0])', u'{"[":0}') + test(r'llJsonGetValue(u"[{\"]\":0}]", [0])', u'{"]":0}') + # And proper balance removes the problem. + test(r'llJsonGetValue(u"[[\"[]\"]]", [0])', u'["[]"]') + # Even if not too proper. + test(r'llJsonGetValue(u"[[\"][\"]]", [0])', u'["]["]') + test(r'llJsonGetValue(u"[[\"][\"]]", [0,0])', u'][') + #INCOMPAT + #test(r'llJsonGetValue(u"[[][]]", [0])', u'[][]') + #test(r'llJsonValueType(u"[[][]]", [0])', JSON_ARRAY) + test(r'llJsonGetValue(u"[[][]]", [0,0])', JSON_INVALID) + # Depth zero is special, no error there: + test(r'llJsonGetValue(u"[\"[\"]", [])', u'["["]') + test(r'llJsonGetValue(u"[\"[\"]", [0])', u'[') + + # INCOMPAT + #test(r'llJsonGetValue(u"[\"[\\\"\\\\\"]", [0])', JSON_INVALID) # File this under WTF. + #test(r'llJsonGetValue(u"[\"[\\\"\\\\\"", [0])', u'"[\\') # Ditto. + #test(r'llJsonGetValue(u"[\"\\\\\"]", [0])', JSON_INVALID) # This seems to be the essence. + #test(r'llJsonGetValue(u"[\"\\\\\"", [0])', u'\\') + else: + test(r'llJsonGetValue(u"[[[[1,2,[\"],4]\",5],6],7]]]", [0,0,0,2])', u'["],4]",5]') + # INCOMPAT + #test(r'llJsonGetValue(u"[[\"[\"]]", [0])', u'["["]') + #test(r'llJsonGetValue(u"[[\"]\"]]", [0])', u'["]"]') + #test(r'llJsonGetValue(u"[{\"{\":0}]", [0])', u'{"{":0}') + #test(r'llJsonGetValue(u"[{\"}\":0}]", [0])', u'{"}":0}') + test(r'llJsonGetValue(u"[[\"{\"]]", [0])', u'["{"]') + test(r'llJsonGetValue(u"[[\"}\"]]", [0])', u'["}"]') + test(r'llJsonGetValue(u"[{\"[\":0}]", [0])', u'{"[":0}') + test(r'llJsonGetValue(u"[{\"]\":0}]", [0])', u'{"]":0}') + test(r'llJsonGetValue(u"[[\"[]\"]]", [0])', u'["[]"]') + test(r'llJsonGetValue(u"[[\"][\"]]", [0])', u'["]["]') + test(r'llJsonGetValue(u"[[\"][\"]]", [0,0])', u'][') + # INCOMPAT + #test(r'llJsonGetValue(u"[[][]]", [0])', u'[][]') + #test(r'llJsonValueType(u"[[][]]", [0])', JSON_ARRAY) + test(r'llJsonGetValue(u"[[][]]", [0,0])', JSON_INVALID) + test(r'llJsonGetValue(u"[\"[\"]", [])', u'["["]') + test(r'llJsonGetValue(u"[\"[\"]", [0])', u'[') + + # INCOMPAT + #test(r'llJsonGetValue(u"[\"[\\\"\\\\\"]", [0])', u'["\\') + #test(r'llJsonGetValue(u"[\"[\\\"\\\\\"", [0])', JSON_INVALID) + #test(r'llJsonGetValue(u"[\"\\\\\"]", [0])', u'\\') + #test(r'llJsonGetValue(u"[\"\\\\\"", [0])', JSON_INVALID) + + # This proves that it converts to integer when traversing an array. + # MAINT-2671 introduced a check for the first character, which is reflected + # in the tests. Apparently the test is just Firstchar in [0-9]. + test(r'llJsonGetValue(u"[[1,2],{\"a\":0}]",[u"0.9999999999"])', u"[1,2]") + # This test mimicks the test for MAINT-2671 in the wiki tests. + test(r'llJsonGetValue(u"[[1,2],{\"a\":0}]",[u"f"])', JSON_INVALID) + # FIXME: llJsonSetValue pending + '''test(r'llJsonSetValue(u"", [u"0",1], u"1")', JSON_INVALID) + test(r'llJsonSetValue(u"", [u"0",0], u"1")', u'{"0":[1]}') + test(r'llJsonSetValue(u"", [u"0",0.0], u"1")', u'{"0":}') + test(r'llJsonSetValue(u"", [u"0",0.0], u"1")', u'{"0":}') + test(r'llJsonSetValue(u"", [u"0",u"0"], u"1")', u'{"0":{u"0":1}}') + test(r'llJsonSetValue(u"", [u"0",Key(u"0")], u"1")', u'{"0":{u"0":1}}') + test(r'llJsonSetValue(u"", [u"0",ZERO_VECTOR], u"1")', u'{"0":}') + test(r'llJsonSetValue(u"", [ZERO_VECTOR], u"1")', u'') + test(r'llJsonSetValue(u" [ 1 , 2 , [ 3 , 4 ] ] ", [0], u"1")', u'[1,2,[ 3 , 4 ]]') + + test(r'llJsonSetValue(u" { \"a\" : [ 1 ] , \"a\" : 2 } ",[u"a"], u"3")', u'{"a":3}') + test(r'llJsonSetValue(u" { \"a\" : [ 1 ] , \"a\" : 2 } ",[u"a",0], u"3")', u'{"a":[3]}') + test(r'llJsonSetValue(u" { \"a\" : [ 1 ] , \"a\" : 2 } ",[u"a",0], u"3")', u'{"a":3}') + test(r'llJsonSetValue(u" { \"a\" : [ 1 , 2 ] , \"a\" : 3 } ",[u"a",0], u"4")', u'{"a":[4]}') + # This proves the path must be found in the *last* match of an object: + test(r'llJsonSetValue(u" { \"a\" : [ 1 , 2 ] , \"a\" : 3 } ",[u"a",1], u"4")', JSON_INVALID) + test(r'llJsonSetValue(u" { \"a\" : 3 , \"a\" : [ 1 , 2 ] } ",[u"a",0], u"4")', u'{"a":[4,2]}') + test(r'llJsonSetValue(u" { \"a\" : 3 , \"a\" : [ 1 , 2 ] } ",[u"a",1], u"4")', u'{"a":[1,4]}') + test(r'llJsonSetValue(u" { \"a\" : 3 , \"b\" : 6, \"a\" : [ 1 , 2 ] } ",[u"a",1], u"4")', u'{"a":[1,4],"b":6}') + test(r'llJsonSetValue(u" { \"b\" : 3 , \"a\" : 6, \"b\" : [ 1 , 2 ] } ",[u"b",1], u"4")', u'{"a":6,"b":[1,4]}') + # This proves llJsonSetValue sorts the items it recurses into and keeps + # just one copy of them. + # No "a13" in original but some dupes: + test(r'llJsonSetValue(u"{\"b\":{\"a9\":15,\"a0\":16,\"a7\":27,\"a20\":28,' + r'\"a7\":21,\"a21\":22,\"a8\":7,\"a24\":8,\"a9\":13,\"a0\":14,\"a26\":29,' + r'\"a20\":30,\"a0\":11,\"a26\":12,\"a14\":19,\"a10\":20,\"a11\":1,' + r'\"a12\":2,\"a9\":23,\"a4\":24,\"a20\":5,\"a17\":6,\"a21\":17,\"a3\":18,' + r'\"a4\":9,\"a1\":10,\"a10\":3,\"a26\":4,\"a21\":25,\"a17\":26},' + r'\"a\":{\"a9\":15,\"a0\":16,\"a7\":27,\"a20\":28,\"a7\":21,\"a21\":22,' + r'\"a8\":7,\"a24\":8,\"a9\":13,\"a0\":14,\"a26\":29,\"a20\":30,\"a0\":11,' + r'\"a26\":12,\"a14\":19,\"a10\":20,\"a11\":1,\"a12\":2,\"a9\":23,\"a4\":24' + r',\"a20\":5,\"a17\":6,\"a21\":17,\"a3\":18,\"a4\":9,\"a1\":10,\"a10\":3' + r',\"a26\":4,\"a21\":25,\"a17\":26}}", [u"b",u"a13"], u"\"*********\"")', + u'{"a":{"a9":15,"a0":16,"a7":27,"a20":28,"a7":21,"a21":22,"a8":7,' + u'"a24":8,"a9":13,"a0":14,"a26":29,"a20":30,"a0":11,"a26":12,"a14":19,' + u'"a10":20,"a11":1,"a12":2,"a9":23,"a4":24,"a20":5,"a17":6,"a21":17,' + u'"a3":18,"a4":9,"a1":10,"a10":3,"a26":4,"a21":25,"a17":26},' + u'"b":{"a0":11,"a1":10,"a10":3,"a11":1,"a12":2,"a13":"*********","a14":19,' + u'"a17":26,"a20":5,"a21":25,"a24":8,"a26":4,"a3":18,"a4":9,"a7":21,"a8":7,' + u'"a9":23}}') + # Two "a13" in original (and some other dups such as "a9" which appears three times): + test(r'llJsonSetValue(u"{\"b\":{\"a12\":19,\"a23\":20,\"a9\":7,\"a7\":8,' + r'\"a28\":21,\"a15\":22,\"a9\":17,\"a22\":18,\"a1\":13,\"a26\":14,' + r'\"a7\":23,\"a13\":24,' # <-- 1st instance of "a13" + r'\"a9\":3,\"a26\":4,\"a14\":9,\"a24\":10,\"a12\":29,' + r'\"a16\":30,\"a25\":5,\"a23\":6,\"a2\":11,\"a13\":12,' # <-- 2nd instance + r'\"a11\":1,\"a12\":2,' + r'\"a15\":25,\"a25\":26,\"a25\":27,\"a18\":28,\"a22\":15,\"a27\":16},' + r'\"a\":{\"a12\":19,\"a23\":20,\"a9\":7,\"a7\":8,\"a28\":21,\"a15\":22,' + r'\"a9\":17,\"a22\":18,\"a1\":13,\"a26\":14,\"a7\":23,\"a13\":24,\"a9\":3,' + r'\"a26\":4,\"a14\":9,\"a24\":10,\"a12\":29,\"a16\":30,\"a25\":5,' + r'\"a23\":6,\"a2\":11,\"a13\":12,\"a11\":1,\"a12\":2,\"a15\":25,' + r'\"a25\":26,\"a25\":27,\"a18\":28,\"a22\":15,\"a27\":16}}",' + r' [u"b",u"a13"],u"\"*********\"")', + # "a" is respected but put *before* "b". + u'{"a":{"a12":19,"a23":20,"a9":7,"a7":8,"a28":21,"a15":22,"a9":17,' + u'"a22":18,"a1":13,"a26":14,"a7":23,"a13":24,"a9":3,"a26":4,"a14":9,' + u'"a24":10,"a12":29,"a16":30,"a25":5,"a23":6,"a2":11,"a13":12,"a11":1,' + u'"a12":2,"a15":25,"a25":26,"a25":27,"a18":28,"a22":15,"a27":16},' + # "b" has only one of each including "a13", and has its elements sorted. + # Only the last element of each repetition is kept. + u'"b":{"a1":13,"a11":1,"a12":2,"a13":"*********","a14":9,"a15":25,' + u'"a16":30,"a18":28,"a2":11,"a22":15,"a23":6,"a24":10,"a25":27,"a26":4,' + u'"a27":16,"a28":21,"a7":23,"a9":3}}') + + # Incoming facepalm series. + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], u" "+JSON_DELETE+u" ")', JSON_DELETE) + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], u" "+JSON_INVALID+u" ")', u'') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], u" "+JSON_STRING+u" ")', u'"' + JSON_STRING + u'"') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], JSON_NUMBER)', u'"' + JSON_NUMBER + u'"') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], JSON_OBJECT)', u'"' + JSON_OBJECT + u'"') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], JSON_ARRAY)', u'"' + JSON_ARRAY + u'"') + test(r'llJsonSetValue(u"[1,2,3]", [0,0,0], JSON_INVALID)', u'[[[]],2,3]') + test(r'llJsonSetValue(u"[1,2,3]", [0,0,0], JSON_DELETE)', JSON_INVALID) + + # These are sane-ish or at least they make sense. + test(r'llJsonSetValue(u"[1,2,3]", [0,0,0], u"")', u'[[[""]],2,3]') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], u" "+JSON_TRUE+u" ")', u'true') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], JSON_FALSE)', u'false') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", [], JSON_NULL)', u'null') + + # Elements are completely replaced if the type doesn't match. + # E.g. an object turns into a zero-length array if necessary. + # And there's no numeric evaluation of strings. + test(r'llJsonSetValue(u"{\"a\":3}", [u"a"], u"")', u'{"a":""}') + test(r'llJsonSetValue(u"{\"a\":3}", [u"0"], u"")', u'{"0":"","a":3}') + test(r'llJsonSetValue(u"[\"a\",3]", [u"0"], u"")', u'{"0":""}') + test(r'llJsonSetValue(u"[\"a\",3]", [1, u"0"], u"")', u'["a",{"0":""}]') + test(r'llJsonSetValue(u"{\"a\":3}", [1, u"0"], u"")', JSON_INVALID) + test(r'llJsonSetValue(u"{\"a\":3}", [0, u"0"], u"")', u'[{"0":""}]') + test(r'llJsonSetValue(u"{\"a\":3,\"b\":4}", ["a"], u" "+JSON_DELETE+u" ")', u'{"b":4}') +''' + # JSON tests from the wiki + test_types(); + test_get_value(); + # FIXME: llJsonSetValue pending + #test_set_value(); + test_json_to_list(); + test_list_to_json(); + # FIXME: llJsonSetValue pending + #test_strings_with_escaped_chars(); + test_jira_fixes(); + +do_tests() + +print +print tests, "tests in suite" +print tests-untested, "tests run" +print errors, "errors found" +print tests-untested-errors, "tests passed" + +# Disassemble +#import dis +#dis.disco(sub.__code__) + +#from deadcode import finddeadcode +# +#dead = finddeadcode(InternalUTF8toString.__code__) +# +#if dead: +# for line in dead: +# print "Line %d is unreachable" % line +#elif dead == []: +# print "No unreachable lines found." +#else: +# print "No line info in code?!" diff --git a/testparser.py b/testparser.py new file mode 100644 index 0000000..7b5dee4 --- /dev/null +++ b/testparser.py @@ -0,0 +1,216 @@ +from lslopt.lslparse import parser,EParseSyntax,EParseUEOF,EParseAlreadyDefined,\ + EParseUndefined,EParseTypeMismatch,EParseReturnShouldBeEmpty,EParseReturnIsEmpty,\ + EParseInvalidField,EParseFunctionMismatch,EParseDeclarationScope,EParseUnexpected,\ + fieldpos +from lslopt.lsloutput import outscript +from lslopt import lslfuncs +import unittest +import os + +class UnitTestCase(unittest.TestCase): + pass + +class TestCompiler(UnitTestCase): + def setUp(self): + self.parser = parser() + self.outscript = outscript() + + def test_coverage(self): + try: + os.remove('overwritten.lsl') + except OSError: + pass + f = open('overwritten.lsl', 'wb') + f.write('/*Autogenerated*/default{timer(){}}') + f.close() + del f + self.parser.parsefile('overwritten.lsl') + self.outscript.output(self.parser.parse("""default{touch(integer n){jump n;@n;}}""")) + self.assertRaises(EParseUndefined, self.parser.parse, """default{touch(integer n){jump k;n;}}""") + self.outscript.output(self.parser.parse("""default{touch(integer n){n;}}""")) + print self.outscript.output(self.parser.parse(r"""string x=""; + vector V=ZERO_VECTOR; + vector W = <1,2,3>; + quaternion Q = <1,2,3,4>; + float f; + float ff = f; + list L = []; + list L2 = [2,3,4,5,6]; + integer fn(integer x){ + if (1) for (f=3,f=4,f=5;3;f++,f++) do while(0); while(0); else if (2) return 2; else; + fn(3); + integer j = 3||4&&5|6^7&8.==9!=10.e+01f<11<=12>13.>=14<<15>>16== ++f+-f++; + j *= 3.0; // LSL allows this + 1+((float)2+(integer)(1+1)); + 12345678901;0x000000012345678901;0x000; + 2*(V*V/4)*V*--V.x*V.x++; + L+L2;L+1;1+L; + <0,0,0.>0>0>*<0,0,0==0>2,3>>3>3.>%<3,4,5>; + f -= TRUE-(integer)-1; + f *= !FALSE; + V %= ZERO_VECTOR*ZERO_ROTATION; + 1e37;1.1e22;1.; + print(V *= 3); + fwd("","",""); + L"\n\t\rxxxx"; + {f;} + [1,2,3]; + } + fwd(string a,string b,string c){} + default{touch(integer n){n;state default;state another;return;}timer(){}} + state another{timer(){}}//""")) + self.assertRaises(EParseUEOF, self.parser.parse, '') + self.assertRaises(EParseUEOF, self.parser.parse, 'default') + self.assertRaises(EParseSyntax, self.parser.parse, 'x') + self.outscript.output(self.parser.parse('integer x=TRUE;integer y=x;integer j=FALSE;default{timer(){}}')) + self.assertRaises(EParseSyntax, self.parser.parse, ';') + self.assertRaises(EParseSyntax, self.parser.parse, 'f(){}g(integer x,key y){{}}h(;){}') + self.assertRaises(EParseSyntax, self.parser.parse, 'f(){}g(integer x,key y){}h()}') + self.assertRaises(EParseUEOF, self.parser.parse, 'integer "') + self.assertRaises(EParseSyntax, self.parser.parse, 'default{timer(){}}state blah{timer(){}}state ;') + self.assertRaises(EParseSyntax, self.parser.parse, 'default{timer(integer x){}}') + self.assertRaises(EParseSyntax, self.parser.parse, 'default{timer(integer x){(integer)x=0}}') + self.assertRaises(EParseSyntax, self.parser.parse, 'default{timer(){state;}}') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, 'default{timer(integer x,integer x){}}') + self.assertRaises(EParseSyntax, self.parser.parse, 'x;') + self.assertRaises(EParseSyntax, self.parser.parse, '1e;') + self.assertRaises(EParseSyntax, self.parser.parse, 'integer x=-TRUE;') + self.assertRaises(EParseSyntax, self.parser.parse, 'integer x=-3;integer y=-x;') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, '''float x=3;float x;''') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, '''default{timer(){}} + state blah{timer(){}} + state blah{}''') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, '''default{timer(){@x;@x;}}''') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, '''default{timer(){integer x;@x;}}''') + self.assertRaises(EParseAlreadyDefined, self.parser.parse, '''default{timer(){@x;integer x;}}''') + self.assertRaises(EParseUEOF, self.parser.parse, 'float x=3+3;', set(('extendedglobalexpr',))) + self.assertRaises(EParseUndefined, self.parser.parse, '''float x=-2147483648;float y=z;''') + self.assertRaises(EParseUndefined, self.parser.parse, '''float z(){;}float y=z;''') + self.assertRaises(EParseUndefined, self.parser.parse, '''float y=z;float z;''') + self.assertRaises(EParseUndefined, self.parser.parse, '''default{timer(){state blah;}}''') + self.assertRaises(EParseUndefined, self.parser.parse, '''f(){k;}''') + self.assertRaises(EParseReturnShouldBeEmpty, self.parser.parse, '''default{timer(){return 1;}}''') + self.assertRaises(EParseReturnIsEmpty, self.parser.parse, '''integer f(){return;}''') + self.assertRaises(EParseFunctionMismatch, self.parser.parse, '''f(integer i){f("");}''') + self.assertRaises(EParseFunctionMismatch, self.parser.parse, '''f(integer i){f(1,2);}''') + self.assertRaises(EParseFunctionMismatch, self.parser.parse, '''f(integer i){f(f(1));}''') + self.assertRaises(EParseFunctionMismatch, self.parser.parse, '''f(integer i){f();}''') + self.assertRaises(EParseDeclarationScope, self.parser.parse, '''f(){if (1) integer i;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){[f()];}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.||2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3||2.;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.|2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3|2.;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.&2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3&2.;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.^2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3^2.;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){f()!=2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){2!=f();}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.<"";}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""<"".;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3.<<2;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3>>2.;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""-(key)"";}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""+f();}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""+(key)"";}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){key k;k+k;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3/<1,2,3>;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3/<1,2,3,4>;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""*3;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""%4;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){3%<2,3,4>;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){""%4;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){(vector)4;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){key k;k+=k;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;i++;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;(i-=i);}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;(i*=i);}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;-i;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;~i;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;!i;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;++i;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''g(){integer k;k=g();}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''g(){@x;x;}state x{}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''g(){print(g());}state x{}''') + self.assertRaises(EParseUndefined, self.parser.parse, '''g(){integer k;k();}''') + self.assertRaises(EParseUndefined, self.parser.parse, '''g(){++x;}state x{}''') + self.assertRaises(EParseUndefined, self.parser.parse, '''g(){print(x);}state x{}''') + self.assertRaises(EParseUEOF, self.parser.parse, '''f(){(integer)''') + self.assertRaises(EParseInvalidField, self.parser.parse, '''f(){vector v;v.s;}''') + self.assertRaises(EParseSyntax, self.parser.parse, '''f(){<1,2,3,4==5>;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){<1,2,3,4>"">;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){<1,2,3,"">"">;}''') + self.assertRaises(EParseTypeMismatch, self.parser.parse, '''f(){string i;(i&=i);}''', + set(('extendedassignment'))) + + # Force a list constant down its throat, to test coverage of LIST_VALUE + self.parser.constants['LISTCONST']=[1,2,3] + print self.outscript.output(self.parser.parse('default{timer(){LISTCONST;}}')) + + print self.outscript.output(self.parser.parse(''' + float f=2+2; + default{timer(){ + 1+([]+(integer)~1); + list a; + float f; + a = 3; a += 3; + f += 4; + integer i; + i |= i; + i>>=i; + }}''', + set(('explicitcast','extendedtypecast','extendedassignment', + 'extendedglobalexpr')))) + print self.parser.scopeindex + self.assertRaises(EParseUnexpected, self.parser.PopScope) + + self.assertEqual(fieldpos("a,b",",",3),-1) + self.assertRaises(lslfuncs.ELSLTypeMismatch, self.outscript.Value2LSL, lslfuncs.Key(u'')) + self.assertRaises(lslfuncs.ELSLTypeMismatch, self.outscript.Value2LSL, '') + + def tearDown(self): + del self.parser + del self.outscript + +class TestLibraryLoader(UnitTestCase): + def test_coverage(self): + try: + os.remove('builtins.txt') + except OSError: + pass + f = open('builtins.txt', 'wb') + f.write(r'''const key a="\t" +event ev(integer i) +event ev(integer i) +quaternion x(integer i) +void x(integer i) +blah +const vector a = <4,5,3,2> +const vector a = <4,5,3,2 +const vector a = +const vector a = <4,x,3> +const vector a = <3,4,x> +const rotation a = <3,4,4,x> +const list l = [] +const quaternion q=<1,2,3,4> +const string v=" +const string q="\t" +''') + f.close() + parser() + f = open('builtins.txt.dat', 'rb') + b = f.read() + f.close() + try: + os.remove('builtins.txt') + except OSError: + pass + f = open('builtins.txt', 'wb') + f.write(b) + f.close() + parser() + + +if __name__ == '__main__': + unittest.main()